diff --git a/src/figwheel/main.cljc b/src/figwheel/main.cljc index 32b7859..c98e587 100644 --- a/src/figwheel/main.cljc +++ b/src/figwheel/main.cljc @@ -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"] @@ -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))) @@ -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))) @@ -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)) diff --git a/src/figwheel/main/schema/cljs_options.clj b/src/figwheel/main/schema/cljs_options.clj index 1fb568e..b3b1cb7 100644 --- a/src/figwheel/main/schema/cljs_options.clj +++ b/src/figwheel/main/schema/cljs_options.clj @@ -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