Skip to content

Commit b1de2f8

Browse files
Deraenswannodette
authored andcommitted
CLJS-2699: Use higher-level Closure API for module-processing
Also fixes CompilerInput.getRequires handling for next Closure release
1 parent 0dad6a2 commit b1de2f8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
SourceMap$DetailLevel ClosureCodingConvention SourceFile
3838
Result JSError CheckLevel DiagnosticGroups
3939
CommandLineRunner AnonymousFunctionNamingPolicy
40-
JSModule SourceMap Es6RewriteModules VariableMap
41-
ProcessCommonJSModules Es6RewriteScriptsToModules]
40+
JSModule SourceMap VariableMap]
4241
[com.google.javascript.jscomp.deps ModuleLoader$ResolutionMode ModuleNames]
4342
[com.google.javascript.rhino Node]
4443
[java.nio.file Path Paths Files StandardWatchEventKinds WatchKey
@@ -1736,6 +1735,12 @@
17361735
(str
17371736
"goog.provide(\"" module-name "\");\n"
17381737
(->> (.getRequires input)
1738+
;; v20180204 returns string
1739+
;; next Closure returns DependencyInfo.Require object
1740+
(map (fn [i]
1741+
(if (string? i)
1742+
i
1743+
(.getSymbol i))))
17391744
;; If CJS/ES6 module uses goog.require, goog is added to requires
17401745
;; but this would cause problems with Cljs.
17411746
(remove #{"goog"})
@@ -1796,9 +1801,11 @@
17961801
^Node js-root (.getSecondChild extern-and-js-root)
17971802
inputs-by-name (into {} (map (juxt #(.getName %) identity) (vals (.getInputsById closure-compiler))))]
17981803

1799-
(.process (Es6RewriteScriptsToModules. closure-compiler) extern-root js-root)
1800-
(.process (Es6RewriteModules. closure-compiler) extern-root js-root)
1801-
(.process (ProcessCommonJSModules. closure-compiler) extern-root js-root)
1804+
;; This will rewrite CommonJS modules
1805+
(.whitespaceOnlyPasses closure-compiler)
1806+
;; This will take care of converting ES6 to CJS
1807+
;; Based on language-in setting, this could also handle ES7/8/TypeScript transpilation.
1808+
(.transpileAndDontCheck closure-compiler)
18021809

18031810
(map (partial add-converted-source
18041811
closure-compiler inputs-by-name opts)

0 commit comments

Comments
 (0)