Fork me on GitHub
#shadow-cljs
<
2022-11-10
>
jpmonettas12:11:12

hi everybody! I'm connecting to a shadow-cljs nrepl server (clojure side) and trying to get a cljs fn source like (cljs.repl/source-fn env 'cljs.core/first) but I don't have an environment. I know I can get the compiler environment for a build-id with shadow.cljs.devtools.api/compiler-env but most functions I want to use require the analysis env instead. Is there a way of calling this functions? I know how to call them with macros at macroexpansion time by using the analysis environment provided as &env but I would like to do it from the clojure repl.

thheller17:11:14

could you explain what you are trying to do exactly? I mean macros are macros and calling them as functions doesn't work

thheller17:11:42

oh nvm. source-fn is not a macro

thheller17:11:41

you can get a env via (cljs.analyzer/empty-env). it expects *cljs-ns* to be bound for the current ns though

thheller17:11:28

or I guess the default cljs.user also works depending on what you are trying to do?

jpmonettas18:11:02

nice, the empty-env did the trick. I also need to bind the cljs.env/compiler like this :

(binding [cljs.analyzer/*cljs-ns* 'cljs.user
          cljs.env/*compiler* (atom (shadow.cljs.devtools.api/compiler-env build-id))]
  (repl/source-fn (ana/empty-env) symb))

Lone Ranger20:11:08

is it possible to recover from a build failure without restarting the process?

dehli21:11:54

if you go to localhost:9630 I think you can recompile from there

Lone Ranger23:11:15

(⌐■_■) ( •_•)>⌐■-■ (o_O) what is this magical place!

😁 1
thheller05:11:44

watch will just recompile if you change something?

Lone Ranger22:11:28

but if it never connected to the repl in the first place, how will it know if I change something?

Lone Ranger22:11:52

oh, it just does, that's how