Skip to content

Commit 29363bb

Browse files
authored
CLJS-3321: Upgrade to Closure Compiler v20210808 (#101)
CLJS-3321: Upgrade to Closure Compiler v20210808
1 parent 4d4abbf commit 29363bb

File tree

7 files changed

+31
-20
lines changed

7 files changed

+31
-20
lines changed

deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{:paths ["src/main/clojure" "src/main/cljs" "resources"]
22
:deps
3-
{com.google.javascript/closure-compiler-unshaded {:mvn/version "v20210505"}
3+
{com.google.javascript/closure-compiler-unshaded {:mvn/version "v20210808"}
44
com.cognitect/transit-clj {:mvn/version "0.8.309"}
55
org.clojure/clojure {:mvn/version "1.10.0"}
66
org.clojure/core.specs.alpha {:mvn/version "0.1.24"}

pom.template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.google.javascript</groupId>
3232
<artifactId>closure-compiler-unshaded</artifactId>
33-
<version>v20210505</version>
33+
<version>v20210808</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>org.clojure</groupId>

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[org.clojure/test.check "0.10.0-alpha3" :scope "test"]
1717
[com.cognitect/transit-clj "0.8.309"]
1818
[org.clojure/google-closure-library "0.0-20201211-3e6c510d"]
19-
[com.google.javascript/closure-compiler-unshaded "v20210505"]]
19+
[com.google.javascript/closure-compiler-unshaded "v20210808"]]
2020
:profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
2121
:uberjar {:aot :all :main cljs.main}
2222
:closure-snapshot {:dependencies [[com.google.javascript/closure-compiler-unshaded "1.0-SNAPSHOT"]]}}

script/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
CLOJURE_RELEASE="1.9.0"
66
SPEC_ALPHA_RELEASE="0.1.143"
77
CORE_SPECS_ALPHA_RELEASE="0.1.24"
8-
CLOSURE_RELEASE="20210505"
8+
CLOSURE_RELEASE="20210808"
99
DJSON_RELEASE="0.2.6"
1010
TRANSIT_RELEASE="0.8.309"
1111
GCLOSURE_LIB_RELEASE="0.0-20201211-3e6c510d"

src/main/clojure/cljs/closure.clj

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
[cljs.module-graph :as module-graph])
2727
(:import [java.lang ProcessBuilder]
2828
[java.io
29-
File BufferedInputStream BufferedReader
29+
File BufferedReader BufferedInputStream
3030
Writer InputStreamReader IOException StringWriter ByteArrayInputStream]
3131
[java.net URI URL]
3232
[java.util.logging Level]
@@ -39,9 +39,8 @@
3939
SourceMap$DetailLevel ClosureCodingConvention SourceFile
4040
Result JSError CheckLevel DiagnosticGroup DiagnosticGroups
4141
CommandLineRunner
42-
JSModule SourceMap VariableMap PrintStreamErrorManager DiagnosticType
42+
JSChunk SourceMap VariableMap PrintStreamErrorManager DiagnosticType
4343
VariableRenamingPolicy PropertyRenamingPolicy]
44-
[com.google.javascript.jscomp.bundle Transpiler]
4544
[com.google.javascript.jscomp.deps ClosureBundler ModuleLoader$ResolutionMode ModuleNames
4645
SimpleDependencyInfo]
4746
[com.google.javascript.rhino Node]
@@ -117,16 +116,25 @@
117116
(defmulti js-source-file (fn [_ source] (class source)))
118117

119118
(defmethod js-source-file String [^String name ^String source]
120-
(SourceFile/fromCode name source))
119+
(-> (SourceFile/builder)
120+
(.withPath name)
121+
(.withContent source)
122+
(.build)))
121123

122124
(defmethod js-source-file File [_ ^File source]
123-
(SourceFile/fromPath (.toPath source) StandardCharsets/UTF_8))
125+
(-> (SourceFile/builder)
126+
(.withPath (.toPath source))
127+
(.withCharset StandardCharsets/UTF_8)
128+
(.build)))
124129

125130
(defmethod js-source-file URL [_ ^URL source]
126131
(js-source-file _ (io/file (.getPath source))))
127132

128133
(defmethod js-source-file BufferedInputStream [^String name ^BufferedInputStream source]
129-
(SourceFile/fromInputStream name source))
134+
(-> (SourceFile/builder)
135+
(.withPath name)
136+
(.withContent source)
137+
(.build)))
130138

