Skip to content

Commit 0e7671d

Browse files
committed
CLJS-1093: Better compiler defaults
:optimizations :none is the default if nothing supplied. if :optimizations :none, :cache-analysis is true and :source-map is true by default unless different setting supplied :verbose is the default for cljs.closure/watch unless different setting supplied
1 parent 8ed0640 commit 0e7671d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/clj/cljs/closure.clj

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,11 @@ should contain the source for the given namespace name."
13101310
(and (satisfies? deps/IJavaScript js)
13111311
(deps/-foreign? js)))
13121312

1313-
(defn add-implicit-options [opts]
1313+
(defn add-implicit-options
1314+
[{:keys [optimizations output-dir]
1315+
:or {optimizations :none
1316+
output-dir "out"}
1317+
:as opts}]
13141318
(let [opts (cond-> opts
13151319
(:closure-defines opts)
13161320
(assoc :closure-defines
@@ -1322,15 +1326,21 @@ should contain the source for the given namespace name."
13221326
(cond->
13231327
(-> opts
13241328
(assoc
1329+
:optimizations optimizations
1330+
:output-dir output-dir
13251331
:ups-libs libs
13261332
:ups-foreign-libs foreign-libs
13271333
:ups-externs externs)
13281334
(update-in [:preamble] #(into (or % []) ["cljs/imul.js"])))
1335+
13291336
(:target opts)
13301337
(assoc-in [:closure-defines (str (comp/munge 'cljs.core/*target*))]
13311338
(name (:target opts)))
1332-
(nil? (:optimizations opts))
1333-
(assoc :optimizations :none))))
1339+
1340+
(= optimizations :none)
1341+
(assoc
1342+
:cache-analysis (:cache-analysis opts true)
1343+
:source-map (:source-map opts true)))))
13341344

13351345
(defn build
13361346
"Given a source which can be compiled, produce runnable JavaScript."
@@ -1458,7 +1468,10 @@ should contain the source for the given namespace name."
14581468
env/*compiler*
14591469
(env/default-compiler-env opts))))
14601470
([source opts compiler-env]
1461-
(let [path (Paths/get (.toURI (io/file source)))
1471+
(let [opts (cond-> opts
1472+
(= (:verbose opts :not-found) :not-found)
1473+
(assoc :verbose true))
1474+
path (Paths/get (.toURI (io/file source)))
14621475
fs (.getFileSystem path)
14631476
service (.newWatchService fs)]
14641477
(letfn [(buildf []

0 commit comments

Comments
 (0)