-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Require react directly #165
Comments
I ran into this same issue! If you're using React and ReactDOM from NPM (and maybe also from CLJSJS, though that's not my case,) you can also export those globals in your shadow configuration instead of explicitly requiring the cljsjs ones--my project uses NPM dependencies, and I didn't want to use CLJSJS only for the benefit of a dev tool hehe. e.g. (the relevant bit being the :devcards
{:target :browser
:output-dir "target/cljsbuild/public/js/devcards"
:asset-path "/js/devcards"
:compiler-options {:devcards true}
:modules {:main {:entries [myapp.devcards]}}
:js-options
{:resolve
{"react" {:export-globals ["React"]}
"react-dom" {:export-globals ["ReactDOM"]}}} However, I would also like to see this resolved in the library to not have to reach for this relatively arcane Shadow CLJS option (I only found out about it while perusing the shadow source code and finding this fun gem: https://github.com/thheller/shadow-cljs/blob/989590bb373e56b1d0ccf3a4029e2d3ec294ffe3/src/main/shadow/build/resolve.clj#L69) Also, caveat, this codebase assumes that |
Requiring So following my repro doesn't actually need cljsjs, but now that I think about it some more it is extra confusing to be referring to something that isn't anywhere in the deps too. Looking at #127 I guess this was meant be fixed in 0.2.6, but isn't? I suppose the |
It has been fixed in v0.2.7. |
Right you are @suud! |
Hi there,
Devcards seems to depend on the global
React
instead of requiring it directly. When using https://github.com/thheller/shadow-cljs with Devcards, you need to directly importcljsjs.react
andcljsjs.react.dom
before importingdevcards.core
, otherwise it will error out at runtime:If devcards imports React directly instead, it should work though:
The text was updated successfully, but these errors were encountered: