Fork me on GitHub
#cljsjs
<
2018-06-27
>
cjohansen20:06:09

I've been working on a library that depends on a node module. It's tests are working fine, but when I try to consume it from another code base, the npm-deps from my compiler config is missing. Do I need to package up the node module as a cljsjs package to have it as a transitive dependency?

juhoteperi20:06:43

@christian767 No, not necessarily. Simple solution is to tell users of the library to add npm package themselves (npm-deps or manually or anything).

juhoteperi20:06:24

Transitive :npm-deps are also supported, the library can create deps.cljs file in jar root and :npm-deps from that file is read by consumer projects, IF the apps use :install-deps true option.

juhoteperi20:06:51

Creating the cljsjs package is also option, if you want to allow users to select if they want to use cljsjs or npm. Reagent does this.

cjohansen20:06:19

Guess I'll make the cljsjs package then, I'd rather my users needn't worry about specifics of my deps

juhoteperi20:06:50

Yes, I think that allows the broadest support for library now. To allow the lib also be used with npm, you should match the npm names in cljsjs package and use global-exports option: https://github.com/cljsjs/packages/blob/master/create-react-class/build.boot#L25-L28

juhoteperi20:06:11

With those options the JS lib can be used from Cljs using the same code as npm-deps, so users can use either

cjohansen20:06:26

Cool, thanks!