Skip to content

Commit d94e6c6

Browse files
author
dnolen
committed
CLJS-1130: :foreign-libs regression under Closure optimized builds
:foreign-libs support regressed, we never want to emit a goog.require for a foreign lib in any other optimization setting other than :none make the comment string clear on this point to avoid future simple errors like this one.
1 parent efec6f4 commit d94e6c6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/clj/cljs/compiler.clj

+12-8
Original file line numberDiff line numberDiff line change
@@ -848,14 +848,18 @@
848848
(emitln "if(!COMPILED) " loaded-libs " = cljs.core.set();"))
849849
(doseq [lib (remove (set (vals seen)) (distinct (vals libs)))]
850850
(cond
851-
(and (= :nodejs (get-in @env/*compiler* [:options :target]))
852-
(ana/foreign-dep? lib))
853-
;; under node.js we load foreign libs globally
854-
(let [{:keys [js-dependency-index options]} @env/*compiler*
855-
ijs-url (get-in js-dependency-index [(name lib) :url])]
856-
(emitln "cljs.core.load_file(\""
857-
(str (io/file (util/output-directory options) (util/get-name ijs-url)))
858-
"\");"))
851+
(ana/foreign-dep? lib)
852+
(let [{:keys [target optimizations]} (get @env/*compiler* :options)]
853+
;; we only load foreign libraries under optimizations :none
854+
(when (= :none optimizations)
855+
(if (= :nodejs target)
856+
;; under node.js we load foreign libs globally
857+
(let [{:keys [js-dependency-index options]} @env/*compiler*
858+
ijs-url (get-in js-dependency-index [(name lib) :url])]
859+
(emitln "cljs.core.load_file(\""
860+
(str (io/file (util/output-directory options) (util/get-name ijs-url)))
861+
"\");"))
862+
(emitln "goog.require('" (munge lib) "');"))))
859863

860864
(-> libs meta :reload)
861865
(emitln "goog.require('" (munge lib) "', 'reload');")

0 commit comments

Comments
 (0)