Skip to content

Commit

Permalink
fix "browser" overrides with false in package.json not working
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed May 31, 2022
1 parent b9992b4 commit c2c1804
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 148 deletions.
292 changes: 146 additions & 146 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,20 @@
:output-to "out/demo-script-bundle/script.js"}

#_#_:browser-single
{:target :browser
{:target :browser

:output-dir "out/demo-browser-single/public/js"
:asset-path "/js"
:output-dir "out/demo-browser-single/public/js"
:asset-path "/js"

:compiler-options
{:closure-defines {demo.browser/FOO "bar"}}
:compiler-options
{:closure-defines {demo.browser/FOO "bar"}}

:modules
{:demo {:entries [demo.browser]}}
:modules
{:demo {:entries [demo.browser]}}

:devtools
{:before-load-async demo.browser/stop-from-config
:after-load demo.browser/start-from-config}}
:devtools
{:before-load-async demo.browser/stop-from-config
:after-load demo.browser/start-from-config}}

:chrome-ext
{:target :chrome-extension
Expand All @@ -266,88 +266,88 @@
:output-to "out/demo-test-node/script.js"}

#_#_:test-fail
{:target :node-test
:output-to "out/demo-test-node-fail/script.js"
:ns-regexp "demo.test-fail"}
{:target :node-test
:output-to "out/demo-test-node-fail/script.js"
:ns-regexp "demo.test-fail"}

#_#_:test-karma
{:target :karma
:output-to "out/demo-karma/test.js"}
{:target :karma
:output-to "out/demo-karma/test.js"}

