Fork me on GitHub
#figwheel-main
<
2022-11-06
>
George01:11:07

hello, I am new to Clojure and figwheel and having trouble using my own server with figwheel-main and cider. Cider-jack-in-cljs works OK. But if I cider-jack-in-clj&cljs I can't get the cljs repl to connect

George01:11:22

I've followed the 'your own server' guide in the docs but I am missing a step on how to integrate that with cider, as it recommends starting with the CLI and -i <your clj script to start server>

George01:11:13

I've also tried modifying my dev.cljs.edn to add :connect-url of my server, but the connection doesn't work...in the browser console I see that it keeps trying to connect and failing

George01:11:33

any tips greatly appreciated, thanks

George01:11:14

(note I've also tried starting the clj server first, and then cljs, but same issue)

George02:11:20

Also the 'your own server' page of the docs is confusing to me as well. When I run that example with the CLI, I do get a figwheel session on port 9500, and my jetty server starts on port 4000, but they're not connected, i.e. (js/alert "hi") evals in the port 9500 address, and I can't browse to a route served by jetty via port 9500

seancorfield03:11:11

I think you'll end up with three servers running on different ports: Jetty (web server) which you can view in a browser to see your application, a Clojure nREPL server that your editor will connect to (for eval'ing .clj code) and a ClojureScript REPL server that your editor will connect to (for eval'ing .cljs code)? I use Calva (and CIDER) and when it jacks into a Figwheel-Main project, it starts all three of those up, and then when I eval code in the editor, it figures out which REPL to send it to for evaluation, so I can dev against the live backend and the live frontend. (disclaimer: I'm very new to cljs stuff so this is just how it seems to me so far)

mikerod22:11:56

I believe that the CLJ and CLJS repl actually are both using the same nREPL server instance typically. They are just different client-connections to it, where the CLJS one has the cljs-repl wrapper stuff applied.

mikerod22:11:56

So you have: 1) Your webserver process (if it’s separate) 2) nREPL server used for all the clj/cljs repl connections (this can also be where you start the webserver in (1)) 3) figwheel’s own server for doing the hot reloading (with browser etc) things

George05:11:03

holy cow I got it working!

George05:11:02

@seancorfield thank you, that's helpful. Also watching your London stream about repl dev was very useful

George05:11:20

I just wasn't understanding some config options for figwheel, getting the :connect-url right made it work

1
George06:11:06

wow this is great