Skip to content

Commit 3fd1b8b

Browse files
committed
more discipline around how we detect the standard library
change `cljs.analyzer/cache-file` so that it is read and write aware.
1 parent edb5361 commit 3fd1b8b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,17 +1899,18 @@ argument, which the reader will use in any emitted errors."
18991899
ret))))
19001900

19011901
(defn cache-file
1902-
"Given a ClojureScript source file returns the _output_ path to the analysis
1903-
cache file."
1902+
"Given a ClojureScript source file returns the read/write path to the analysis
1903+
cache file. Defaults to the read path which is usually also the write path."
19041904
([src] (cache-file src "out"))
1905-
([src output-dir]
1905+
([src output-dir] (cache-file src (parse-ns src) output-dir))
1906+
([src ns-info output-dir] (cache-file src (parse-ns src) output-dir :read))
1907+
([src ns-info output-dir mode]
19061908
(if-let [core-cache
1907-
(and (util/url? src)
1908-
(.endsWith (.getPath ^URL src) (str "cljs" File/separator "core.cljs"))
1909+
(and (= mode :read)
1910+
(= (:ns ns-info) 'cljs.core)
19091911
(io/resource "cljs/core.cljs.cache.aot.edn"))]
19101912
core-cache
1911-
(let [ns-info (parse-ns src)]
1912-
(io/file (str (util/to-target-file output-dir ns-info "cljs") ".cache.edn"))))))
1913+
(io/file (str (util/to-target-file output-dir ns-info "cljs") ".cache.edn")))))
19131914

19141915
(defn last-modified [src]
19151916
(cond
@@ -1969,14 +1970,15 @@ argument, which the reader will use in any emitted errors."
19691970
:else (io/resource f))]
19701971
(assert res (str "Can't find " f " in classpath"))
19711972
(env/ensure
1972-
(let [path (if (instance? File res)
1973+
(let [ns-info (parse-ns res)
1974+
path (if (instance? File res)
19731975
(.getPath ^File res)
19741976
(.getPath ^URL res))
1975-
cache (when (or (= f "cljs/core.cljs")
1977+
cache (when (or (= (:ns ns-info) 'cljs.core)
19761978
(and (:cache-analysis opts) output-dir))
1977-
(cache-file res output-dir))]
1979+
(cache-file res ns-info output-dir))]
19781980
(when-not (get-in @env/*compiler* [::analyzed-cljs path])
1979-
(if (or (not= f "cljs/core.cljs")
1981+
(if (or (not= (:ns ns-info) 'cljs.core)
19801982
(not cache)
19811983
(requires-analysis? res output-dir))
19821984
(binding [*cljs-ns* 'cljs.user

src/clj/cljs/compiler.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@
10871087
:visited (conj visited ns)})))
10881088
(when (true? (:cache-analysis opts))
10891089
(ana/write-analysis-cache ns
1090-
(ana/cache-file src (util/output-directory opts))))
1090+
(ana/cache-file src ns-info (util/output-directory opts) :write)))
10911091
ret))
10921092
(do
10931093
(when-not (contains? (::ana/namespaces @env/*compiler*) ns)

0 commit comments

Comments
 (0)