shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
2021-06-04T06:15:11.351800Z

I am trying to create a library that is going to be included in a script tag in another shadow-cljs project. The problem I am facing is that it seems that a shadow$provide global variable is created for each build, and because of this, the second variable overwrites the first one producing a Module not provided. I've tried the :browser and the :node-library targets and both of them seem to have the same problem. What is the best way to get around this?

thheller 2021-06-04T06:27:54.352500Z

@diego.vid.eco it is not a good idea to use 2 separate CLJS builds on the same page. both will end up including cljs.core and all other dependencies leading to a lot of bloat. they also won't be compatible with each other and can't exchange CLJS datastructures. ideally make the library part of the compilation of the second one, like any other CLJS libs.

2021-06-04T06:45:15.355400Z

I see. And it makes sense. I originally wanted to develop a couple of plug-n-play libraries for an art project, where also others could plug in their own developments. So that's why I didn't intend to have them "installed" by default on the hosting webpage. Seems like I may have to reconsider some things, but might not be much of a problem.

thheller 2021-06-04T06:52:47.356600Z

yeah unfortunately there is no way to really do this properly in CLJS. even if I isolated shadow$provide more that doesn't fix all the other problems you'd have.

thheller 2021-06-04T06:53:37.357400Z

JS has the same issues if you have 2 libs using immutable-js or so. things can talk to each other fine with just JS objects but everything else breaks.

danielneal 2021-06-04T08:14:28.359Z

is it possible to have multiple shadow-cljs builds with different dependencies. i.e. I want to produce a js npm package (that doesn't depend on react, helix etc) and a cljs live-reloading demo of the package (that does depend on react, helix etc), but preferably from the same overall project

thheller 2021-06-04T08:16:15.359600Z

npm library as-in it will be consumed by JS projects?

thheller 2021-06-04T08:17:17.360200Z

in general your dependencies decide nothing about the build. the build config controls how or what is included, not the dependencies you have listed in your project

thheller 2021-06-04T08:17:56.360600Z

what is a live-reloading demo? for people checking out the repo and running it locally you mean?

danielneal 2021-06-04T08:18:52.361100Z

yep, the npm library will be consumed by js projects

danielneal 2021-06-04T08:19:32.362100Z

the live-reloading demo is exactly for the cljs devs so that we can check out the lib and make modifications to it and see it in action

thheller 2021-06-04T08:19:32.362200Z

not including react is fine but helix is a CLJS lib so you need to include that no?

thheller 2021-06-04T08:20:39.363200Z

to build the library you can use :target :node-library or :target :npm-module, those by default don't bundle JS dependencies, only compiled CLJS code

danielneal 2021-06-04T08:21:03.363500Z

ah ok

danielneal 2021-06-04T08:21:25.363800Z

I'll have a go 🙂

thheller 2021-06-04T08:21:51.364Z

https://github.com/thheller/npm-module-demo

thheller 2021-06-04T08:22:49.364700Z

made that a long time ago. config is unchanged though. just need to bump a few versions

thheller 2021-06-04T08:23:19.365400Z

basically you add the dependencies of the package in the packages/demo/package.json

thheller 2021-06-04T08:23:31.365900Z

and publish the packages/demo dir using npm publish

danielneal 2021-06-04T08:24:23.366800Z

the :entries key is a list of clojurescript namespaces to include in the npm package?

thheller 2021-06-04T08:29:09.367200Z

yes

danielneal 2021-06-04T08:29:37.367400Z

great, thanks

Franklin 2021-06-04T08:40:51.368400Z

can shadow-cljs also watch and hot-reload css?

thheller 2021-06-04T08:42:04.369100Z

watch as in observe when the file changes yes

Franklin 2021-06-04T08:42:26.369700Z

yes, so I'm hoping that when I change them... the styling on the browser also changes

Franklin 2021-06-04T08:42:54.369900Z

cool, thanks

2021-06-04T13:32:57.371900Z

how do I use latest shadow-cljs from github?

thheller 2021-06-04T14:54:04.373Z

unfortunately not that simple. can't use deps.edn because there is some stuff that needs to be built (eg. java sources).