Skip to content

Commit 4a97e04

Browse files
committed
CLJS-1117: Dependencies in JARs don't use cached analysis
cljs.analyzer/analyze: * :pre condition so opts map isn't accidentally passed as 3rd name argument. cljs.analyzer/analyze-file: * fix bad caching boolean test * invoke cljs.analyzer/analyze correctly * Use implied output-dir.
1 parent 3c2dab3 commit 4a97e04

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,8 @@
18441844
([env form] (analyze env form nil))
18451845
([env form name] (analyze env form name nil))
18461846
([env form name opts]
1847+
{:pre [(or (nil? name) (symbol? name))
1848+
(or (nil? opts) (map? opts))]}
18471849
(env/ensure
18481850
(wrapping-errors env
18491851
(reduce (fn [ast pass] (pass env ast))
@@ -2033,9 +2035,10 @@ argument, which the reader will use in any emitted errors."
20332035
\":output-dir/some/ns/foo.cljs.cache.edn\". This function does not return a
20342036
meaningful value."
20352037
([f] (analyze-file f nil))
2036-
([f {:keys [output-dir] :as opts}]
2038+
([f opts]
20372039
(binding [*file-defs* (atom #{})]
2038-
(let [res (cond
2040+
(let [output-dir (util/output-directory opts)
2041+
res (cond
20392042
(instance? File f) f
20402043
(instance? URL f) f
20412044
(re-find #"^file://" f) (URL. f)
@@ -2047,11 +2050,10 @@ argument, which the reader will use in any emitted errors."
20472050
(.getPath ^File res)
20482051
(.getPath ^URL res))
20492052
cache (when (or (= (:ns ns-info) 'cljs.core)
2050-
(and (:cache-analysis opts) output-dir))
2053+
(:cache-analysis opts))
20512054
(cache-file res ns-info output-dir))]
20522055
(when-not (get-in @env/*compiler* [::namespaces (:ns ns-info)])
2053-
(if (or (not= (:ns ns-info) 'cljs.core)
2054-
(not cache)
2056+
(if (or (not cache)
20552057
(requires-analysis? res output-dir))
20562058
(binding [*cljs-ns* 'cljs.user
20572059
*cljs-file* path
@@ -2063,7 +2065,7 @@ argument, which the reader will use in any emitted errors."
20632065
(if forms
20642066
(let [form (first forms)
20652067
env (assoc env :ns (get-namespace *cljs-ns*))
2066-
ast (analyze env form opts)]
2068+
ast (analyze env form nil opts)]
20672069
(if (= (:op ast) :ns)
20682070
(recur (:name ast) (next forms))
20692071
(recur ns (next forms))))

0 commit comments

Comments
 (0)