This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-21
Channels
- # announcements (17)
- # babashka (2)
- # beginners (51)
- # calva (14)
- # clojure (30)
- # clojure-europe (12)
- # clojure-uk (3)
- # clojurescript (22)
- # cursive (10)
- # defnpodcast (1)
- # etaoin (1)
- # fulcro (7)
- # graalvm-mobile (3)
- # music (1)
- # obb (4)
- # podcasts-discuss (1)
- # sci (2)
- # shadow-cljs (37)
- # spacemacs (3)
- # xtdb (16)
Hi everyone, I’ve gone through the shadow-cljs quickstart guide in the GitHub repo README and got the desired message in the browser console. Next, I’d like to introduce deps.edn
to the project. I’m having some difficulty in jacking in after adding deps.edn
.
System details:
OS: WSL2
Java version: OpenJDK 11.0.15
Clojure CLI version: 1.11.1.1113
With only shadow-cljs.edn
in the project, said file contents are:
;; shadow-cljs.edn
{:source-paths ["src/dev"
"src/main"
"src/test"]
:dependencies []
:dev-http {8080 "public"}
:builds {:frontend {:target :browser
:modules {:main {:init-fn }}}}}
At this point, jacking in with Calva using the “shadow-cljs” project type, which both starts and connects to the “:frontend” build works like a charm. As mentioned in the first paragraph, I’ve been having difficulty with introducing deps.edn
to the project. I think it has something to do with starting the build and having the REPL connect to it.
Add deps.edn
to the main project directory with the following contents:
;; deps.edn
{:paths ["src/main"
"src/dev"
"src/test"]
:aliases
{:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.19.0"}}}}}
Change shadow-cljs.edn
to:
;; shadow-cljs.edn
{:deps {:aliases [:cljs]}
:dev-http {8080 "public"}
:builds {:frontend {:target :browser
:modules {:main {:init-fn }}}}}
Jacking in with Calva at this point leads to an error containing “Failed starting cljs repl for build: :frontend. Is the build running and connected?” The Calva Connection Log also provides information, including: “shadow-cljs has not been started yet!” and “If you have a shadow-cljs server or watch running then you are not connected to that process.”
The build doesn’t seem to have been started. What if we run npx shadow-cljs watch frontend
and then tried connecting to the REPL? Same error messages as before.
I’d appreciate any guidance on how to proceed to connect Calva to shadow-cljs with deps.edn
present. Thanks in advance!Hello, thanks for asking about this! If you do, on the command line:
shadow-cljs watch :frontend
do you get a REPL prompt?Thanks for your response. 😄
I do not get a REPL prompt from npx shadow-cljs watch :frontend
alone. To get a REPL prompt, running npx shadow-cljs cljs-repl :frontend
in a separate terminal window does the trick.
(From https://shadow-cljs.github.io/docs/UsersGuide.html#build-repl)
Yes, of course, I forgot about that step. 🙂 Looks like it should work then. You should still be using shadow-cljs as the project type when you jack-in, btw. Are you?
I was not. Making use of that type once more worked! 🎉 Thank you @U0ETXRFEW. 😁
Where before I made use of the “shadow-cljs” project type, after adding in deps.edn
I figured the project type should now be “deps.edn + shadow-cljs”. When should that type be used?
So, you have configured shadow-cljs to use deps.edn for dependency resolution. You can see it when you start the REPL. Something like:
starting via clojure
Some use deps.edn to start shadow-cljs instead, and that's when you would use the other config.I’ll have to look into that approach, not familiar with it yet. Which is preferred for a fullstack project?
Can i ask a favor? We are trying to populate https://ask.clojure.org with Calva questions, so that it shall get easier to google for this kind of knowledge. Would you consider asking your question there? You can add at the end that after the update, you are switching which project type you use at Jack-in. Then I can post an answer elaborating a bit on the choices.
I prefer to try stick with shadow-cljs as the project build tool for development. I guess there are situations when you need to do it some other way, but I can't really name any such situation right now.
Big fan of increasing accessibility for this kind of thing! 😁 Question asked here: https://ask.clojure.org/index.php/11901/calva-project-type-shadow-cljs-vs-deps-edn-shadow-cljs
Thanks! I notice that the same strange thing with some missing characters in the first shadow-cljs.edn
file as I see in the thread start here is also missing in the post on the Ask site.
Ah, the dangers of copy-pasting from editors… Should’ve taken it to Notepad first. 😝 Corrected both here and on AskClojure. Thanks for your help!