This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-06
Channels
- # announcements (1)
- # bangalore-clj (3)
- # beginners (73)
- # boot (1)
- # calva (88)
- # cljdoc (13)
- # cljsrn (1)
- # clojure (65)
- # clojure-finland (1)
- # clojure-spec (14)
- # clojure-uk (1)
- # clojurescript (50)
- # core-async (4)
- # datavis (6)
- # duct (2)
- # figwheel-main (1)
- # off-topic (15)
- # pedestal (16)
- # planck (11)
- # re-frame (3)
- # shadow-cljs (19)
- # yada (3)
@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).
@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.@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.
then there is a build REPL where you can REPL into a specific build configued in your :builds
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)
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
https://github.com/minimal-xyz/minimal-shadow-cljs-nodejs here is a minimal setup if you want to try
@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@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.
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