Fork me on GitHub
#shadow-cljs
<
2021-01-04
>
Alexis Vincent12:01:26

@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* .

thheller12:01:54

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 Vincent12:01:06

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

thheller12:01:23

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

Alexis Vincent12:01:47

Thanks. Ill try again. Might have been conflating issues

Alexis Vincent13:01:43

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

thheller13:01:45

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

Alexis Vincent13:01:46

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 Vincent13:01:33

Adding :dev/always fixes it!

mss20:01:34

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?

mss20:01:51

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?

mss20:01:10

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

thheller20:01:31

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

👍 3
thheller20:01:11

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

thheller20:01:37

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

mss20:01:08

perfect. thanks for the pointers