shadow-cljs

andrea 2025-06-21T10:00:33.847539Z

Is there a way to get hot-reload and a repl to a :node-script target? I'm experimenting with a server that needs to run on node, I could get the server to compile with: npx shadow-cljs -d cider/cider-nrepl:0.51.1 watch :app :server That generates the server js file but doesn't run the server. If I do separately run node path/to/server.js it will start a server, and a :server repl I can connect and print to. Good. Now if I do save that file there's no hot reload, I could use nodemon path/to/server.js and that would hotreload the whole node process, losing the internal state. Is there a good way to get a clojure-like experience with a node server?

thheller 2025-06-21T10:08:30.826179Z

if you have a REPL then there is hot reload

thheller 2025-06-21T10:08:37.733459Z

what you might be missing is the :dev/after-load hook

andrea 2025-06-21T10:47:05.328339Z

ah thank you! I was using :after-load rather than :dev/after-load ! One thing that it's not clear to me is where the server repl is running from. I guess it's not from npx shadow-cljs... but rather from node path/to/server.js correct? This seems useful to know to fix a related problem I have with calva not switching between the two repls https://clojurians.slack.com/archives/CBE668G4R/p1750501328074719?thread_ts=1750499391.908279&cid=CBE668G4R

thheller 2025-06-21T10:48:03.431149Z

both really

thheller 2025-06-21T10:50:40.801269Z

you can switch repls via (shadow.cljs.devtools.api/repl :app) or :server. switches the CLJ REPL to CLJS for that build. :cljs/quit switches it back to CLJ

thheller 2025-06-21T10:50:54.058539Z

not the slightest clue how calva handles any of that though

andrea 2025-06-21T10:52:58.161199Z

Will investigate, thank you!!