This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-08
Channels
- # announcements (8)
- # aws (2)
- # babashka (11)
- # babashka-sci-dev (39)
- # beginners (62)
- # calva (5)
- # cider (1)
- # clj-kondo (50)
- # cljdoc (2)
- # cljs-dev (6)
- # clojure (52)
- # clojure-austin (22)
- # clojure-czech (13)
- # clojure-europe (88)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (6)
- # clojuredesign-podcast (13)
- # clojurescript (45)
- # community-development (3)
- # core-typed (31)
- # cursive (12)
- # datahike (2)
- # datalevin (7)
- # datomic (5)
- # events (1)
- # exercism (11)
- # fulcro (27)
- # gratitude (1)
- # holy-lambda (3)
- # hoplon (2)
- # introduce-yourself (2)
- # jobs (1)
- # lambdaisland (3)
- # lsp (110)
- # malli (2)
- # meander (4)
- # music (2)
- # off-topic (50)
- # overtone (1)
- # pathom (13)
- # polylith (26)
- # re-frame (4)
- # releases (2)
- # rewrite-clj (3)
- # ring (12)
- # shadow-cljs (20)
- # specter (4)
- # tools-deps (8)
- # xtdb (40)
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?
@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
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
note that npm might make a copy of your code in node_modules
instead of symlinking it
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