Skip to content

Commit a43ae53

Browse files
committed
Clarify cljs.analyzer/cache-file docstring
add `cljs.closure/aot-cache-core` helper, prep for CLJS-897 and CLJS-899. `cljs.compiler/compile-file` is now :cache-analysis aware. Previously compilation would not write out analysis cache files.
1 parent 7d25650 commit a43ae53

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,8 @@ argument, which the reader will use in any emitted errors."
18861886
ret))))
18871887

18881888
(defn cache-file
1889+
"Given a ClojureScript source file returns the _output_ path to the analysis
1890+
cache file."
18891891
([src] (cache-file src "out"))
18901892
([src output-dir]
18911893
(if-let [core-cache

src/clj/cljs/closure.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,16 @@ should contain the source for the given namespace name."
15521552
goog-ns
15531553
(str goog-ns))))))
15541554

1555+
(defn aot-cache-core []
1556+
(let [src (io/file "src" "cljs" "cljs" "core.cljs")
1557+
dest (io/file "src" "aot_cljs" "cljs" "core.js")]
1558+
(util/mkdirs dest)
1559+
(env/with-compiler-env (env/default-compiler-env)
1560+
(comp/compile-file src dest
1561+
{:source-map true
1562+
:cache-analysis true
1563+
:output-dir "src/aot_cljs"}))))
1564+
15551565
(comment
15561566

15571567
(println (build '[(ns hello.core)

src/clj/cljs/compiler.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,9 @@
10721072
(fn [{:keys [recompile visited]}]
10731073
{:recompile (into recompile (ana/ns-dependents ns))
10741074
:visited (conj visited ns)})))
1075+
(when (true? (:cache-analysis opts))
1076+
(ana/write-analysis-cache ns
1077+
(ana/cache-file src (util/output-directory opts))))
10751078
ret))
10761079
(do
10771080
(when-not (contains? (::ana/namespaces @env/*compiler*) ns)

0 commit comments

Comments
 (0)