Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Add callback to lumo.build.api/build
Browse files Browse the repository at this point in the history
This change was made necessary by the fact that the bootstrap compiler is
asynchronous by default. Therefore, it does not make sense to call
lumo.build.api/build without a callback.

The patch does not break old code, so it still contains the arity without cb,
but includes a warning if that arity is invoked.
  • Loading branch information
arichiardi committed Sep 12, 2017
1 parent 3f1292c commit 92ba898
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/cljs/bundled/lumo/build/api.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@
(defn build
"Given a source which can be compiled, produce runnable JavaScript."
([source opts]
(build source opts
(env/default-compiler-env
(closure/add-externs-sources opts))))
(build source opts (fn [& args] args)))
([source opts compiler-env]
(build source opts compiler-env cb))
([source opts compiler-env cb]
(doseq [[unknown-opt suggested-opt] (util/unknown-opts (set (keys opts)) closure/known-opts)]
(when suggested-opt
(println (str "WARNING: Unknown compiler option '" unknown-opt "'. Did you mean '" suggested-opt "'?"))))
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
(closure/build source opts compiler-env))))
(closure/build source opts
(if compiler-env
compiler-env
(env/default-compiler-env
(closure/add-externs-sources opts))) cb))))

(defn inputs
"Given a list of directories and files, return a compilable object that may
Expand Down
7 changes: 3 additions & 4 deletions src/cljs/bundled/lumo/closure.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,17 +2153,16 @@

(defn build
"Given a source which can be compiled, produce runnable JavaScript."
([source opts]
([source opts cb]
(build source opts
(if-not (nil? env/*compiler*)
env/*compiler*
(env/default-compiler-env
;; need to dissoc :foreign-libs since we won't know what overriding
;; foreign libspecs are referring to until after add-implicit-options
;; - David
(add-externs-sources (dissoc opts :foreign-libs))))))
([source opts compiler-env]
(build source opts compiler-env (fn [& args] args)))
(add-externs-sources (dissoc opts :foreign-libs))))
cb))
([source opts compiler-env cb]
(env/with-compiler-env compiler-env
;; we want to warn about NPM dep conflicts before installing the modules
Expand Down

0 comments on commit 92ba898

Please sign in to comment.