131139
(def check-level
132140
{:error CheckLevel/ERROR
@@ -180,7 +188,6 @@
180188
:too-many-type-params DiagnosticGroups/TOO_MANY_TYPE_PARAMS
181189
:tweaks DiagnosticGroups/TWEAKS
182190
:type-invalidation DiagnosticGroups/TYPE_INVALIDATION
183-
:undefined-names DiagnosticGroups/UNDEFINED_NAMES
184191
:undefined-variables DiagnosticGroups/UNDEFINED_VARIABLES
185192
:underscore DiagnosticGroups/UNDERSCORE
186193
:unknown-defines DiagnosticGroups/UNKNOWN_DEFINES
@@ -1262,7 +1269,7 @@
12621269
"Given a list of IJavaScript sources in dependency order and compiler options
12631270
return a dependency sorted list of module name / description tuples. The
12641271
module descriptions will be augmented with a :closure-module entry holding
1265-
the Closure JSModule. Each module description will also be augmented with
1272+
the Closure JSChunk. Each module description will also be augmented with
12661273
a :foreign-deps vector containing foreign IJavaScript sources in dependency
12671274
order."
12681275
[sources opts]
@@ -1287,7 +1294,7 @@
12871294
(str "Module " name " does not define any :entries"))
12881295
(when (:verbose opts)
12891296
(util/debug-prn "Building module" name))
1290-
(let [js-module (JSModule. (clojure.core/name name))
1297+
(let [js-module (JSChunk. (clojure.core/name name))
12911298
module-sources
12921299
(reduce
12931300
(fn [ret entry-sym]
@@ -1315,7 +1322,7 @@
13151322
(do
13161323
(when (:verbose opts)
13171324
(util/debug-prn " module" name "depends on" dep))
1318-
(.addDependency js-module ^JSModule parent-module))
1325+
(.addDependency js-module ^JSChunk parent-module))
13191326
(throw (util/compilation-error (IllegalArgumentException.
13201327
(str "Parent module " dep " does not exist"))))))
13211328
(conj ret
@@ -1424,7 +1431,7 @@
14241431
(io/file prop-out)))))
14251432

14261433
(defn optimize-modules
1427-
"Use the Closure Compiler to optimize one or more Closure JSModules. Returns
1434+
"Use the Closure Compiler to optimize one or more Closure JSChunks. Returns
14281435
a dependency sorted list of module name and description tuples."
14291436
[opts & sources]
14301437
;; the following pre-condition can't be enabled
@@ -1445,7 +1452,7 @@
14451452
sources)
14461453
modules (build-modules sources opts)
14471454
^List inputs (map (comp :closure-module second) modules)
1448-
_ (doseq [^JSModule input inputs]
1455+
_ (doseq [^JSChunk input inputs]
14491456
(.sortInputsByDeps input closure-compiler))
14501457
_ (when (or ana/*verbose* (:verbose opts))
14511458
(util/debug-prn "Applying optimizations" (:optimizations opts) "to" (count sources) "sources"))
@@ -1465,7 +1472,7 @@
14651472
:source
14661473
(do
14671474
(when source-map (.reset source-map))
1468-
(.toSource closure-compiler ^JSModule closure-module)))
1475+
(.toSource closure-compiler ^JSChunk closure-module)))
14691476
(when source-map
14701477
(let [sw (StringWriter.)
14711478
source-map-name (str output-to ".map.closure")]

src/main/clojure/cljs/externs.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[com.google.javascript.jscomp.parsing Config$JsDocParsing]
1717
[com.google.javascript.rhino
1818
Node Token JSTypeExpression JSDocInfo$Visibility]
19+
[java.nio.charset StandardCharsets]
1920
[java.util.logging Level]))
2021

2122
(def ^:dynamic *ignore-var* false)
@@ -237,7 +238,10 @@
237238
{:name ns
238239
:defs (parsed->defs
239240
(parse-externs
240-
(SourceFile/fromInputStream f (io/input-stream rsrc))))}))))
241+
(-> (SourceFile/builder)
242+
(.withPath (.toPath (io/file (.getPath rsrc))))
243+
(.withContent (io/input-stream rsrc))
244+
(.build))))}))))
241245

242246
(comment
243247
(require '[clojure.java.io :as io]

src/test/clojure/cljs/closure_tests.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[clojure.java.io :as io]
2020
[clojure.string :as string])
2121
(:import [java.io File]
22-
[com.google.javascript.jscomp JSModule]))
22+
[com.google.javascript.jscomp JSChunk]))
2323

2424
(deftest test-make-preamble
2525
(testing "no options"
@@ -60,7 +60,7 @@
6060
(test/delete-out-files out)
6161
(build/build (build/inputs (:inputs project)) (:opts project))
6262
(let [compiler (closure/make-closure-compiler)
63-
module (JSModule. "module-c")]
63+
module (JSChunk. "module-c")]
6464
(.initOptions compiler (closure/make-options (:opts project)))
6565
(doseq [file ["cljs/core/constants.js"
6666
"module_test/modules/a.js"

0 commit comments

Comments
 (0)