This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-14
Channels
- # adventofcode (36)
- # announcements (5)
- # atom-editor (2)
- # babashka (19)
- # beginners (98)
- # biff (7)
- # calva (25)
- # cider (1)
- # cljdoc (10)
- # clojure (70)
- # clojure-czech (1)
- # clojure-dev (14)
- # clojure-europe (79)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-seattle (3)
- # clojure-uk (2)
- # clojurescript (28)
- # community-development (44)
- # core-typed (3)
- # cursive (2)
- # datalevin (5)
- # datascript (5)
- # datomic (1)
- # dev-tooling (12)
- # emacs (14)
- # honeysql (3)
- # humbleui (11)
- # introduce-yourself (1)
- # java (1)
- # kaocha (1)
- # lsp (3)
- # malli (21)
- # matcher-combinators (2)
- # nbb (7)
- # off-topic (15)
- # portal (12)
- # reitit (4)
- # releases (1)
- # shadow-cljs (59)
- # sql (8)
- # tree-sitter (3)
I'm trying to figure out how to setup a project where deps.edn
is used for dependencies and add nrepl middleware (#portal in this case). Failing so far, with a message nREPL middleware: shadow.cljs.devtools.cli has no namespace
. Details in 🧵
My deps.edn
looks like so:
{:paths ["src" "test" "env/dev"]
:deps {binaryage/devtools {:mvn/version "1.0.6"}
djblue/portal {:mvn/version "0.35.0"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
reagent/reagent {:mvn/version "1.1.1"}
thheller/shadow-cljs {:mvn/version "2.20.14"}}
:aliases {:portal {:extra-deps
{djblue/portal {:mvn/version "0.35.0"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware"
"[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware,portal.nrepl/wrap-portal]"]}}}
And shadow-cljs.edn
:
{:deps {:aliases [:portal]}
:dev-http
{8020 "public"}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:init-fn main.core/init}}
:build-hooks [(portal.shadow.remote/hook)]
:devtools {:preloads [devtools.preload
portal.setup]}}
:test {:target :node-test
:autorun true
:output-to "target/node-test/tests.js"
:ns-regexp ".*-test$"
:build-hooks [(portal.shadow.remote/hook)]
:devtools {:preloads [devtools.preload
portal.setup]}}}}
Running this:
$ npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :app :test
shadow-cljs - config: /Users/pez/Projects/shadow-portal/shadow-cljs.edn
shadow-cljs - starting via "clojure"
nREPL middleware: shadow.cljs.devtools.cli has no namespace
Jack-in process exited. Status: 2
@U0ETXRFEW you cant set :main-opts
in an alias used by shadow-cljs
Thanks. I'll poke around some with this. The last option I think I can't use because I'm not connecting to that nREPL server, but to the one started by clojure
.
yeah but you need to understand that the alias option with main-opts it starting its own new nrepl server
it doesn't make sense to start multiple, so just use the one provided by shadow-cljs
There are some constraints here imposed by assumptions that Calva makes. And by how output is routed for the different repls.
To start with the latter. If I start the REPK with clojure and then start the shadow watchers and cljs-REPL from that REPL, then stdout is routed to the REPL and gets mixed up with REPL output. I prefer to have this output in the terminal where I start the REPL. This happens if I start shadow-cljs and let it start the REPL using clojure
. I don't know why this works differently, just that it does.
As for the assumptions. Calva does actually connect to the nREPL server started by shadow-cljs if I choose the shadow-cljs jack-in option. (I don't know why I thought differently.)
So, in summary. Moving the portal nrepl middleware config to shadow-cljs.edn made things work exactly as I want them to. With the test runner output in the terminal and all. 🎉
Thanks again! I'll try to encode these learnings in an example project. And I will update the Calva docs. I would have had helped from that this time. 😃
what you described doesn't make sense? you are starting via clojure but then don't use it?
If I manage dependencies using tools-deps, then shadow-cljs starts the REPL using clojure
. And also will make it start an nREPL server. I can't use that one with Portal nREPL middleware for reasons you have helped me understand here. But that's fine, since Calva will connect to the nREPL server started by shadow-cljs. Does this make sense?
Here's a template/example project wired to use start and use Portal for taps and evaluation results from both Clojure and ClojureScript REPLs. https://github.com/PEZ/shadow-portal
the reason the tests taps don't show is because the test runtime doesn't connect to the REPL at all
Hi, I'm getting this error after updating shadow-cljs. Any ideas?
Exception in thread "main" Syntax error compiling at (shadow/build/closure.clj:80:3).
Caused by: java.lang.RuntimeException: Unable to find static field: ECMASCRIPT_NEXT_IN in class com.google.javascript.jscomp.CompilerOptions$LanguageMode
Here is my setup;
....
[thheller/shadow-cljs "2.20.14" :exclusions [nrepl commons-codec com.cognitect/transit-clj org.clojure/tools.reader]]
[com.google.javascript/closure-compiler-unshaded "v20221102"]
[org.clojure/clojurescript "1.11.60" :exclusions [org.clojure/tools.reader]]
....
although that is the version it should be using the error indicate that this is not the version you are getting
The interesting part is, it works for my co-workers. I've also deleted .m2/repository/com/google/javascript/closure-compiler-unshaded to avoid conflict
any possible solutions that you could have?
open a plain REPL, then (:require '
and (
Will do thanks 🙂
Here's a template/example project wired to use start and use Portal for taps and evaluation results from both Clojure and ClojureScript REPLs. https://github.com/PEZ/shadow-portal
What can I do to start a JS runtime for a :test
build? In ^ that ^ project tests are set to :auto-run
and that works great. But I can't reach the build via the REPL.
the test targets are for automated testing (ie. CI) and you dont want to keep those processing running due to some connected websocket
If I can I make a node repl autrun the tests for me, that would work for me. I'll see if I can make that happen.
I mean I find running all tests after every change a little frustrating myself but do what you want
So, what I actually want to achieve here is to have taps happening from :auto-run
tests to end up in Portal. I don't strictly need a REPL for that, but that would make it easier to examine the environment. So, then my next question is, can I hope to ba able to add a tap to these test runs?
@U1G869VNV knows this better than me, but as I understand it, Portal listens to a port and then the user registers a tap that submits to this port. https://github.com/djblue/portal/tree/master/src/portal/shadow When I do that from the browser app the tap reaches portal, but from the :node-test
target this doesn't happen, even though it uses the same port. This is where I lose track of it and was thinking a REPL might help me.