Fork me on GitHub
#shadow-cljs
<
2019-04-06
>
thheller10:04:20

@icyiceling184 shadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code).

thheller10:04:27

something seems to be missing from the steps you posted

thheller10:04:45

(shadow/repl :app) is not possible unless a watch for app is running

thheller10:04:55

so you maybe have that running elsewhere?

thheller10:04:22

but yeah just using node-repl is fine and recommended

anovick13:04:00

@thheller Thank you for the prompt reply! After having processed the detailed information you provided me I was able to reach a setup with the shadow-cljs watching the build and being able to connect to a node process via nREPL. Apparently these were the points I needed to know: 1. > shadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code). I now understand that there are multiple ways to start up a Node.js process: - On terminal: shadow-cljs node-repl - On terminal: node out/demo-scripts/script.js - In a REPL at shadow.cljs ns: (shadow.cljs.devtools.api/node-repl) Therefore the quote on the shadow-proto-starter link I gave above is a bit misleading in instructing to use the third option without providing context on the other options available. 2. > (shadow/repl :app) is not possible unless a watch for app is running On the steps that I had followed above, this command was absent, so I can see why (shadow/repl :app) failed for me. At this point, having watch compile my main namespace on changes isn't actually doing anything for me aside from spitting warnings:

(process.on "SIGINT" on-signal-interruption)
 Use of undeclared Var demo.script/process

 (process.getuid)
 Use of undeclared Var demo.script/process
I was also trying to setup :devtools config to work, but didn't get a lot of success there out of the box, so i'm gonna let it go for now. So right now I don't have a good reason to have watch running, so I'm going to avoid that and just connect to a Node.js process and re-evaluate the namespace i'm working on upon changing the file. I also have start, stop functions that do some I/O for me which I have to do before and after re-evaluation. Moving forward I might want to set that up with the :before-load and :after-load build hooks. When I decide to try do that, and am stuck again I'll post a minimal reproduction to try and pinpoint the problem I ran into.

thheller13:04:58

(process.on ...) is not valid code. that should be (js/process.on ...)

thheller13:04:13

@icyiceling184 you must differentiate between the REPLs a bit. There is either a *generic* REPL like node-repl or browser-repl. These are not coupled to a specific build.

thheller13:04:39

then there is a build REPL where you can REPL into a specific build configued in your :builds

thheller13:04:26

the difference between the two is basically that the build REPLs also do other stuff on their own (eg. running your :main function, hot-reload, etc)

thheller13:04:39

the generic REPLs do nothing on their own, only what you make them do

thheller13:04:59

so node out/demo-scripts/script.js this doesn't start a node REPL. that starts a build REPL, your build just happens to be running in node. so yes it is running a node REPL but that is not the same thing as node-repl

thheller13:04:06

I know its confusing ...

thheller13:04:52

so basically if you want hot-reload use a build and REPL into that

thheller13:04:56

if you don't just use node-repl

anovick14:04:27

@thheller Re: > (process.on ...) is not valid code. that should be (js/process.on ...) Hmm I can see that the build compiler doesn't warn about js/process. however the evaluation seems to work just fine when I don't use js/ for process object:

process.version
=> "v10.9.0"
js/process.version
=> "v10.9.0"
> I know its confusing ... Yep! very confusing 🙂 > so basically if you want hot-reload use a build and REPL into that > here is a minimal setup if you want to try Thanks! it's so useful to have this setup. *UPDATE*: The :devtools configs for :before-load-async and :after-load are working for me! Very nice... my workflow is now so much easier with performing some start / stop functions that do some IO (right now for me it's mounting some directory on start and unmounting it on stop, but the same could work for other things like starting up a server and stopping it). I would like to write about this sometime

thheller14:04:40

@icyiceling184 although process.version works it should be avoided since it won't work in different contexts. if you want to use "global" node variables like process you should use them via js/process.

👍 4
caleb.macdonaldblack23:04:02

My shadow-cljs browser project seems to be having some compatibility issues on older versions of safari 7 & 8. Could anyone point me in the right direction as to what I should look into in order to understand more about this? Sorry if this is the wrong channel for this question