Skip to content

Commit

Permalink
Support targeting webworker
Browse files Browse the repository at this point in the history
  • Loading branch information
kommen authored and dnolen committed Dec 22, 2017
1 parent 072677d commit e380903
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11342,7 +11342,7 @@ reduces them without incurring seq initialization"
nil))
(next segs))
(find-ns-obj* goog/global segs))
"default" (find-ns-obj* goog/global segs)
("default" "webworker") (find-ns-obj* goog/global segs)
(throw (js/Error. (str "find-ns-obj not supported for target " *target*))))))

(defn ns-interns*
Expand Down
22 changes: 22 additions & 0 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,29 @@
entries
[(:main opts)])))
"goog.require(\"cljs.nodejscli\");\n")))

:webworker
(output-one-file
(merge opts
(when module
{:output-to (:output-to module)}))
(str (when (or (not module) (= :cljs-base (:module-name opts)))
(str "var CLOSURE_BASE_PATH = \"" asset-path "/goog/\";\n"
"var CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
"var CLOSURE_IMPORT_SCRIPT = (function(global) { return function(src) {global['importScripts'](src); return true;};})(this);\n"
"if(typeof goog == 'undefined') importScripts(\"" asset-path "/goog/base.js\");\n"
"importScripts(\"" asset-path "/cljs_deps.js\");\n"
(apply str (preloads (:preloads opts)))))
(apply str
(map (fn [entry]
(when-not (= "goog" entry)
(str "goog.require(\"" (comp/munge entry) "\");\n")))
(if-let [entries (when module (:entries module))]
entries
(when-let [main (:main opts)]
[main]))))))

(output-one-file
(merge opts
(when module
{:output-to (:output-to module)}))
Expand Down

0 comments on commit e380903

Please sign in to comment.