Skip to content

Commit

Permalink
remove process use in :npm-module builds using :runtime :browser
Browse files Browse the repository at this point in the history
webpack v5 doesn't provide it by default anymore and complains.
so instead of having everyone adjust their build config we just
emit the proper thing from the start.
  • Loading branch information
thheller committed Jul 14, 2022
1 parent 12dcc76 commit ff9668b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/shadow/build/output.clj
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,15 @@
(defn js-module-env
[{:keys [polyfill-js] :as state} {:keys [runtime] :or {runtime :node} :as config}]
(str "var $CLJS = {};\n"
"var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;\n"

(case runtime
:node
"var CLJS_GLOBAL = global;\n"
:browser
"var CLJS_GLOBAL = globalThis;\n"
;; default, tries to figure it out on its own
"var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;\n")

;; closure accesses these defines via goog.global.CLOSURE_DEFINES
"var CLOSURE_DEFINES = CLJS_GLOBAL.CLOSURE_DEFINES = $CLJS.CLOSURE_DEFINES = " (closure-defines-json state) ";\n"
"CLJS_GLOBAL.CLOSURE_NO_DEPS = true;\n"
Expand Down

0 comments on commit ff9668b

Please sign in to comment.