I am trying to understand how I could use nrepl in a node-script target. Any pointers to help/tutorial?
depends on what you mean by "nrepl in a node-script". do you mean starting your own nrepl server or using the shadow-cljs nrepl server to talk to the node-script?
using the shadow-cljs server
atleast that's what I thought to do. I'm still quite new to clojure/cljs
then you use it like any other REPL?
i want to attach it to cursive
then you connect to the shadow-cljs server (using the .shadow-cljs/nrepl.port
file)
and then (shadow/repl :the-build-id)
to switch that connection to CLJS
ah ok
hm it seems i have another problem in cursive too
maybe i need to figure that out first
just select the proper module
you also want to remote connect, not run a local repl
ok
i dont understand where i would chose the proper module
you don't need that. use the "Use port from nrepl file"
for some reason, when i do that i cant chose project
is there a step i missed_
?
I don't know? how did you create the project in cursive?
i created it with npx i believe
and just opened it in cursive
ahh
thanks!
okay, now I finally found time to test this @thheller and it works. however when i try to switch workspace in i get "No avvailable JS runtime"
so I guess i'm missing something?
yeah, you need to run your node-script output
ok so ill do that manually_
?
don't know what you are building but probably yes 😉
if you just want a node repl use (shadow/node-repl)
instead
(from the initially connected Cursive REPL)
i would like to have the same concept that we have in the browser where i can reload code but keeping state
is that possible?
sure, but only via node-script and running the thing manually
node-repl doesn't do hot-reload
i have setup node-script and it's building
but it doesnt run the code
what do you mean by that? you are supposed to run it?
:node-script
gives you the file in :output-to
yes
you then run node whatever.js
what this process does is completely under your control depending on what you do in main
?
what are you trying to build?
a service that is monitoring crypto exchanges
basically a script
ok something that is long running?
or just a script that runs once for a second or whatever and then exits?
yes
long running
ok fine. then when you run that you can REPL into it
it should log a message on startup "shadow-cljs ready" or so
yep that works
and hot reload?
just rebuilding?
while keeping the process alive
same way as the browser targets https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload
https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html
no difference, same setup (just see the main
fn as the init
fn described in the post above)
okay thanks!
ill read through it
thanks for your patience, it works like i want it to now
I keep getting Stale Output! on this Chrome Extension I am working on. Even when I clear all the js
, out
, manifest.json
, .shadow-cljs
, node_modules
etc
I'm wondering if there is some weird Chrome caching bug happening here.
Hard restart of the computer seems to fix it when this happens.
Has happened to me several times over the course of a few days now.
if you restart the build for any reason you need to reload the extension in chrome
hmm I am pretty sure I do this. Like hitting refresh everywhere.
in <chrome://extensions/> hit the reload thingy
I even removed the unpacked extension and loaded it again. Maybe I'm missing something. Will go slower next time and write down all the steps I take to see if I do something silly.