Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cljs 1.10.x worker target support #659

Merged
merged 3 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sidecar/src/figwheel_sidecar/build_middleware/injection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
(when-let [target (get-in build [:build-options :target])]
(= target :nodejs)))

(defn- webworker? [build]
(when-let [target (get-in build [:build-options :target])]
(= target :webworker)))

(defn- has-main? [build]
(get-in build [:build-options :main]))

Expand Down Expand Up @@ -41,7 +45,8 @@
(fnil conj [])
(if (and (has-main? build)
(not (has-modules? build))
(not (node? build)))
(not (node? build))
(not (webworker? build)))
'figwheel.connect
'figwheel.preload))
(update-in [:build-options :external-config :figwheel/config] #(if % % (get build :figwheel {})))
Expand Down Expand Up @@ -70,7 +75,7 @@

(defn append-src-script [build src-code]
(let [output-to (has-output-to? build)
line (if (and (has-main? build) (not (node? build)))
line (if (and (has-main? build) (not (node? build)) (not (webworker? build)))
(str (document-write-src-script src-code))
(format "\n%s" src-code))]
(when (and output-to (.exists (io/file output-to)))
Expand All @@ -80,7 +85,8 @@
(when (and (config/figwheel-build? build)
(has-main? build)
(not (has-modules? build))
(not (node? build)))
(not (node? build))
(not (webworker? build)))
(append-src-script build "figwheel.connect.start();")))

(defn hook [build-fn]
Expand Down
2 changes: 1 addition & 1 deletion sidecar/src/figwheel_sidecar/schemas/cljs_options.clj
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ human-readable manner. Defaults to true.

:pretty-print false")

(def-key ::target #{:nodejs}
(def-key ::target #{:nodejs :webworker}

"If targeting nodejs add this line. Takes no other options at the
moment. The default (no :target specified) implies browsers are being
Expand Down
5 changes: 5 additions & 0 deletions support/src/figwheel/client/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
(defmacro dev-assert [& body]
`(dev
~@(map (fn [pred-stmt] `(assert ~pred-stmt)) body)))

(defmacro feature?
[obj feature]
`(and (cljs.core/exists? ~obj)
(cljs.core/exists? (cljs.core/aget ~obj ~feature))))
9 changes: 2 additions & 7 deletions support/src/figwheel/client/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[goog.userAgent.product :as product])
(:import [goog]
[goog.async Deferred]
[goog.string StringBuffer]))
[goog.string StringBuffer])
(:require-macros [figwheel.client.utils :refer [feature?]]))

;; don't auto reload this file it will mess up the debug printing

Expand Down Expand Up @@ -110,12 +111,6 @@
deferred coll)
(fn [_] (.succeed Deferred @results)))))


(defn- feature? [obj feature]
(and (exists? obj)
(exists? (aget obj feature))))


;; persistent storage of configuration keys

(defonce local-persistent-config
Expand Down