Fork me on GitHub

is there an official recommended way to get cljsjs and bundle/webpack in figwheel main to play nicely? My assumption is that it's important to only have one of everything. So I removed all my cljsjs deps and added them to npm. And i also excluded cljsjs deps from reagent and other projects that pull them in transitively. Then I create cljsjs namespaces by hand, that sets global variables so that i.e. "React" is available globally when someone pulls in cljsjs.react. However, for some reason, the bundled output from figwheel seems to write things so that it's in the wrong order. I.e. a dependency that uses cljsjs.react seems to somehow execute before cljsjs.react is loaded in, and so "React" is undefined. Maybe I should think differently about this?


Curious: which deps are available as CLJSJS, but not NPM that you’re interesting in?


I'm going the opposite way actually, I'm getting rid of cljsjs and moving to using npm instead


Right, so you’re going dep by dep instead of whole sale change?


yeah, I plan to keep the old versjons of some dependencies I use around for now, and provide cljsjs for backwards compatibility, so I don't have to change the actual code, just the build step

👍 1

My normal approach has been whole sale change because, from my experience doing this thing, I can just specify the same versions of the NPM packages and things are good. But, depending on the deps this may not be as straightforward? All good. Curiosity satisfied 🙂


my main issue is a lack of understanding of what's going on and lots of manual trial and error 😄 But at least I can narrow it down now - I'm only going to try variants of having all cljsjs dependencies excluded (as mentioned in #figwheel-main)

👍 1
augustl09:05:23 does not mention that you should exclude cljsjs deps so maybe I'm over thinking it 🙂


tldr: should you make sure to exclude transitive cljsjs dependencies when you combine figwheel main + bundling with webpack + cljsjs?


not entirely sure... but it seems I've ended up in a situation where I have multiple instances of react around


found it! You are indeed supposed to exclude cljsjs dependencies: > When compiling for production we should also, make sure that you aren’t including Cljsjs libraries that are being provided for by NPM libraries. We don’t want to be including libraries twice.


is there any way to tell figwheel/webpack/.... that for the require cljsjs.react-select, it needs to load react and classnames first? I'm using auto bundling


seems like my issue right now is that cljsjs.react-select includes a js file without any goog.require and goog.provide etc, so figwheel/webpack/... has no idea that it needs React to be available, and so I get errors about React being undefined when I run my bundled script


(note that I'm not using cljsjs.react-select from upstream, I'm using a forked version, so maybe something is simply missing from this fork)


I guess that it's a problem that I'm using npm and I've removed all cljsjs deps, except that one cljsjs dep that is an internal fork. So I am in fact still using cljsjs alongside npm


ok... that was it 😄 The fact that this was an internally forked module made me blind to the fact that I was including a cljsjs module alongside npm modules. I added the forked module as a npm dependency instead and BOOM it works partyparrotpartyparrotpartyparrotpartyparrot


tldr: when you combine cljsjs with bundling npm modules in figwheel main, remove and exclude all cljsjs dependencies. Everything has to come from package.json.


I believe the issue is that cljsjs modules are missing important goog.require and goog.provide statements, which causes the cljsjs module to be included in the bundle at the wrong location where required modules aren't yet available



duckie 1