Skip to content

Commit 0ea117b

Browse files
committed
CLJS-3255: cljs.build.api/build doesn't work with single arity / 2-arity with nil
While actually supported make a small change so that `source` argument to cljs.build/build can actually be nil in all cases. If `:main` is supplied, `:optimizations` `:none`, and source nil, go ahead supply source as that will always be what the user intended. Note cljs.cli already fixed this problem some time ago but at a higher level.
1 parent b7895ae commit 0ea117b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3109,11 +3109,15 @@
31093109
(util/debug-prn "Options passed to ClojureScript compiler:" (pr-str opts)))
31103110
(let [one-file? (and (:main opts)
31113111
(#{:advanced :simple :whitespace} (:optimizations opts)))
3112-
source (if one-file?
3112+
source (if (or one-file?
3113+
;; if source is nil, :main is supplied, :optimizations :none,
3114+
;; fix up source for the user, see CLJS-3255
3115+
(and (nil? source) (:main opts) (= :none (:optimizations opts))))
31133116
(let [main (:main opts)
31143117
uri (:uri (cljs-source-for-namespace main))]
31153118
(assert uri (str "No file for namespace " main " exists"))
31163119
uri)
3120+
;; old compile directory behavior, or code-splitting
31173121
source)
31183122
compile-opts (if one-file?
31193123
(assoc opts :output-file (:output-to opts))

src/test/clojure/cljs/build_api_tests.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,15 @@
719719
(test/delete-out-files out)
720720
(build/build (build/inputs (io/file inputs "trivial/core.cljs")) opts cenv)
721721
(is (< (.length out-file) 10000))))
722+
723+
(deftest cljs-3255-nil-inputs-build
724+
(let [out (.getPath (io/file (test/tmp-dir) "3255-test-out"))
725+
out-file (io/file out "main.js")
726+
opts {:main 'trivial.core
727+
:output-to (.getPath out-file)
728+
:output-dir out
729+
:language-in :es6
730+
:optimizations :none}
731+
cenv (env/default-compiler-env)]
732+
(test/delete-out-files out)
733+
(build/build nil opts cenv)))

0 commit comments

Comments
 (0)