shadow-cljs

cjohansen 2025-12-16T08:49:55.713249Z

Question about live reloading and dependencies. I have a namespace A with a (def a :val) in it. Namespace B depends on A and includes (def b (some-derived-value A/a)) and finally I have a third namespace C which depends on B with (def c (some-derived-value B/b)). If I change namespace A, shadow reloads namespaces A and B, but not C. Is that the intended behavior, or should it also reload C?

Roman Liutikov 2025-12-16T09:18:43.403339Z

Hm, normally everything down the dependency tree is rebuilt

cjohansen 2025-12-16T09:21:15.986369Z

That's what I thought, but not what we're seeing 🤔

thheller 2025-12-16T09:47:36.217349Z

that is the way it is intended yeah. it only recompiles/reloads files that are directly referenced. so c doesn't have a direct reference on a (or more specifically the namespace it is in), so it is not reloaded

thheller 2025-12-16T09:48:03.549339Z

you can change that behaviour by using :devtools {:reload-strategy :full} but depending on the build size that may be substantially slower

thheller 2025-12-16T09:51:12.087019Z

the actual strategy is this. you change namespace A, it is recompiled. on a previous compile all namespaces that had any direct reference to A are collected, so any var used. These will also be recompiled.

thheller 2025-12-16T09:53:06.925889Z

:reload-strategy actually only affects the files that get reloaded, not recompiled. since if a file doesn't have any direct references it doesn't need to be recompiled, you are just relying on side-effects during load to occur.

cjohansen 2025-12-16T09:59:55.229189Z

Interesting. Thanks for the info, I'll check out that blog post.

Roman Liutikov 2025-12-16T10:00:18.380369Z

Ha, interesting. I guess I never noticed this since in react apps the ui is updated after reload and everything is pulled by reference

cjohansen 2025-12-16T10:01:57.962939Z

Yes, this is rarely an issue for me as well.

borkdude 2025-12-16T13:24:34.194289Z

I had the same question here :) https://clojurians.slack.com/archives/C6N245JGG/p1758813529397059

cjohansen 2025-12-16T13:28:18.720699Z

I'm terrible at searching 😅 🙈

borkdude 2025-12-16T13:29:06.481169Z

I was terrible at finding this thread even when I knew it existed ;)

😅 1
avocade 2025-12-16T17:03:23.102359Z

Hey, longtime user of shadow-cljs (thanks!) with advanced closure compilation 👋

avocade 2025-12-16T17:06:26.587319Z

Been reading more and more about ESmodules and import maps (ie "bundler-less JS"). Seems like it's the standard-to-be for web apps going forward.

avocade 2025-12-16T17:06:34.512379Z

I'm very curious if there's actual technical limitations to why this would not work for us in cljs-land (which would be very sad indeed), and if those reasons are actually "impossible" or more like "infeasible" right now. Rails seem to be lovin' the new way since a few years back at least: https://world.hey.com/dhh/hey-is-running-its-javascript-off-import-maps-2abcf203

thheller 2025-12-16T18:28:43.971839Z

I think its complete nonsense and CLJS is never going to be "bundler-less" since the browser doesn't understand it natively. so something must convert it to JS, and while doing so might as well do the positive things bundlers do

thheller 2025-12-16T18:28:55.614959Z

that being said, for JS dependencies you can use import maps just fine today

avocade 2025-12-17T10:49:20.138889Z

yeah, for external deps. but would be great not to have the one huge JS file (which is cache-busted on every tiny change to any namespace) 🙂 just feels so clunky.

avocade 2025-12-17T10:49:54.715249Z

but thanks for the insight, I assumed there was a deep technical reason why this would be hard (near impossible?) for cljs-land.

thheller 2025-12-17T11:57:24.828569Z

well the unoptimized code could be output in a way where each namespace is in a separate ESM .js file that is only :simple optimized, but given that its lacking :advanced optimizations overall things just will be much much larger. so one option is downloading 50 different .js files that result in like 1mb of JS. or downloading one highly optimized file (that also compresses better) and having 100kb total or whatever

thheller 2025-12-17T11:58:58.792989Z

I don't think the tradeoff is worth that. I also think the hey screenshot from the blogpost shows exactly that issue. 1.88s to finish is horrible.

avocade 2025-12-17T14:19:56.835989Z

thanks

mauricio.szabo 2026-01-05T14:27:17.919479Z

@avocade a lot of stuff that is praised in Rails is usually exaggerated or incomplete, to be honest. I remember someone proudly showing a post about "caching" where they somehow "praised" the N+1 approach of loading associations in Rails because these all would be cached, but the logs "conveniently" removed the actual time to render the full page (but even what they kept showed that there was no performance gain)