Fork me on GitHub
#cider
<
2019-10-26
>
David Reno11:10:03

I’m not positive if this is a CIDER or shadow-cljs question but I’ll try here: I was having trouble evaluating in a spacemacs code window until I came across a stackoverflow article describing how (for :target :node-script) I need to run node from the command line and evaluate the compiled code. (I also had to run npm install). This makes me feel like I’m missing some key documentation but I didn’t see anything about that here: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node Here’s the stackoverflow article that had the answer: https://stackoverflow.com/questions/58060822/how-to-connect-a-clojurescript-node-repl-to-my-node-library-shadow-cljs-project Question: Is there more documentation that I need to read about how CIDER is launching npx shadow-cljs that will mention things like “then go to the shell and manually run node on the generated JS artifact”?

David Reno11:10:12

admittedly, I haven’t read that whole doc yet, but yes, it will help me understand the architecture. I’ll read that before asking more questions. I was hoping to find a “walk-through” type of thing that mentions all the required steps in a single place.

thheller11:10:50

well the "walk-through" depends on what exactly you are building

David Reno11:10:58

I think this is a key statement in 14.3: > Regular shadow-cljs builds do not manage any JS runtime of their own so you are responsible for running them.

thheller11:10:05

can't write 50 different walkthroughs for all the possible things people may be doing 😛

David Reno11:10:40

Sorry, I’m new and don’t fully understand the flexibility.

David Reno11:10:04

In my head, there’s browser app and node.js app, but I know that’s oversimplified.

thheller11:10:38

hmm? thats exactly how it is?

David Reno11:10:52

only in my head… 😉

thheller11:10:02

you "run" the browser by opening the page

thheller11:10:13

you "run" the node.js app by running node script.js

thheller11:10:23

no difference. you are still always responsible for running things

thheller11:10:01

if you want to skip the manual "run" you use shadow-cljs node-repl or shadow-cljs browser-repl

thheller11:10:07

that runs stuff for you

thheller11:10:21

(dunno how that is intergrated with cider though)

David Reno11:10:46

that’s the part that confused me, I would have thought that CIDER would have run shadow-cljs node-repl based on :target :node-script.

thheller11:10:05

node-repl is independent from builds

thheller11:10:16

it can run entirely without a build config

thheller11:10:23

think clj or lein repl

David Reno11:10:09

maybe when I figure this out I’ll try to write a node.js quickstart that gives all the steps. Then I’ll realize how much I’m missing.

thheller11:10:34

it helps me immensely if you ask specific questions about what confuses you

thheller11:10:47

I mostly have no clue which docs to write

David Reno11:10:47

sorry, let me try again…

thheller11:10:59

but will happily add stuff if it helps people

David Reno11:10:27

rightly or wrongly, I think of CIDER as starting and connecting to any background processes required to evaluate code in the emacs buffer.

thheller11:10:30

the stuff really isn't all that complicated in my head ... but granted that I work on this stuff for years I'm not the best to judge

thheller11:10:12

can we take cider out of the equation for a second since I don't know what it does when it comes to "starting" things

thheller11:10:24

let us assume for a second that you run shadow-cljs server separately

thheller11:10:39

in a terminal and then connect to it via Cider remotely

thheller11:10:00

(this is likely what Cider is doing when you "start" things through it)

David Reno11:10:18

warning, this is losing me because I have only a noobie understanding of how these pieces work…

David Reno11:10:56

but I will study what you write here!

thheller11:10:58

hmm maybe I can guess by what cider commands you are running ...

thheller11:10:03

what do you run in emacs?

David Reno11:10:18

CIDER runs this: `[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server... `

thheller11:10:51

right .. yeah ok that starts the shadow-cljs server I mentioned

David Reno11:10:53

after I run cider-jack-in-cljs and pick “shadow” and provide the build name.

thheller11:10:26

alright. that may be the problem. does it even let you continue WITHOUT selecting a build? or is generic node-repl or browser-repl an option?

David Reno11:10:41

no, pretty sure you have to pick a build.

thheller11:10:53

ok, that should then be files as a bug for cider

thheller11:10:58

that is not how this is intended

thheller11:10:26

(I don't use emacs so I don't follow what is happening with that)

David Reno11:10:44

when cider is starting, I can pick shadow or shadow-select, I always pick shadow.

thheller11:10:56

well, ok then you pick the :node-script build you created

David Reno11:10:03

then it prompts for Select shadow-cljs build (e.g. dev):

David Reno11:10:43

right, I choose app because I have

:builds {:app 

thheller11:10:03

ok. then you have your CLJS repl ready

thheller11:10:35

but since this is a standalone build you still need to "run" the created output

David Reno11:10:40

right. Then I have to go to the shell and run node -e "require('./target/main.js')"

thheller11:10:55

yes exactly

David Reno11:10:59

as per your comment in the above mentioned stackoverflow article.

thheller11:10:57

ok and your confusion comes from why you needed to run node?

David Reno11:10:06

I was expecting to do something very “nominal” and see a brief description of the steps. I suppose I was wrong in the number of things I’ve integrated with and possible steps.

thheller11:10:37

ok. I'll try to think of something and add it to the docs

David Reno11:10:55

I’ll try too! Thanks for trying to get in the head of a beginner like me.

thheller11:10:07

thanks for explaining

👍 1