Skip to content

Commit 62e4bc9

Browse files
anmonteirodnolen
authored andcommitted
CLJS-1821: add-preloads should only touch sources if :preloads option specified
1 parent ab7db12 commit 62e4bc9

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -901,27 +901,29 @@
901901
files needing copying or compilation will be compiled and/or copied to the
902902
appropiate location."
903903
[inputs opts]
904-
(let [pred (fn [x]
905-
(if (:emit-constants opts)
906-
(not= ["constants-table"] (:provides x))
907-
(not= ["cljs.core"] (:provides x))))
908-
pre (take-while pred inputs)
909-
post (drop-while pred inputs)
910-
preloads (remove nil?
911-
(map
912-
(fn [preload]
913-
(try
914-
(comp/find-source preload)
915-
(catch Throwable t
916-
(util/debug-prn "WARNING: preload namespace" preload "does not exist"))))
917-
(:preloads opts)))]
918-
(distinct-by :provides
919-
(concat pre [(first post)]
920-
(-> (add-dependency-sources preloads opts)
921-
deps/dependency-order
922-
(compile-sources opts)
923-
(add-js-sources opts))
924-
(next post)))))
904+
(if-not (:preloads opts)
905+
inputs
906+
(let [pred (fn [x]
907+
(if (:emit-constants opts)
908+
(not= ["constants-table"] (:provides x))
909+
(not= ["cljs.core"] (:provides x))))
910+
pre (take-while pred inputs)
911+
post (drop-while pred inputs)
912+
preloads (remove nil?
913+
(map
914+
(fn [preload]
915+
(try
916+
(comp/find-source preload)
917+
(catch Throwable t
918+
(util/debug-prn "WARNING: preload namespace" preload "does not exist"))))
919+
(:preloads opts)))]
920+
(distinct-by :provides
921+
(concat pre [(first post)]
922+
(-> (add-dependency-sources preloads opts)
923+
deps/dependency-order
924+
(compile-sources opts)
925+
(add-js-sources opts))
926+
(next post))))))
925927

926928
(comment
927929
(comp/find-sources-root "samples/hello/src")
@@ -1854,6 +1856,11 @@
18541856
(assert (not (and (= target :nodejs) (= optimizations :whitespace)))
18551857
(format ":nodejs target not compatible with :whitespace optimizations")))
18561858

1859+
(defn check-preloads [{:keys [preloads optimizations] :as opts}]
1860+
(when (and (some? preloads) (not= optimizations :none))
1861+
(binding [*out* *err*]
1862+
(println "WARNING: :preloads should only be specified with :none optimizations"))))
1863+
18571864
(defn foreign-source? [js]
18581865
(and (satisfies? deps/IJavaScript js)
18591866
(deps/-foreign? js)))
@@ -1949,6 +1956,7 @@
19491956
(check-source-map-path opts)
19501957
(check-output-wrapper opts)
19511958
(check-node-target opts)
1959+
(check-preloads opts)
19521960
(swap! compiler-env
19531961
#(-> %
19541962
(update-in [:options] merge all-opts)

0 commit comments

Comments
 (0)