|
2346 | 2346 | (assert (not (and output-wrapper (= :whitespace optimizations)))
|
2347 | 2347 | ":output-wrapper cannot be combined with :optimizations :whitespace"))
|
2348 | 2348 |
|
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))) |
2351 | 2351 | (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)))) |
2353 | 2353 | (format ":nodejs target with :none optimizations requires a :main entry")))
|
2354 | 2354 |
|
2355 | 2355 | (defn check-main [{:keys [main] :as opts}]
|
|
3020 | 3020 | (check-main opts)
|
3021 | 3021 | opts)
|
3022 | 3022 |
|
| 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 | + |
3023 | 3038 | (defn build
|
3024 | 3039 | "Given compiler options, produce runnable JavaScript. An optional source
|
3025 | 3040 | parameter may be provided."
|
|
3178 | 3193 | (npm-deps-js (:node-module-index @env/*compiler*))))
|
3179 | 3194 | (apply output-unoptimized opts js-sources)))]
|
3180 | 3195 | (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)) |
3207 | 3197 | ret))))))
|
3208 | 3198 |
|
3209 | 3199 | (comment
|
|
0 commit comments