Skip to content

Commit

Permalink
get new :bundle target working
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman committed May 13, 2020
1 parent 4452b0c commit 5425d72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/figwheel/main.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ classpath. Classpath-relative paths have prefix of @ or @/")
;; Config
;; ----------------------------------------------------------------------------

(defn browser-target? [target]
(or (nil? target)
(= :bundle target)))

(defn default-output-dir* [target & [scope]]
(->> (cond-> [(or target default-target-dir) "public" "cljs-out"]
Expand Down Expand Up @@ -1157,7 +1160,7 @@ classpath. Classpath-relative paths have prefix of @ or @/")

(defn config-cljs-devtools [{:keys [::config options] :as cfg}]
(if (and
(nil? (:target options))
(browser-target? (:target options))
(= :none (:optimizations options :none))
(:cljs-devtools config true)
(try (bapi/ns->location 'devtools.preload) (catch Throwable t false)))
Expand Down Expand Up @@ -1267,7 +1270,7 @@ classpath. Classpath-relative paths have prefix of @ or @/")
(defn- config-warn-resource-directory-not-on-classpath [{:keys [::config options] :as cfg}]
;; this could check for other directories than resources
;; but this is mainly to help newcomers
(when (and (nil? (:target options))
(when (and (browser-target? (:target options))
(or (and (::build-once config)
(#{:serve} (:mode config)))
(#{:repl :serve} (:mode config)))
Expand Down Expand Up @@ -1710,11 +1713,11 @@ In the cljs.user ns, controls can be called without ns ie. (conns) instead of (f
(background-build cfg build)))

(defn validate-fix-target-classpath! [{:keys [::config ::build options]}]
(when (and (nil? (:target options))
;; if build-once and not :serve -> don't validate fix classpath
(when (and (browser-target? (:target options))
;; if build-once and not :serve -> don't validate fix classpath
(not (and (::build-once config)
(not (= (:mode config) :serve)))))
;; browsers need the target classpath to load files
;; browsers need the target classpath to load files
(when-not (contains? (:ring-stack-options config) :static)
(when-let [output-to (:output-dir options (:output-to options))]
(when-not (.isAbsolute (io/file output-to))
Expand Down
20 changes: 14 additions & 6 deletions src/figwheel/main/schema/cljs_options.clj
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,23 @@ human-readable manner. Defaults to true.
:pretty-print false")

(s/def ::target #{:nodejs :webworker})
(s/def ::target #{:nodejs :webworker :bundle})
(def-spec-meta ::target
:doc
"If targeting nodejs add this line. Takes no other options at the
moment. The default (no :target specified) implies browsers are being
targeted. Have a look here for more information on how to run your
code in nodejs.
"Valid options are :nodejs, :webworker and :bundle.
:target :nodejs")
The default (no :target specified) implies browsers are being
targeted.
:webworker produces a bootstrap script suitable for loading with Web
Workers.
The :bundle target is to support dependencies in node_modules. The
output generated by ClojureScript will need to be passed on to some
other JavaScript tool (i.e. Webpack, Metro) that can handle the
Node.js style require imports generated for these dependencies.
:target :bundle")

(s/def ::infer-externs boolean?)
(def-spec-meta ::infer-externs
Expand Down

0 comments on commit 5425d72

Please sign in to comment.