Fork me on GitHub

In the manual on compilation 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?


@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


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

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.


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


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


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


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


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.


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).


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


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


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


it should trigger a compilation


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


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


hmm dunno that usually signals an internal error


but dunno what module is there?


maybe I'll try a minimal repro


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