This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-19
Channels
- # announcements (15)
- # babashka (4)
- # beginners (55)
- # calva (92)
- # cider (70)
- # circleci (1)
- # clj-kondo (136)
- # cljdoc (2)
- # clojars (11)
- # clojure (48)
- # clojure-australia (1)
- # clojure-europe (30)
- # clojure-nl (3)
- # clojure-sweden (2)
- # clojure-uk (7)
- # clojurescript (40)
- # conjure (5)
- # core-async (11)
- # cursive (55)
- # data-science (1)
- # datomic (10)
- # degree9 (2)
- # development-containers (15)
- # events (1)
- # fulcro (14)
- # gratitude (13)
- # helix (5)
- # lsp (35)
- # malli (10)
- # meander (18)
- # off-topic (24)
- # pathom (13)
- # polylith (12)
- # practicalli (6)
- # re-frame (13)
- # reagent (33)
- # reitit (4)
- # remote-jobs (1)
- # shadow-cljs (13)
- # spacemacs (31)
- # specter (1)
- # stepwise (2)
- # tools-deps (19)
- # vim (1)
- # xtdb (7)
How would i get a Nrepl to a shadow-cljs build that's targeting a node-library:
{:exports-var blah
:target :node-library
:output-dir "out/backend/"
:output-to "out/backend/main.js"}
I tried connecting via cider-connect-cljs shadow-cljs and node, both said the connected by neither let me eval ed the code.shadow always starts an nrepl server right? It should just be there. just cider-jack-in and select the build you care about and it should just work
there is a project script that starts the shadow and the repl i can connect to. I was able to use cider-connect-cljs for the frontend part but not the backend. I tried the node and shadow connection option. The node one throws an execution error:
;; ClojureScript REPL type: node
;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
;;
Execution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:30).
Assert failed: (keyword? repl-env)
the node option starts a cljs.main repl who's repl env is cljs.repl.node
> (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
thanks. Also, in case it's part of the issue. What is the difference between "shadow" and "shadow-select"?
trying to connect with with repl type: shadow gives me a no build id: app. Which is confusing because neither my /.shadow-cljs/config.edn or my project-cljs.edn mentions a build with id app.
1. Unhandled clojure.lang.ExceptionInfo
no build with id: :app
{:tag :shadow.cljs.devtools.config/no-build, :id :app}
config.clj: 156 shadow.cljs.devtools.config/get-build!
config.clj: 154 shadow.cljs.devtools.config/get-build!
the only mention of an app is the modules key e.g :modules {:app {....i think shadow-select is the "connect" version of connecting to a running shadow instance
hmm maybe a dir-locals configuration is getting picked up.
yeah clear those out. absolutely should be given a list of choices. and it parses your shadow-cljs.edn file to list the available builds
Yea. that must be it, as your right, it wasn't giving me a choice of build. I'm perplexed because there isn't a dir-locals file in the project.
i'm not sure what you mean. This is the information i'm reading on my end:
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
;;
Execution error (ExceptionInfo) at shadow.cljs.devtools.config/get-build! (config.clj:156).
no build with id: :app
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build completed. (229 files, 0 compiled, 0 warnings, 1.14s)
shadow.user>
shadow.user> (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :backend) (shadow/nrepl-select :backend))
To quit, type: :cljs/quit
[:selected :backend]No available JS runtime.
See available JS runtime.
The no js runetime error makes sense to me backend targets a node-librarythe error text seems to be missing a newline https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting
if you want to REPL into :backend
you need to actually start it yourself. meaning the actual node process.
as in, i can't cider connect?
can't comment on any cider related things but I think no. you still connect to shadow-cljs as normal
but you backend needs to be started and then that one will also connect to shadow-cljs which will then let you talk to that one in the REPL
if you don't actually need any of this use the built-in node-repl. don't know how you do that for cider but that one manages the node process for you
cider allows you to choose that build. it looks at all of the builds in the shadow-cljs.edn and also includes browser and node repls
and i believe what @thheller is saying is that if you use the node-repl
included repl, shadow will start the node process for you. If you are using :npm-lib
, shadow will compile your stuff into a js file (`:output-to` i think) and then you need to manually run node that-file.js
and then your repl will have its runtime. The same way you need to load your webapp before you can use the frontend repl
ah, makes sense. something called nodemon is calling the outputed js file.
:node-library
outputs are not meant to be called directly by anything? they are meant to be imported by something else? hence the "library" name?
but again: if you just want a node REPL use node-repl, not :backend
. you can still start your backend from there just fine, but you don't have to manage your node process?
the build id is :backend.
where as the REPL for :node-script
or :node-library
is a REPL embedded in your-actual-program
, like starting your own nrepl
server or something (not really, just for comparison sake)
node-repl
is not tied and does not care about a build id. it is standalone and generic, just like clj
or lein repl
really need to find a better way to explain this ... it really isn't all that complicated 😛
one point of confusion is your talking about node-repl like thats a script/program i should be aware of. As where i thought what we were saying is that i was going to run node somefile.js
and then tell my nrepl server to connect to it with a node protocol.
again .. I don't have the slightest clue what cider/emacs looks like these days. I'm talking about it in terms of shadow-cljs and what the docs there talk about (hopefully).
ok there is a shadow/node-repl command.
as in shadow-cljs node-repl
or shadow-cljs cljs-repl backend
(I would assume there is a comparable option for those in emacs but don't know)
and the only thing that CIDER ever does is this command, parameterized over the build name
(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
i actually haven't started up CIDER in a while now. let me go see exactly what it does
;; Startup: /usr/local/bin/npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.9 server
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/node-repl))
doesn't matter these days and is actually required (not used still, just got tired of trying to "fake" it)
faking it was just too problematic, now its just added as normal but the shadow-cljs middleware places itself before piggieback. so that never actually does anything but is still there to make cider happy and stuff
@dpsutton what did you run to get it to run shadow/node-repl?
i must have some global configuration somewhere that's setting things. ugh.
but no matter. it seems like you can just call (shadow/node-repl)
yourself when it throws an error with trying to do :app
That seems to work. thanks a lot. Will shadow watch/recompile a node target like it does a browser one? I realize were in the cider channel 🙂
yes, although reloading is often a bit trickier. depends on how much state you keep in those nasty node callbacks and such 😉
i added the server startup commands and the cljs repl startup commands at the top of the repl so you'd see you just get a regular clj repl and then use shadow's api commands to "upgrade" the repl into a cljs repl.
there's no magic. it's just getting a clojure repl and running (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/node-repl))
that's just clojure code
The offending configuration problem was coming form my spacemacs/emacs-custom-settings in my init file. I don't recall it every causing this type of issue before. i just removed it as it's auto generated.