|
26 | 26 | [cljs.module-graph :as module-graph]) |
27 | 27 | (:import [java.lang ProcessBuilder] |
28 | 28 | [java.io |
29 | | - File BufferedInputStream BufferedReader |
| 29 | + File BufferedReader BufferedInputStream |
30 | 30 | Writer InputStreamReader IOException StringWriter ByteArrayInputStream] |
31 | 31 | [java.net URI URL] |
32 | 32 | [java.util.logging Level] |
|
39 | 39 | SourceMap$DetailLevel ClosureCodingConvention SourceFile |
40 | 40 | Result JSError CheckLevel DiagnosticGroup DiagnosticGroups |
41 | 41 | CommandLineRunner |
42 | | - JSModule SourceMap VariableMap PrintStreamErrorManager DiagnosticType |
| 42 | + JSChunk SourceMap VariableMap PrintStreamErrorManager DiagnosticType |
43 | 43 | VariableRenamingPolicy PropertyRenamingPolicy] |
44 | | - [com.google.javascript.jscomp.bundle Transpiler] |
45 | 44 | [com.google.javascript.jscomp.deps ClosureBundler ModuleLoader$ResolutionMode ModuleNames |
46 | 45 | SimpleDependencyInfo] |
47 | 46 | [com.google.javascript.rhino Node] |
|
117 | 116 | (defmulti js-source-file (fn [_ source] (class source))) |
118 | 117 |
|
119 | 118 | (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))) |
121 | 123 |
|
122 | 124 | (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))) |
124 | 129 |
|
125 | 130 | (defmethod js-source-file URL [_ ^URL source] |
126 | 131 | (js-source-file _ (io/file (.getPath source)))) |
127 | 132 |
|
128 | 133 | (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))) |
130 | 138 |
|
131 | 139 | (def check-level |
132 | 140 | {:error CheckLevel/ERROR |
|
180 | 188 | :too-many-type-params DiagnosticGroups/TOO_MANY_TYPE_PARAMS |
181 | 189 | :tweaks DiagnosticGroups/TWEAKS |
182 | 190 | :type-invalidation DiagnosticGroups/TYPE_INVALIDATION |
183 | | - :undefined-names DiagnosticGroups/UNDEFINED_NAMES |
184 | 191 | :undefined-variables DiagnosticGroups/UNDEFINED_VARIABLES |
185 | 192 | :underscore DiagnosticGroups/UNDERSCORE |
186 | 193 | :unknown-defines DiagnosticGroups/UNKNOWN_DEFINES |
|
1262 | 1269 | "Given a list of IJavaScript sources in dependency order and compiler options |
1263 | 1270 | return a dependency sorted list of module name / description tuples. The |
1264 | 1271 | 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 |
1266 | 1273 | a :foreign-deps vector containing foreign IJavaScript sources in dependency |
1267 | 1274 | order." |
1268 | 1275 | [sources opts] |
|
1287 | 1294 | (str "Module " name " does not define any :entries")) |
1288 | 1295 | (when (:verbose opts) |
1289 | 1296 | (util/debug-prn "Building module" name)) |
1290 | | - (let [js-module (JSModule. (clojure.core/name name)) |
| 1297 | + (let [js-module (JSChunk. (clojure.core/name name)) |
1291 | 1298 | module-sources |
1292 | 1299 | (reduce |
1293 | 1300 | (fn [ret entry-sym] |
|
1315 | 1322 | (do |
1316 | 1323 | (when (:verbose opts) |
1317 | 1324 | (util/debug-prn " module" name "depends on" dep)) |
1318 | | - (.addDependency js-module ^JSModule parent-module)) |
| 1325 | + (.addDependency js-module ^JSChunk parent-module)) |
1319 | 1326 | (throw (util/compilation-error (IllegalArgumentException. |
1320 | 1327 | (str "Parent module " dep " does not exist")))))) |
1321 | 1328 | (conj ret |
|
1424 | 1431 | (io/file prop-out))))) |
1425 | 1432 |
|
1426 | 1433 | (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 |
1428 | 1435 | a dependency sorted list of module name and description tuples." |
1429 | 1436 | [opts & sources] |
1430 | 1437 | ;; the following pre-condition can't be enabled |
|
1445 | 1452 | sources) |
1446 | 1453 | modules (build-modules sources opts) |
1447 | 1454 | ^List inputs (map (comp :closure-module second) modules) |
1448 | | - _ (doseq [^JSModule input inputs] |
| 1455 | + _ (doseq [^JSChunk input inputs] |
1449 | 1456 | (.sortInputsByDeps input closure-compiler)) |
1450 | 1457 | _ (when (or ana/*verbose* (:verbose opts)) |
1451 | 1458 | (util/debug-prn "Applying optimizations" (:optimizations opts) "to" (count sources) "sources")) |
|
1465 | 1472 | :source |
1466 | 1473 | (do |
1467 | 1474 | (when source-map (.reset source-map)) |
1468 | | - (.toSource closure-compiler ^JSModule closure-module))) |
| 1475 | + (.toSource closure-compiler ^JSChunk closure-module))) |
1469 | 1476 | (when source-map |
1470 | 1477 | (let [sw (StringWriter.) |
1471 | 1478 | source-map-name (str output-to ".map.closure")] |
|
0 commit comments