Fork me on GitHub
#inf-clojure
<
2022-12-16
>
Jason03:12:51

for clj I use C-c C-k to invoke (do (load-file "filepath")(in-ns 'namespace)) to reload a file and switch to its' namespace. I'm having difficulty figuring out an equivalent thing for cljs. If I run load-file and then in-ns it works but it leaves an extra []\n in the repl output so I've been trying to sort it out. In the meantime I was wondering why inf-clojure has these as separate commands, do people usually load and set-ns as different commands or is there a different common workflow?

dpsutton05:12:11

I just require the namespace. I’m not sure that clojurescript has a notion of load file?

dpsutton05:12:47

and using load-file means each form is essentially fed into a repl so you don't get line number metadata and source therefore won't work

dpsutton05:12:54

it seems cljs does have load-file. Interesting that you see extra input. If you just type in (load-file "whatever") in the repl do you see the extra input?

Jason02:12:25

no, it just goes to the next line :thinking_face:

Jason02:12:25

(do (load-file "whatever")) gives goog.nodeGlobalRequire is not a function\n:repl/exception!

dpsutton02:12:53

That sounds like a problem with your code the

dpsutton02:12:00

Can you require the file?

Jason02:12:46

yeah. If I'm running a watch process is just require effectively the same thing?

dpsutton02:12:13

Not sure what you mean. If you just execute (require ‘my.ns) what happens?

Jason03:12:01

sorry, I was thinking calling require explicitly would change my repl ns

Jason03:12:35

what I was supposed to be asking is if I'm running a watch process is just in-ns effectively the same thing

dpsutton03:12:43

You’ll always want the namespace required at least once before doing that

dpsutton06:12:22

the great thing about inf-clojure is that there's not much it does on top of a repl. So if you are seeing that output it is highly likely that that is just what the repl itself is returning

Jason02:12:34

yeah, I didn't anticipate fixing the issue here, I'm just interested in how other people do the reload and switch namespace workflows