Fork me on GitHub
#shadow-cljs
<
2022-04-08
>
pinkfrog12:04:13

In the manual on compilation cache: https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache, it is said Namespaces that are known to include side-effecting macros can be blocked from caching. What is side-effecting macro and what bad outcome will happen if the namespace containing it is cached?

thheller14:04:46

@i side-effect is everything where the macro generates different code for the same form depending on other factors. eg. touching files on disk, manually editing analyzer data, etc

thheller14:04:27

bad outcome is that you see stale compilation output. ie. not what you expecting, since it is caching data and not updating "properly" since it doesn't know about the external stuff

👍 1
rgm20:04:17

we're developing a typescript+hooks component and planning to use it from cljs. Is there an example around of how to have typescript code participating in shadow's hot-reload? Right now we have /ts-dir and /cljs-dir. The /ts-dir is a webpack project that produces its js via npm run build. The /cljs-dir has a reference in its package.json dependencies as "my-ts-code": "../ts-dir". I'm re-building the typescript with a simple find src | entr npm run build in a separate terminal window. As it stands, I seem to have to restart shadow to get it to notice the new bundled JS from /ts-dir.

thheller20:04:21

touch can touch node_modules/my-ts-code/package.json to make shadow-cljs recompile it. hot-reload is very unlikely to work in that kind of setup though

rgm21:04:26

thanks ... I'll give that a go and report back

thheller21:04:11

note that npm might make a copy of your code in node_modules instead of symlinking it

rgm21:04:09

ok ... I'll just figure out which thing I need to poke with touch

rgm21:04:16

I can just touch another cljs component ns, and I'm not super concerned with "proper" hot reload (meaning browser app state is preserved) ... reloading everything would be fine since even that's an improvement over restarting the shadow watch process.

rgm21:04:08

hm, nope, at least not on a Mac. npm i (with npm 8.5.0) in /cljs-dir just symlinks /ts-dir -> /cljs-dir/node_modules/my-ts-code and it doesn't look like shadow watching crosses the symlink. I tried manually setting up a copy in /cljs-dir/node_modules/my-ts-code and rsyncing but that seems to yank something important out from under shadow. Shadow notices, but I get a "can't find module" message. (I can do it again to get the exact phrasing ... forgot to copy it).

thheller21:04:51

invidivual files in node_modules are not watched at all. only the package.json is checked. so thats why you touch it

rgm21:04:47

right ... it just doesn't seem shadow notices a touch on the package.json on the far side of the symlink

thheller21:04:36

do you judge that by checking a rebuild actually happens or whether the reload is working?

thheller21:04:45

it should trigger a compilation

rgm21:04:13

oh wait it did trigger ... my mistake... but I got this

rgm21:04:11

so to be clear: yes, shadow notices the touch through the symlink, but it gets confused

thheller21:04:16

hmm dunno that usually signals an internal error

thheller21:04:27

but dunno what module is there?

rgm21:04:37

maybe I'll try a minimal repro

rgm21:04:17

might be something I'm doing wrong in code splitting, but other than this it seems to be working OK