                                  (recur (:name ast) (next forms))
                                  (recur ns (next forms))))
                              ns))]
+                 (when cache
+                   (spit cache
+                     (str ";; Analyzed by ClojureScript " (util/clojurescript-version) "\n"
+                       (pr-str (get-in @env/*compiler* [::namespaces ns])))))
                  (swap! env/*compiler* assoc-in [::analyzed-cljs path] true)))))))))
 

            [clojure.tools.reader.reader-types :as readers])
  (:import java.lang.StringBuilder
           java.io.File
           [cljs.tagged_literals JSValue]))

(set! *warn-on-reflection* true)

        (swap! env/*compiler* assoc ::namespaces namespaces')
        ret))))

(defn cache-file
  ([src] (cache-file src "out"))
  ([src output-dir]
    (let [ns-info (parse-ns src)]
      (io/file (str (util/to-target-file output-dir ns-info) ".cache.edn")))))

(defn last-modified [src]
  (cond
    (instance? File src) (.lastModified ^File src)
    (instance? URL src) (.getLastModified (.openConnection ^URL src))
    :else
    (throw
      (IllegalArgumentException. (str "Cannot get last modified for " src)))))

(defn requires-analysis?
  ([src] (requires-analysis? src "out"))
  ([src output-dir]
    (let [cache (cache-file src output-dir)]
      (requires-analysis? src cache output-dir)))
  ([src ^File cache output-dir]
    (if (not (.exists cache))
      true
      (let [out-src (util/to-target-file output-dir (parse-ns src))]
        (if (not (.exists out-src))
          true
          (or
            (> (last-modified src) (last-modified cache))
            (let [version' (util/compiled-by-version cache)
                  version (util/clojurescript-version)]
              (and version (not= version version')))))))))

(defn analyze-file
  ([f] (analyze-file f nil))
