From d94e6c6e88541b8cd3d559be4281c76bb8c408d9 Mon Sep 17 00:00:00 2001 From: dnolen Date: Mon, 16 Mar 2015 13:48:13 -0400 Subject: [PATCH] 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. --- src/clj/cljs/compiler.clj | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/clj/cljs/compiler.clj b/src/clj/cljs/compiler.clj index 8044a39963..8c98f4ebdb 100644 --- a/src/clj/cljs/compiler.clj +++ b/src/clj/cljs/compiler.clj @@ -848,14 +848,18 @@ (emitln "if(!COMPILED) " loaded-libs " = cljs.core.set();")) (doseq [lib (remove (set (vals seen)) (distinct (vals libs)))] (cond - (and (= :nodejs (get-in @env/*compiler* [:options :target])) - (ana/foreign-dep? lib)) - ;; under node.js we load foreign libs globally - (let [{:keys [js-dependency-index options]} @env/*compiler* - ijs-url (get-in js-dependency-index [(name lib) :url])] - (emitln "cljs.core.load_file(\"" - (str (io/file (util/output-directory options) (util/get-name ijs-url))) - "\");")) + (ana/foreign-dep? lib) + (let [{:keys [target optimizations]} (get @env/*compiler* :options)] + ;; we only load foreign libraries under optimizations :none + (when (= :none optimizations) + (if (= :nodejs target) + ;; under node.js we load foreign libs globally + (let [{:keys [js-dependency-index options]} @env/*compiler* + ijs-url (get-in js-dependency-index [(name lib) :url])] + (emitln "cljs.core.load_file(\"" + (str (io/file (util/output-directory options) (util/get-name ijs-url))) + "\");")) + (emitln "goog.require('" (munge lib) "');")))) (-> libs meta :reload) (emitln "goog.require('" (munge lib) "', 'reload');")