Skip to content

Commit 16e2ce4

Browse files
committed
CLJS-3238: Watch incompatible with :bundle, throws :nodejs-related exception
Need to stop looking at `:target` and instead consider `:nodejs-rt`. Clean up the bundle command runner. Deduplicate and include :stderr
1 parent 6c3276e commit 16e2ce4

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

src/main/clojure/cljs/closure.clj

+19-29
Original file line numberDiff line numberDiff line change
@@ -2346,10 +2346,10 @@
23462346
(assert (not (and output-wrapper (= :whitespace optimizations)))
23472347
":output-wrapper cannot be combined with :optimizations :whitespace"))
23482348

2349-
(defn check-node-target [{:keys [target optimizations] :as opts}]
2350-
(assert (not (and (= target :nodejs) (= optimizations :whitespace)))
2349+
(defn check-node-target [{:keys [nodejs-rt optimizations] :as opts}]
2350+
(assert (not (and nodejs-rt (= optimizations :whitespace)))
23512351
(format ":nodejs target not compatible with :whitespace optimizations"))
2352-
(assert (not (and (= target :nodejs) (= optimizations :none) (not (contains? opts :main))))
2352+
(assert (not (and nodejs-rt (= optimizations :none) (not (contains? opts :main))))
23532353
(format ":nodejs target with :none optimizations requires a :main entry")))
23542354

23552355
(defn check-main [{:keys [main] :as opts}]
@@ -3020,6 +3020,21 @@
30203020
(check-main opts)
30213021
opts)
30223022

3023+
(defn run-bundle-cmd [opts]
3024+
(let [cmd-type (or (#{:none} (:optimizations opts)) :default)]
3025+
(when-let [cmd (get-in opts [:bundle-cmd cmd-type])]
3026+
(let [{:keys [exit out err]}
3027+
(try
3028+
(apply sh/sh cmd)
3029+
(catch Throwable t
3030+
(throw
3031+
(ex-info (str ":build-cmd " cmd-type " failed")
3032+
{:cmd cmd} t))))]
3033+
(when-not (== 0 exit)
3034+
(throw
3035+
(ex-info (str ":bundle-cmd " cmd-type " failed")
3036+
{:cmd cmd :exit-code exit :stdout out :stderr err})))))))
3037+
30233038
(defn build
30243039
"Given compiler options, produce runnable JavaScript. An optional source
30253040
parameter may be provided."
@@ -3178,32 +3193,7 @@
31783193
(npm-deps-js (:node-module-index @env/*compiler*))))
31793194
(apply output-unoptimized opts js-sources)))]
31803195
(output-bootstrap opts)
3181-
(when (bundle? opts)
3182-
(when-let [cmd (and (= :none optim)
3183-
(get-in opts [:bundle-cmd :none]))]
3184-
(let [{:keys [exit out]}
3185-
(try
3186-
(apply sh/sh cmd)
3187-
(catch Throwable t
3188-
(throw
3189-
(ex-info ":build-cmd :none failed"
3190-
{:cmd cmd} t))))]
3191-
(when-not (== 0 exit)
3192-
(throw
3193-
(ex-info ":bundle-cmd :none failed"
3194-
{:cmd cmd :exit-code exit :std-out out})))))
3195-
(when-let [cmd (and (not= :none optim)
3196-
(get-in opts [:bundle-cmd :default]))]
3197-
(let [{:keys [exit out]}
3198-
(try
3199-
(apply sh/sh cmd)
3200-
(catch Throwable t
3201-
(ex-info ":build-cmd :default failed"
3202-
{:cmd cmd} t)))]
3203-
(when-not (== 0 exit)
3204-
(throw
3205-
(ex-info ":bundle-cmd :default failed"
3206-
{:cmd cmd :exit-code exit :std-out out}))))))
3196+
(when (bundle? opts) (run-bundle-cmd opts))
32073197
ret))))))
32083198

32093199
(comment

0 commit comments

Comments
 (0)