          (let [path (if (instance? File res)
                       (.getPath ^File res)
                       (.getPath ^java.net.URL res))
-               ;; cache (if output-dir
-               ;;         (cache-file res output-dir))
-               ]
+               cache (when (and (:cache-analysis opts) output-dir)
+                       (cache-file res output-dir))]
            (when-not (get-in @env/*compiler* [::analyzed-cljs path])
              (binding [*cljs-ns* 'cljs.user
                        *cljs-file* path

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

(defn requires-analysis? [^File f ^File cache]
  (or (not (.exists cache))
      (> (.lastModified f) (.lastModified cache))
      (let [version' (util/compiled-by-version cache)
            version  (util/clojurescript-version)]
        (and version (not= version version')))))

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

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

                                 (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)))))))))

