Skip to content

Commit f75da4e

Browse files
Maria Neiseswannodette
Maria Neise
authored andcommitted
CLJS-1288: compiler doesn't emit "goog.require" for foreign library when optimization level is not set
Merge all options in the compiler-env with existing options. Pull emit-constants options into add-implicit-options function.
1 parent cfdb0d4 commit f75da4e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,15 +1399,19 @@
13991399
(map (fn [[k v]]
14001400
[(if (symbol? k) (str (comp/munge k)) k) v])
14011401
(:closure-defines opts)))))
1402-
{:keys [libs foreign-libs externs]} (get-upstream-deps)]
1402+
{:keys [libs foreign-libs externs]} (get-upstream-deps)
1403+
emit-constants (or (and (= optimizations :advanced)
1404+
(not (false? (:optimize-constants opts))))
1405+
(:optimize-constants opts))]
14031406
(cond->
14041407
(-> opts
14051408
(assoc
14061409
:optimizations optimizations
14071410
:output-dir output-dir
14081411
:ups-libs libs
14091412
:ups-foreign-libs foreign-libs
1410-
:ups-externs externs)
1413+
:ups-externs externs
1414+
:emit-constants emit-constants)
14111415
(update-in [:preamble] #(into (or % []) ["cljs/imul.js"])))
14121416

14131417
(:target opts)
@@ -1434,10 +1438,7 @@
14341438
([source opts compiler-env]
14351439
(env/with-compiler-env compiler-env
14361440
(let [compiler-stats (:compiler-stats opts)
1437-
all-opts (add-implicit-options opts)
1438-
emit-constants (or (and (= (:optimizations opts) :advanced)
1439-
(not (false? (:optimize-constants opts))))
1440-
(:optimize-constants opts))]
1441+
all-opts (add-implicit-options opts)]
14411442
(check-output-to opts)
14421443
(check-output-dir opts)
14431444
(check-source-map opts)
@@ -1446,7 +1447,7 @@
14461447
(check-node-target opts)
14471448
(swap! compiler-env
14481449
#(-> %
1449-
(assoc-in [:options :emit-constants] emit-constants)
1450+
(update-in [:options] merge all-opts)
14501451
(assoc :target (:target opts))
14511452
(assoc :js-dependency-index (deps/js-dependency-index all-opts))))
14521453
(binding [comp/*dependents* (when-not (false? (:recompile-dependents opts))
@@ -1484,7 +1485,7 @@
14841485
[(-compile (io/resource "cljs/nodejs.cljs") all-opts)])))
14851486
(when (= :nodejs (:target all-opts))
14861487
[(-compile (io/resource "cljs/nodejscli.cljs") all-opts)]))))
1487-
_ (when emit-constants
1488+
_ (when (:emit-constants all-opts)
14881489
(comp/emit-constants-table-to-file
14891490
(::ana/constant-table @env/*compiler*)
14901491
(str (util/output-directory all-opts) "/constants_table.js")))

0 commit comments

Comments
 (0)