Fork me on GitHub
#spacemacs
<
2022-11-04
>
2FO00:11:34

Howdy all, I'm struggling to set-up a working browser repl with shadow-cljs. My app has a nrepl connection on port 3333. Here's my workflow: 1. Open nrepl prompt , ' 2. Select cider-connect-cljs 3. Select localhost 4. Select my-app:3333 5. Select shadowfrom the nrepl list The *Messages* buffer states [nREPL] Direct connection to localhost:3333 established. However, evaluating the core.cljs buffer hangs indefinitely on Loading /my-app/src/app/core.cljs... and evaluating a function e.g (js/alert "hello") has no effect in the browser.

Drew Verlee00:11:00

Is your project public? I can diagnose it faster looking at it.

Drew Verlee00:11:54

How are you injecting the nrepl middleware/code/libraries/deps into your app so that cider can connect to it?

Drew Verlee00:11:44

I sometimes have to go to the shadow cljs browser tab that has the server info and force a compile, then browser app before it will let me eval something.

2FO00:11:37

The repo's not yet public, I'm afraid. RE: nrepl injection method, how would I go about determining that? I'll go ahead an include the shadow-cljs.edn on the off chance that helps:

2FO01:11:09

{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :target :browser}
  :cards {:asset-path "/js"
          :modules {:main {:init-fn app.cards/main}}
          :compiler-options {:devcards true}
          :output-dir "public/js"
          :target :browser}
  :test {:ns-regexp "app.cards"
         :output-to "out/test.js"
         :target :node-test}
  :e2e {:ns-regexp "e2e.*"
        :output-to "out/e2e.js"
        :target :node-test}}
 :dependencies [[reagent "0.8.1"]
                [devcards "0.2.6"]]
 :dev-http {4200 "public"}
 :nrepl {:port 3333}
 :source-paths ["src"]}

Drew Verlee01:11:37

Check the links above as well as reading the cider docs about shadow, that's a good starting point for understanding. But when you start shadow it needs a cider client lib. Cider Jack in, will add it for you. If you connect, then you have to add it. No way is better, but if emacs/cider adds it for you then the client lib will sync with the server.

2FO01:11:43

I'll do some digging, thanks for the tips

Drew Verlee01:11:38

Yeah. After reading that once, feel free to ask again. It's not easy.