This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-26
Channels
- # beginners (17)
- # boot (3)
- # cljs-dev (2)
- # cljsrn (3)
- # clojure (52)
- # clojure-austin (1)
- # clojure-poland (4)
- # clojure-russia (29)
- # clojure-spec (25)
- # clojure-uk (5)
- # clojurescript (39)
- # cursive (29)
- # data-science (5)
- # datomic (5)
- # fulcro (21)
- # graphql (1)
- # hoplon (20)
- # off-topic (5)
- # pedestal (1)
- # perun (3)
- # protorepl (2)
- # re-frame (7)
- # ring (1)
- # shadow-cljs (19)
- # unrepl (10)
- # vim (4)
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: https://github.com/thheller/shadow-cljs-template). 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?).
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
oh if you use the template run npm install
. it already has everything properly setup.
https://github.com/shadow-cljs/lein-template 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. https://github.com/cljsjs/packages/tree/master/react
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. https://github.com/thheller/shadow-cljsjs
I wrote a few posts about JS deps https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html
> 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.
https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html hopefully covers everything about JS deps