Fork me on GitHub
#shadow-cljs
<
2022-03-10
>
Pepijn de Vos12:03:31

If I add https://www.npmjs.com/package/bootstrap-icons as a dependency, how can I actually reference the svg files?

thheller12:03:51

it is not javascript. so not with shadow-cljs.

1
Pepijn de Vos12:03:18

Ok, I'll just copy the SVGs, yolo

rkiouak13:03:36

I am trying to build a cljs project into an npm module for import into a js project, I understand that using the :node-library may lead more fine grained control, but I haven't been able to get past the roadblock of the output of shadow for this project including e.g. var js = FS.readFileSync(filePath);. Am I missing some obvious control on how I would tell the compile job to output a node-library suitable for a browser env?

thheller13:03:20

as the name should imply :node-library is intended to run in node

thheller13:03:03

use :target :npm-module if you want to include in a webpack build or something like that

rkiouak13:03:46

am I misinterpreting this guidance: > If you plan to distribute code on NPM, then you may want to use the :node-libraryhttps://shadow-cljs.github.io/docs/UsersGuide.html#NodeLibrary instead since it allows for a finer level of control over exports and optimization. ?

thheller13:03:18

well, technically speaking :node-library works too. just assumes the presence of node for compile and watch builds. release build will also work in the browser

thheller13:03:53

but :target :npm-module with :runtime :browser will work more reliable and also with compile/watch

thheller13:03:29

regardless of target. only release builds should actually be published

rkiouak15:03:25

thanks @thheller. Is it possible to do a release build of either node-library or npm-module without minified function fields? I'm not publishing to npm now, i'm taking a very legacy cljs app and working on getting it behaving correctly in a js project, and as it is not yet behaving well, the console errors are difficult to debug with the minifed output.

thheller15:03:20

you can use shadow-cljs release the-build --pseudo-names to make it easier

🙏 1
thheller15:03:00

you can set :compiler-options {:optimizations :simple} but that'll make the build much much larger

rkiouak15:03:39

yeah, unfortunately the webpack dev build of the js app was OOMing with non release optimizations

rkiouak15:03:48

trying --pseudo-neames now

thheller15:03:47

what kind of JS integration are you looking for? CLJS using JS code, JS code using CLJS or both?

rkiouak15:03:55

Js using cljs

thheller15:03:01

hmm yeah then npm-module is best I'd say

thheller15:03:47

just include the external index in the webpack build (won't slow it down as much)

thheller15:03:06

and then in the JS access the CLJS code via export'd globals

thheller15:03:22

so (defn ^:export foo [] ...) is that.ns.foo() in JS

thheller15:03:21

that way webpack doesn't touch the CLJS code at all though which might be good

Sam Ritchie17:03:28

does anyone have any clue why this is occurring for me, with a threejs load?

Sam Ritchie17:03:25

I am working on a better repro… basically I have some code that absolutely works with shadow-cljs: https://github.com/sicmutils/mathbox-clj/blob/main/src/main/mathbox_clj/demo.cljs But then I try and use the code from a different project with more npm deps and I get this error. Those files definitely exist Vector3, Matrix4 , but something is weird about the way they’re written. what is causing the module$node_modules etc output?

Sam Ritchie17:03:20

in fact it seems like shadow loads it fine… there is just this error below

Sam Ritchie17:03:33

might have solved it from a SLACK search… gotta get used to that still…

Sam Ritchie18:03:03

mismatched shadow version caused it all 🙂