Skip to content

Commit eaebc1c

Browse files
ducky427dnolen
authored andcommitted
CLJS-1682 - :foreign-libs with module conversion does not works properly if it is used form deps.cljs
Look at modules found in `:ups-foreign-libs` for google closure conversion.
1 parent 0ed9398 commit eaebc1c

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,8 @@
15381538
(.getAstRoot input closure-compiler)))
15391539

15401540
(defn get-source-files [opts]
1541-
(->> (:foreign-libs opts)
1541+
(->> (concat (:foreign-libs opts)
1542+
(:ups-foreign-libs opts))
15421543
(filter #(let [module-type (:module-type %)]
15431544
(or (= module-type :amd)
15441545
(= module-type :commonjs)
@@ -1735,7 +1736,7 @@
17351736
)
17361737

17371738

1738-
(defn get-upstream-deps*
1739+
(defn get-upstream-deps*
17391740
"returns a merged map containing all upstream dependencies defined
17401741
by libraries on the classpath."
17411742
([]
@@ -1903,13 +1904,9 @@
19031904
(not (false? (:static-fns opts))) (assoc :static-fns true)
19041905
(not (false? (:optimize-constants opts))) (assoc :optimize-constants true)))))
19051906

1906-
(defn process-js-modules
1907-
"Given the current compiler options, converts JavaScript modules to Google
1908-
Closure modules and writes them to disk. Adds mapping from original module
1909-
namespace to new module namespace to compiler env. Returns modified compiler
1910-
options where new modules are passed with :libs option."
1911-
[opts]
1912-
(let [js-modules (filter :module-type (:foreign-libs opts))]
1907+
(defn- process-js-modules*
1908+
[opts k]
1909+
(let [js-modules (filter :module-type (k opts))]
19131910
(reduce (fn [new-opts {:keys [file module-type] :as lib}]
19141911
(if (or (and (= module-type :commonjs) can-convert-commonjs?)
19151912
(and (= module-type :amd) can-convert-amd?)
@@ -1921,11 +1918,21 @@
19211918
#(update-in % [:js-module-index] assoc provide module-name)))
19221919
(-> new-opts
19231920
(update-in [:libs] (comp vec conj) (:out-file ijs))
1924-
(update-in [:foreign-libs]
1921+
(update-in [k]
19251922
(comp vec (fn [libs] (remove #(= (:file %) file) libs))))))
19261923
new-opts))
19271924
opts js-modules)))
19281925

1926+
(defn process-js-modules
1927+
"Given the current compiler options, converts JavaScript modules to Google
1928+
Closure modules and writes them to disk. Adds mapping from original module
1929+
namespace to new module namespace to compiler env. Returns modified compiler
1930+
options where new modules are passed with :libs option."
1931+
[opts]
1932+
(-> opts
1933+
(process-js-modules* :foreign-libs)
1934+
(process-js-modules* :ups-foreign-libs)))
1935+
19291936
(defn build
19301937
"Given a source which can be compiled, produce runnable JavaScript."
19311938
([source opts]

0 commit comments

Comments
 (0)