Fork me on GitHub
#shadow-cljs
<
2019-04-05
>
flowthing08:04:14

I inherited a project that has functions like this in dev.clj:

(defn start []
  (shadow.server/start!)
  (shadow/watch :app)
  (start-app))

(defn stop []
  (app/stop)
  (shadow.server/stop!))
However, my understanding is that restarting the shadow-cljs server should only be necessary if dependencies change. Is that correct? In other words, it would be better to start the shadow-cljs server via npx shadow-cljs server app and then just start/stop the shadow-cljs watcher in the start and stop functions?

flowthing08:04:59

I don't know that there's a downside to restarting the shadow-cljs server, though.

thheller09:04:00

@flowthing yes only changing dependencies should require a restart. stop! stops all running watch processes an in turn kills all REPL state/connections

thheller09:04:45

you can still use the embedded server. just don't call stop!

flowthing09:04:46

All right, thanks. The way this project is set up is that you're supposed to call lein repl :headless, then connect to the nREPL with your IDE, and then run (start). This way (stop) doesn't kill the REPL.

thheller09:04:24

yeah I do that for my CLJ setups as well

thheller09:04:31

just run shadow-cljs separately

thheller09:04:50

but it is a bit annoying to manage multiple REPL connections

thheller09:04:03

so I understand why some people might prefer dealing with only one connection

flowthing09:04:46

Right. I guess the choice between starting the shadow-cljs server from the command line or using the embedded server here is mostly a matter of preference, then?

thheller09:04:55

yeah. I think things are more reliable if you leave shadow-cljs running independently but otherwise things work the same

flowthing09:04:18

Gotcha. Many thanks, both for the answers and for shadow-cljs itself!

đź‘Ť 4
grav10:04:42

Is it possible to switch between connected clients from the cljs repl? Couldn’t find anything in the docs.

thheller10:04:29

@grav not currently no. the web ui at http://localhost:9630 lets you select which client you connect to but that API isn't accesible elsewhere currently

thheller10:04:36

mostly because tools wouldn't use it anyways

thheller10:04:23

the logic currently picks the first connected client

grav10:04:12

Ok, but the repl accessible via the Web ui isn’t a cljs one?

grav10:04:32

Oh, the ones for the clients are.

grav10:04:52

That’s good enough for me - it allows me to delete the caches on the various clients when I mess up 🙂

grav11:04:40

Btw, I eventually got both iOS and Android to connect to both https and ssl with live-reload and everything. I just needed to explicitly tell iOS to trust my custom root cert, and I needed to setup port forwarding via Chrome DevTools for both https and wss and use localhost from Android.

grav11:04:22

Being able to inspect both devices directly from IntelliJ would be freakin’ awesome, but at least the repls in Shadow CLJS’ web-ui brings me some of the way 🙂

anovick19:04:50

Hello, i'm trying to use shadow-cljs for writing a ClojureScript script on Node.js I get an error

No such namespace: js
The instructions that got me there: 0. Configure shadow-deps.clj:
{:source-paths ["src"]

 :dependencies []

 :nrepl        {:port 3333}

 :builds
 {:app {:target :node-script
        :main demo.script/main
        :output-to "out/demo-script/script.js"
        :output-dir "public/js"
        :asset-path "/js"

        :modules
        {:main
         {:entries [demo.script]}}}}}
1. shadow-cljs node-repl app:
cli version: 2.8.26  node: v10.9.0
shadow-cljs - server version: 2.8.26 running at 
shadow-cljs - nREPL server started on port 3333
[0:0]~cljs.user=> 
2. Connect to the Remote Configuration nREPL port 3333 in Cursive, open REPL and see this message:
Connecting to remote nREPL server...
Clojure 1.10.0
3. Evaluate (shadow/repl :app) in the REPL
(shadow/repl :app)
To quit, type: :cljs/quit
=> [:selected :app]
4. Evaluate (js/console.log "working?") 5. Receive the error Any idea how to solve this?

anovick19:04:33

I figured something out on this link [shadow-cljs guide by loganpowell](https://github.com/loganpowell/shadow-proto-starter#using-protorepl): > For Node development - unlike when targeting the browser - you'll use:

(shadow.cljs.devtools.api/node-repl)
After evaluating that expression I don't get the error anymore, so I guess the instruction #3 should be replaced with this, in the instruction list I've described above.