figwheel-main

George 2022-11-06T01:05:07.420369Z

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

George 2022-11-06T01:06:22.814069Z

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>

George 2022-11-06T01:08:13.106869Z

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

George 2022-11-06T01:08:33.337559Z

any tips greatly appreciated, thanks

George 2022-11-06T01:09:14.062859Z

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

George 2022-11-06T02:51:20.255919Z

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

George 2022-11-06T03:09:32.938789Z

aha, I think I'm not understanding how this all works at a basic level...https://stackoverflow.com/questions/56782751/how-to-setup-figwheel-main-to-reload-code-served-by-clojure-backend

seancorfield 2022-11-06T03:44:11.460819Z

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)

2022-11-07T22:32:56.923209Z

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.

2022-11-07T22:33:56.592499Z

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

George 2022-11-06T05:05:03.464049Z

holy cow I got it working!

George 2022-11-06T05:06:02.723629Z

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

George 2022-11-06T05:06:43.887069Z

this was the critical piece, https://clojurians-log.clojureverse.org/figwheel-main/2020-08-04

George 2022-11-06T05:07:20.509649Z

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

👍🏻 1
George 2022-11-06T06:29:06.753479Z

wow this is great