Fork me on GitHub

Hi, currently I'm playing around with shadow-cljs and still don't completely grasp its dependency management (especially the interplay between cljs and npm libs). When I bootstrap a leiningen app (e.g. with figwheel) and add rum as dependency, I can start my app with lein figwheel right away and all required dependencies are downloaded automatically. On the other hand, when I add rum as a dependency to shadow-cljs, I have to separately include the official js react dependencies in the project's package.json as well (e.g. done here: If I don't, I receive an The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs" (`cljsjs/react` is a dependency for rum) error. Why is that? I guess I'm not really understanding how leiningen and shadow-cljs solve the installation of dependencies internally, especially when it comes to cljsjs-libraries (which we don't really need in shadow-cljs anyways, right?).


shadow-cljs uses npm to manage the JS dependencies. so you npm install react.


not all CLJS project (eg. rum) properly declare their :npm-deps and will still use cljsjs


so its a matter of projects not declaring the deps, they should be automatically installed once declared properly


until that point though it will remain a bit manual


oh if you use the template run npm install. it already has everything properly setup.


lein templates just don’t run that command for you

thheller12:11:14 thats the template btw. deleted the old fork.


Thanks a lot for your quick response 🙂 So that's already a lot clearer. Just for comparison: Why doesn't leiningen need this extra step of installing the react js dependency?


because rum uses cljsjs.react which is the re-packaged npm package. so its not using npm but rather the 3rd party package.


shadow-cljs uses the npm package directly, skipping the re-packaged cljsjs.


Ah, OK, so shadow-cljs is aware of cljsjs dependencies and can skip them automatically? That's really cool!


it doesn’t strictly skip them, it just provides the mapping back to their original npm packages.


> The systems simply do not mix well and frequently conflict with each other. One library might use cljsjs.react while another uses the newer “react”. This would lead to two versions of React being included in your page.


thats basically why I have to work around cljsjs packages, I don’t want any of those conflicts.


I think I've understood it now. Thanks again for your time! I'll also have a look at your blog posts.