Fork me on GitHub
#calva
<
2022-05-21
>
Stef Coetzee17:05:02

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!

pez18:05:46

Hello, thanks for asking about this! If you do, on the command line:

shadow-cljs watch :frontend
do you get a REPL prompt?

Stef Coetzee19:05:42

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)

pez19:05:36

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?

Stef Coetzee19:05:12

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?

pez19:05:43

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.

😲 1
pez19:05:32

You are not the only one falling into this trap. It's rather confusing with the naming.

Stef Coetzee19:05:03

I’ll have to look into that approach, not familiar with it yet. Which is preferred for a fullstack project?

pez19:05:49

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.

❤️ 1
pez19:05:20

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.

👍 1
Stef Coetzee19:05:53

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

🙏 1
pez19:05:20

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.

pez20:05:52

I've posted an answer now. 😃

Stef Coetzee04:05:05

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!