#_#_:sm-test
{:target :browser

:output-dir "out/demo-sm-test/public/js"
:asset-path "/js"

:compiler-options
{:source-map true
:pretty-print false}

:modules
{:base
{:entries
[cljs.core]
:depends-on
#{}}

:test
{:entries [demo.sm-test]
:depends-on #{:base}}}

:js-options
{:js-provider :shadow
:resolve
{"js-sm-test"
{:target :file
:file "test/cjs/js-sm-test.js"}}}

:devtools
{:http-root "out/demo-sm-test/public"
:http-port 8605
:async-require true
:enabled false}}
{:target :browser

:output-dir "out/demo-sm-test/public/js"
:asset-path "/js"

:compiler-options
{:source-map true
:pretty-print false}

:modules
{:base
{:entries
[cljs.core]
:depends-on
#{}}

:test
{:entries [demo.sm-test]
:depends-on #{:base}}}

:js-options
{:js-provider :shadow
:resolve
{"js-sm-test"
{:target :file
:file "test/cjs/js-sm-test.js"}}}

:devtools
{:http-root "out/demo-sm-test/public"
:http-port 8605
:async-require true
:enabled false}}

#_#_:bootstrap-host
{:target :browser
{:target :browser

:output-dir "out/demo-selfhost/public/simple/js"
:asset-path "/simple/js"
:output-dir "out/demo-selfhost/public/simple/js"
:asset-path "/simple/js"

:compiler-options
{:optimizations :simple}
:compiler-options
{:optimizations :simple}

:modules
{:base
{:entries [demo.selfhost.simple]}}
:modules
{:base
{:entries [demo.selfhost.simple]}}

:devtools
{:http-root "out/demo-selfhost/public"
:http-port 8610
:before-load demo.selfhost.simple/stop
:after-load demo.selfhost.simple/start}}
:devtools
{:http-root "out/demo-selfhost/public"
:http-port 8610
:before-load demo.selfhost.simple/stop
:after-load demo.selfhost.simple/start}}

#_#_:bootstrap-worker
{:target :browser
{:target :browser

:output-dir "out/demo-selfhost/public/worker/js"
:asset-path "/worker/js"
:output-dir "out/demo-selfhost/public/worker/js"
:asset-path "/worker/js"

:compiler-options
{:optimizations :simple}
:compiler-options
{:optimizations :simple}

:modules
{:base
{:entries [shadow.cljs.bootstrap.env
demo.selfhost.host]}
:worker
{:entries [demo.selfhost.worker]
:depends-on #{:base}
:web-worker true}}
:modules
{:base
{:entries [shadow.cljs.bootstrap.env
demo.selfhost.host]}
:worker
{:entries [demo.selfhost.worker]
:depends-on #{:base}
:web-worker true}}

:devtools
{:before-load demo.selfhost.host/stop
:after-load demo.selfhost.host/start}}
:devtools
{:before-load demo.selfhost.host/stop
:after-load demo.selfhost.host/start}}

:bootstrap-support
{:target :bootstrap
Expand All @@ -357,50 +357,50 @@
:macros []}

#_#_:js-only
{:target :browser
:output-dir "out/demo-js-only/public/js"
:asset-path "/js"
:compiler-options
{:optimizations :simple
:pretty-print true}
:modules {:base {:entries [cljs.core
shadow.js]}
:main {:entries ["/test/cjs/entry.js"]
:depends-on #{:base}}}
:devtools
{:enabled false
:console-support false}}
{:target :browser
:output-dir "out/demo-js-only/public/js"
:asset-path "/js"
:compiler-options
{:optimizations :simple
:pretty-print true}
:modules {:base {:entries [cljs.core
shadow.js]}
:main {:entries ["/test/cjs/entry.js"]
:depends-on #{:base}}}
:devtools
{:enabled false
:console-support false}}

#_#_:closure
{:target :browser
:output-dir "out/demo-closure/public/js"
:asset-path "/js"
:modules {:base {:entries [cljs.core
shadow.js]}
:main {:entries [demo.reagent]
:depends-on #{:base}}}
:compiler-options
{:externs ["test/react.ext.js"
"test/react-dom.ext.js"]
:closure-warnings {:global-this :off}}
:js-options
{:js-provider :closure}
:devtools
{:http-root "out/demo-closure/public"
:http-port 7810
:autoload true}}
{:target :browser
:output-dir "out/demo-closure/public/js"
:asset-path "/js"
:modules {:base {:entries [cljs.core
shadow.js]}
:main {:entries [demo.reagent]
:depends-on #{:base}}}
:compiler-options
{:externs ["test/react.ext.js"
"test/react-dom.ext.js"]
:closure-warnings {:global-this :off}}
:js-options
{:js-provider :closure}
:devtools
{:http-root "out/demo-closure/public"
:http-port 7810
:autoload true}}

#_#_:closure-es6
{:target :browser
:output-dir "out/demo-closure-es6/public/js"
:asset-path "/js"
:modules {:main {:entries [demo.closure]}}
:js-options
{:js-provider :closure}
:devtools
{:http-root "out/demo-closure-es6/public"
:http-port 7820
:autoload true}}
{:target :browser
:output-dir "out/demo-closure-es6/public/js"
:asset-path "/js"
:modules {:main {:entries [demo.closure]}}
:js-options
{:js-provider :closure}
:devtools
{:http-root "out/demo-closure-es6/public"
:http-port 7820
:autoload true}}

:script
{:target :node-script
Expand Down Expand Up @@ -446,17 +446,17 @@
:keep-native-requires true}}

#_#_:custom
{:target build/custom
{:target build/custom

:output-dir "out/demo-browser/js"
:asset-path "/js"
:output-dir "out/demo-browser/js"
:asset-path "/js"

:modules
{:demo {:entries [demo.browser]}}
:modules
{:demo {:entries [demo.browser]}}

:devtools
{:before-load demo.browser/stop
:after-load demo.browser/start}}
:devtools
{:before-load demo.browser/stop
:after-load demo.browser/start}}

:warnings
{:target :node-script
Expand All @@ -469,14 +469,14 @@
:output-to "out/demo-errors/script.js"}

#_#_:foreign
{:target :browser
:output-dir "out/demo-foreign/js"
:asset-path "/js"
:compiler-options
{:externs
["src/dev/demo/foreign-ext.js"]}
:modules
{:main {:entries [demo.foreign]}}}
{:target :browser
:output-dir "out/demo-foreign/js"
:asset-path "/js"
:compiler-options
{:externs
["src/dev/demo/foreign-ext.js"]}
:modules
{:main {:entries [demo.foreign]}}}

:npm
{:target :npm-module
Expand All @@ -486,9 +486,9 @@
#_demo.rel-require]}

#_#_:azure-fn
{:target :azure-app
:fn-map {:simple demo.azure.simple/test-fn}
:app-dir "out/azure-fn"}
{:target :azure-app
:fn-map {:simple demo.azure.simple/test-fn}
:app-dir "out/azure-fn"}

:expo-ios
{:target :react-native
Expand All @@ -505,14 +505,14 @@
:devtools {:autoload true}}

#_#_:expo-android
{:target :expo
:init-fn demo.rn/init
:platform "android"
:expo-root "out/TestCRNA"
:output-dir "out/TestCRNA/out-android"
:devtools
{:http-port 19501
:http-root "out/TestCRNA/out-android"}}
{:target :expo
:init-fn demo.rn/init
:platform "android"
:expo-root "out/TestCRNA"
:output-dir "out/TestCRNA/out-android"
:devtools
{:http-port 19501
:http-root "out/TestCRNA/out-android"}}

:npm-web
{:target :npm-module
Expand All @@ -521,9 +521,9 @@
:output-dir "out/npm-web/src/cljs"}

#_#_:node-repl-test
{:target :node-script
:main shadow.cljs.devtools.client.node-repl/main
:output-to "out/node-repl-dev/node-repl.js"}
{:target :node-script
:main shadow.cljs.devtools.client.node-repl/main
:output-to "out/node-repl-dev/node-repl.js"}

:dce
{:target :browser
Expand Down
7 changes: 5 additions & 2 deletions src/main/shadow/build/npm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,11 @@
:package-require
(let [override
(when (and require-from (::package require-from) (:use-browser-overrides (:js-options npm)))
(or (get-in require-from [::package :browser-overrides require])
(get node-libs-browser require)))]
(let [override (get-in require-from [::package :browser-overrides require])]
;; might be false, can't use or
(if-not (nil? override)
override
(get node-libs-browser require))))]

(cond
;; common path, no override
Expand Down

0 comments on commit c2c1804

Please sign in to comment.