shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Alexis Vincent 2021-01-04T12:06:26.259400Z

@thheller shadow-cljs isn’t hot reloading files that aren’t found in src path. I have a deps.edn file with :paths ["src", "resources", ".x/resources"] and :deps true in shadow. File watching, recompile and hot-reload work if I have the file in src but not if the file is instead in resources or .x/resources . How do I fix that? I’m starting the server and watch process in clojure using shadow.cljs.devtools.server/start! and shadow.cljs.devtools.api/watch* .

thheller 2021-01-04T12:45:54.259700Z

resources are filtered out since they not supposed to contain source files. this is currently not configurable since a lot of people put the output files into the resources folder and that causes issues for shadow-cljs if it thinks those are sources again

Alexis Vincent 2021-01-04T12:51:06.260200Z

Thanks. I found the same issue with ".clam/src" What alternative paths are allowed

thheller 2021-01-04T12:53:23.261200Z

.clam/src should be fine unless the dir is hidden

Alexis Vincent 2021-01-04T12:53:47.261600Z

Thanks. Ill try again. Might have been conflating issues

Alexis Vincent 2021-01-04T13:00:43.262700Z

Excellent! Working! Is there a way to force hot-reloading further up the tree for specific namespaces? i.e. not just requiring namespaces

thheller 2021-01-04T13:14:04.262900Z

hmm?

thheller 2021-01-04T13:14:45.263500Z

:dev/always in the ns forces a recompile every time but what do you mean by "further up the tree"?

Alexis Vincent 2021-01-04T13:46:46.275500Z

so I have a case where x -requires-> y -requires-> z . When z changes I need to compute data with clojure and inject it into x . Currently the way I’m doing it is, y defs a var that evals a macro (which computes the data). Then x has a :dev/after-load hook which renders component defined in z, computed in macro in y . However, the require of yin x is stale when :dev/after-load is called (I assume because of hot reloading doesnt traverse up the tree like figwheel), so I need to do some stuff where I defer using var via wrapped function. I realise this is probably super confusing. But I was asking whether when z changes, which triggers y to be reevaluated, I could make x do the same, because I ’m assuming this would fix my issue? It’s not super important since I got things working by creating a function that returns the function I want (in x), its just a bit unclear why this is needed.

Alexis Vincent 2021-01-04T13:54:33.275900Z

Adding :dev/always fixes it!

2021-01-04T20:10:34.278100Z

I’m running shadow/watch to compile + hot reload a bundle w/ a browser target and want a hook to run a shell script after the initial build. what’s the idiomatic way to do that in shadow?

thheller 2021-01-04T20:18:49.278400Z

:build-hooks https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks

2021-01-04T20:30:51.278900Z

had seen this, but it looks like a build hook on a watch will be invoked on each rebuild if I’m reading that correctly. there’s no hook for just the first completed build at the moment, correct?

2021-01-04T20:31:10.279100Z

by the way, thanks for everything you do with shadow. absolutely lovely piece of technology

thheller 2021-01-04T20:31:31.279300Z

you can (assoc build-state ::work-done true) and then check (::work-done build-state) if you did what you intended to do

👍 1
thheller 2021-01-04T20:32:11.279600Z

well opposite order but build-state will stay arround in watch so you can store stuff in it between each cycle

thheller 2021-01-04T20:32:37.279800Z

make sure to use namespaced keys though to now clash with anything internal

2021-01-04T20:34:08.280Z

perfect. thanks for the pointers