Fork me on GitHub
#shadow-cljs
<
2021-10-08
>
myguidingstar17:10:50

my app stops working in :advanced mode after migrating to shadow - no error under browser console. Before that we had webpack + cljsjs for npm modules. We have no compilation warnings except some from libraries when set {:infer-externs :all}. There are lots of them, so I wonder there are a list of functions from popular libraries that are known to break :advance compilation.

thheller17:10:02

don't use :all. none of them are relevant

thheller17:10:40

what does "stops working" mean? I mean there must be some kind of bad behavior?

myguidingstar08:10:46

never mind, I've pinpointed the problem with rigid logging.

myguidingstar08:10:16

but glad to know the libraries are not relevant. Thank you very much

cap10morgan17:10:29

Was playing around with this: https://github.com/thheller/netlify-cljs ...and after updating some deps, it seems to fail in netlify-lambda and netlify dev b/c __dirname is set to / so shadow's attempts to import things from __dirname + '/../.shadow-cljs/...' fail. Anyone know of a workaround there?

thheller17:10:59

@cap10morgan are you publishing development code that way or is this during development? you should only actually use release code in a production environment which will never use __dirname?

cap10morgan17:10:59

Strictly local dev so far

thheller17:10:30

it has been 3 years since I touched netlify so no clue what changed on their side. you can set :output-dir "functions" in addition to :output-to "functions/api.js". then it won't use __dirname either

cap10morgan17:10:10

OK I'll give that a try thanks!

cap10morgan17:10:44

that made it put a cljs-runtime dir in the functions dir and then it errors out with no such file or directory, open '/cljs-runtime/goog.debug.error.js'

cap10morgan17:10:05

one issue might be that netlify-lambda now errors out if netlify.toml is pointed at the same functions dir. they say to point it at e.g. functions-build and then it does some kind of build and copy of api.js over to that dir

thheller17:10:45

hmm yeah that doesn't work. the code expects to run in the place where it was created by the compiler

thheller17:10:57

only release can run wherever it wants

cap10morgan17:10:39

ok, yeah, it works w/ npx shadow-cljs release lambda

thheller17:10:31

I mean if you make it copy all the other files in cljs-runtime too then it should be fine

thheller17:10:47

but just copying the :output-to won't work

thheller17:10:33

everything in :output-dir needs to be readable and should ideally not be further modified. otherwise it might mess with hot-reload and stuff

cap10morgan17:10:42

I tried symlinking cljs-runtime but that didn't work b/c it's still trying __dirname + /cljs-runtime so ends up w/ /cljs-runtime

cap10morgan17:10:01

but I can probably get by w/ release for now

thheller17:10:25

don't know why its messing with __dirname though? is this no longer following node rules?

cap10morgan17:10:24

I guess not 🤷

cap10morgan20:10:28

If I'm targeting the browser but building a library that I expect people to consume in a react app w/ webpack, etc., should I use :target :npm-module or :target :node-library instead of :target :browser?

thheller20:10:36

:npm-module was made for that particular use case

👍 2
thheller20:10:00

:node-library makes a few too many assumptions about being for node so I wouldn't recommend that

niveauverleih21:10:55

Shadow-cljs tuning: Apart from :jvm-opts ["-Xmx512m"] are there any settings to limit the RAM and CPU consumption of shadow-cljs? Like reducing the number of files watched, disabling some services? I use a low end device to learn the basics of reagent.

alexdavis22:10:48

You might find this useful, you can learn the basics of clojurescript and reagent without needing to run anything except a browser https://borkdude.github.io/scittle/

alexdavis22:10:17

Alternatively you could use a cloud vm service of some kind to run the shadow process

niveauverleih05:10:20

Thank you all!

thheller21:10:31

not really no