Skip to content

Commit

Permalink
CLJS-2968: Support immutable GCC DependencyOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed Nov 30, 2018
1 parent 0be62b2 commit 69a09a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/clojure/cljs/closure.clj
Expand Up @@ -16,6 +16,7 @@
[cljs.env :as env]
[cljs.js-deps :as deps]
[clojure.java.io :as io]
[clojure.reflect]
[clojure.set :as set]
[clojure.string :as string]
[clojure.data.json :as json]
Expand Down Expand Up @@ -1961,6 +1962,13 @@
(= (package-json-entries {:target :nodejs :package-json-resolution :webpack}) ["browser" "module" "main"])
(= (package-json-entries {:target :nodejs :package-json-resolution ["foo" "bar"]}) ["foo" "bar"]))

(defn- sorting-dependency-options []
(try
(util/compile-if (contains? (:flags (clojure.reflect/reflect DependencyOptions)) :abstract)
(DependencyOptions/sortOnly)
(doto (DependencyOptions.)
(.setDependencySorting true)))))

(defn convert-js-modules
"Takes a list JavaScript modules as an IJavaScript and rewrites them into a Google
Closure-compatible form. Returns list IJavaScript with the converted module
Expand All @@ -1972,8 +1980,7 @@
(.setProcessCommonJSModules true)
(.setLanguageIn (lang-key->lang-mode :ecmascript6))
(.setLanguageOut (lang-key->lang-mode (:language-out opts :ecmascript3)))
(.setDependencyOptions (doto (DependencyOptions.)
(.setDependencySorting true)))
(.setDependencyOptions (sorting-dependency-options))
(.setPackageJsonEntryNames ^List (package-json-entries opts)))
closure-compiler (doto (make-closure-compiler)
(.init externs source-files options))
Expand Down

0 comments on commit 69a09a3

Please sign in to comment.