(defn write-analysis-cache
([ns cache-file]
(write-analysis-cache ns cache-file nil))
([ns ^File cache-file src]
(util/mkdirs cache-file)
(dump-specs ns)
(let [ext (util/ext cache-file)
analysis (dissoc (get-in @env/*compiler* [::namespaces ns]) :macros)]
(case ext
"edn" (spit cache-file
(str (when
(str ";; Analyzed by ClojureScript " (util/clojurescript-version) "\n"))
(pr-str analysis)))
"json" (when-let [{:keys [writer write]} @transit]
(write
(writer (FileOutputStream. cache-file) :json
transit-write-opts)
analysis))))
(when src
(.setLastModified ^File cache-file (util/last-modified src)))))