Fork me on GitHub
#shadow-cljs
<
2021-04-29
>
Fredrik Andersson09:04:56

I am trying to understand how I could use nrepl in a node-script target. Any pointers to help/tutorial?

thheller09:04:14

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?

Fredrik Andersson09:04:29

using the shadow-cljs server

Fredrik Andersson09:04:19

atleast that's what I thought to do. I'm still quite new to clojure/cljs

thheller09:04:21

then you use it like any other REPL?

Fredrik Andersson09:04:02

i want to attach it to cursive

thheller09:04:26

then you connect to the shadow-cljs server (using the .shadow-cljs/nrepl.port file)

thheller09:04:37

and then (shadow/repl :the-build-id) to switch that connection to CLJS

Fredrik Andersson09:04:24

hm it seems i have another problem in cursive too

Fredrik Andersson09:04:47

maybe i need to figure that out first

thheller09:04:00

just select the proper module

thheller09:04:27

you also want to remote connect, not run a local repl

Fredrik Andersson09:04:26

i dont understand where i would chose the proper module

thheller09:04:19

you don't need that. use the "Use port from nrepl file"

Fredrik Andersson09:04:32

for some reason, when i do that i cant chose project

Fredrik Andersson09:04:46

is there a step i missed_

thheller09:04:44

I don't know? how did you create the project in cursive?

Fredrik Andersson09:04:54

i created it with npx i believe

Fredrik Andersson09:04:02

and just opened it in cursive

Fredrik Andersson14:04:12

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"

Fredrik Andersson14:04:35

so I guess i'm missing something?

thheller14:04:29

yeah, you need to run your node-script output

Fredrik Andersson14:04:40

ok so ill do that manually_

thheller14:04:56

don't know what you are building but probably yes 😉

thheller14:04:11

if you just want a node repl use (shadow/node-repl) instead

thheller14:04:25

(from the initially connected Cursive REPL)

Fredrik Andersson14:04:03

i would like to have the same concept that we have in the browser where i can reload code but keeping state

Fredrik Andersson14:04:16

is that possible?

thheller15:04:11

sure, but only via node-script and running the thing manually

thheller15:04:15

node-repl doesn't do hot-reload

Fredrik Andersson15:04:10

i have setup node-script and it's building

Fredrik Andersson15:04:26

but it doesnt run the code

thheller15:04:50

what do you mean by that? you are supposed to run it?

thheller15:04:02

:node-script gives you the file in :output-to

thheller15:04:12

you then run node whatever.js

thheller15:04:28

what this process does is completely under your control depending on what you do in main?

thheller15:04:56

what are you trying to build?

Fredrik Andersson15:04:22

a service that is monitoring crypto exchanges

Fredrik Andersson15:04:35

basically a script

thheller15:04:48

ok something that is long running?

thheller15:04:08

or just a script that runs once for a second or whatever and then exits?

thheller15:04:25

ok fine. then when you run that you can REPL into it

thheller15:04:41

it should log a message on startup "shadow-cljs ready" or so

Fredrik Andersson15:04:05

while keeping the process alive

thheller15:04:32

no difference, same setup (just see the main fn as the init fn described in the post above)

Fredrik Andersson15:04:47

ill read through it

Fredrik Andersson15:04:32

thanks for your patience, it works like i want it to now

👍 3
grounded_sage19:04:24

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

grounded_sage19:04:46

I'm wondering if there is some weird Chrome caching bug happening here.

grounded_sage19:04:01

Hard restart of the computer seems to fix it when this happens.

grounded_sage19:04:24

Has happened to me several times over the course of a few days now.

thheller19:04:31

if you restart the build for any reason you need to reload the extension in chrome

grounded_sage20:04:44

hmm I am pretty sure I do this. Like hitting refresh everywhere.

thheller20:04:29

in <chrome://extensions/> hit the reload thingy

grounded_sage20:04:51

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.