This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-13
Channels
- # announcements (4)
- # babashka (1)
- # beginners (124)
- # calva (5)
- # cider (3)
- # clara (3)
- # clerk (5)
- # clj-commons (14)
- # cljdoc (12)
- # cljs-dev (14)
- # clojure (43)
- # clojure-austin (23)
- # clojure-europe (55)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (2)
- # clojurescript (34)
- # conjure (1)
- # cursive (1)
- # data-science (28)
- # datomic (3)
- # fulcro (20)
- # gratitude (2)
- # hyperfiddle (6)
- # introduce-yourself (1)
- # jobs (5)
- # lsp (56)
- # malli (5)
- # membrane (7)
- # mount (5)
- # off-topic (16)
- # polylith (39)
- # portal (38)
- # practicalli (1)
- # rdf (1)
- # re-frame (8)
- # releases (8)
- # remote-jobs (4)
- # shadow-cljs (49)
- # sql (1)
- # xtdb (36)
How do I run 2 shadow-cljs processes / servers together?
• I am trying to run a shadow server for my code repl (let’s say build-id :dev
)
• and another instance for kaocha bin/kaocha
tests with shadow build-id :test
Up until shadow-cljs 2.19.X
this was possible. Turns out in 2.20.0
this additional check was introduced https://github.com/thheller/shadow-cljs/commit/47c3824634118f27a8276a70d6bf2da8752905bc check-for-other-instance!
which won’t let me start another instance.
Any idea for a work around for this? Or how do I check for an existing shadow process and connect to it?
> just run both builds in one instance? npx shadow-cljs watch dev test
?
I’ll try doing this but I think this would cause a bit of a mismatch in our tooling.
I have the project setup with kaocha
+ kaocha-cljs2
+ funnel
, all of which are bundled together using kaocha hooks. Then to enable proper hot reloading with kaocha-cljs2
I manually hook into the shadow-api/watch-compile!
.
By running both shadow dev and test builds together, I’ll also have to run Kaocha and funnel everytime I run the dev repl which may not be required. Also won’t get terminal logs separately.
Also when the dev repl is running we can no longer run kaochas --focus
tests or any other runs from the CLI. Everything related to koacha will need a repl interface -or- dev repl will need to be closed.
Any thoughts here? Also would a PR be accepted adding an extra option in config and making this check overridable?
We’re running the shadow server from clj (embedded). Any way for the kaocha process running in a separate process to connect to that embedded shadow server?
the check will not be overridable, the check was added for good reasons. basically shadow-cljs is not intended to run two instances per project. they WILL interfere with each other.
if you want to create a repo with that setup I can take a look. so far I don't quite understand what you are doing
Thanks I can do that.
Would super appreciate it 🙌 🙏
Process A:
cider-jack-in-clj&cljs
or clj -A:dev
launches a server using shadow-server/start!
and then does shadow-api/watch :dev
Process B:
Then I have another process for tests clj -A:tests -m kaocha.runner
which also is trying to shadow-api/watch :test
but it can’t find the shadow server running in process A
The clj
commands? The :dev
repl has some dev specific paths and debugging libraries. The :test
repl has kaocha and other libraries + test paths.
> the CLJ API never looks for a new server, only the npx shadow-cljs
command does
This is the issue because we need to use the shadow-api/watch-compile!
trigger on kaocha pre-load. So we have to use the clj api.
can you explain the last bit? I have never used kaocha, why does it need to trigger this?
I guess I can add an option to remove this check in case of two embedded servers. the reason it exists is that a server writes several "state" files (nrepl.port, http.port, etc) to .shadow-cljs
. if you start two the second will overwrite the files from the first
so in essence the first becomes a "ghost" that nothing external (ie. your editor) can find
so in case of your setup I guess thats fine since probably both test and dev are self contained with no "network access" required from external processes?
maybe I could add a special for that, that doesn't even attempt to write those files
> the CLJ API never looks for a new server, only the npx shadow-cljs
command does
💡 Maybe that ^ could be changed instead of disabling the check?
I’m running into some issues bringing shadow into an existing project. The error I am getting is
nREPL middleware: shadow.cljs.devtools.cli has no namespace
My thoughts are that my middleware config is causing the conflict. I both including and not including shadow-cljs and the middleware in my deps.edn. Here is a very minimal config that is causing the error. Can anyone place give it a look and see what I’m missing?
DEV PROFILE IN DEPS.EDN
:aliases {:dev {:exta-paths ["src/clojure/dev"]
:extra-deps {nrepl/nrepl {:mvn/version "1.1.0-alpha1"}
cider/cider-nrepl {:mvn/version "0.30.0"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}
mx.cider/tools.deps.enrich-classpath {:mvn/version "1.9.0"}
com.github.jpmonettas/flow-storm-dbg {:mvn/version "3.3.320"}
djblue/portal {:mvn/version "0.35.1"}
com.lambdaisland/classpath {:mvn/version "0.4.44"}
com.datomic/dev-local {:mvn/version "1.0.243"}
org.clojure/tools.namespace {:mvn/version "1.2.0"}
; clojurescript
org.clojure/clojurescript {:mvn/version "1.11.60"}
#_#_thheller/shadow-cljs {:mvn/version "2.22.0"}
binaryage/devtools {:mvn/version "1.0.6"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20230228"}}
:main-opts ["-m" "nrepl.cmdline" "-b" "0.0.0.0" "-p" "8675" "--middleware"
"[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}
SHADOW-CLJS.EDN
{:deps {:aliases [:dev]}
:dev-http {4040 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn troubleshoot.client/init
:entries [troubleshoot.client]}}}}}
If anyone can set me straight I’d greatly appreciate it. Lost here.I am currently working in a separate profile that just has;
:cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.11.60"}
thheller/shadow-cljs {:mvn/version "2.22.0"}
binaryage/devtools {:mvn/version "1.0.6"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20230228"}}}
Everything is all good there. Is there any added benefit to having my cljs deps combined with my other dev dependencies? Or is heading forward with a cljs only profile actually a better move?Why do you have shadow-cljs dep commented out in the :dev
profile?
#_#_thheller/shadow-cljs {:mvn/version "2.22.0"}
I was troubleshooting. It was giving me the same error with and without ignoring the shadow-cljs in the deps profile. I was a bit confused with a recommendation to run shadow standalone in the docs. The whole thing gives me a bit of confusion for a moment every time. Imagine it’s a me thing. At any rate, I’m quite pleased with putting all my cljs deps in it’s own profile and my clj dev deps separate. Everything is working as I expect and workflow is quite enjoyable. Good times. CHEERS!
Hello, I just updated from 2.21.0
to 2.22.2
and I got this The required namespace "
in my code. So, is there some lib removed from shadow-cljs
?
yes, and no. This version of shadow-cljs bumps the underlying version of the google-closure-lib, which provides http://goog.net.cookies. goog.net.cookies got deprecated (and then removed) in favour of http://goog.net.Cookies.
I hit this the other day if you are interested https://clojurians.slack.com/archives/C0620C0C8/p1678379726699909
it is a bit more involved than just changing the cookies to Cookies... you need to use http://goog.net.Cookies/getInstance now
I'm a bit confused on how externs inference and shadow-cljs work together. If I import a constructor from JS code and use it in a lexical binding, does the binding get the ^js
meta? If so, do we still need goog.object.set
or can we safely use set!
the gist is if you get a warning, add a hint. if you get no warning you should be safe.
No warning. Here is an example:
(ns demo
(:require ["js-code" :refer [SomeObject]]))
(defn example []
(let [obj (SomeObject.)]
(set! (.-property obj) val)))
I haven't checked that. The code seemingly works under both development and production builds
I was just wondering if what I'm doing is a bad idea and whether I should prefer goog.object/set here
Has anyone run into an issue where running
npx shadow-cljs stop
Does not actually shut down the server?
I get:
shadow-cljs - server not running
But i have to manually determine whats running on port 9630
and kill it, and then
npx shadow-cljs start
will start it back up on the correct port
I tried hardcoding the port in my config, etc. but cant get it to stop the service automatically :thinking_face:do you delete the .shadow-cljs
directory in some sort of clean
task maybe? it determines the state of the server from the files in that dir.
otherwise not sure. I generally do not recommend running the background server. npx shadow-cljs server
and keeping that open lets you ctrl+c it anytime
i probably did delete it, but thought itd be fine after a fresh start
command -- for some reason seeing this happen every time, even without a clean -- but good to know! I can probably look through that dir to see if state is incorrect somewhere
good to know about the background server! will try that workflow instead, thanks
btw never delete the .shadow-cljs
dir. it also holds all caches, there should be no reason to ever delete it all.
noted! Yeah I had an issue sometime where i got into a crazy state, and wanted to rule out the shadow cache as the issue, but will avoid going forward