Starting a new ClojureScript project in 2022. Setup suggestions

Ya, the issue here is Clojurescript has no real REPL.

The actual REPL is in Clojure. The Clojure REPL will compile code into JavaScript and then send JavaScript to the JavaScript runtime to be evaluated.

The browser actually connects to the Clojurescript REPL. So in Clojure you start a Clojurescript REPL server, and from the browser you have JavaScript code (previously compiled from Clojurescript) which connects to the Clojurescript REPL server which is running in Clojure.

Now to make matters worse, this Clojure based Clojurescript REPL is not an nREPL, so if you want to use nRepl based tooling, you need to use piggyback, which is a nRepl middleware that under the hood use a Clojurescript REPL.

I recommend trying it raw, without any other tooling as described here: ClojureScript - REPL and Evaluation

When you use figwheel-main, you’re actually breaking standard Clojure convention, and instead of REPL-driven hot-reloads, you’ve switched to file based hot-reloads.

Figwheel-main will watch your files, and reload them, it’s more like traditional JS hot-reloading. The benefits over a REPL are that it also will reload JS and CSS files.

Now it’ll also set you up with a Clojurescript browser REPL, so you can get both benefits at ounce.

And it adds a few other extra bells and whistles.

But if you’re someone that like more minimal tooling, you can go with just a standard Clojurescript REPL and not use figwheel-main at all.

Edit: And I forgot to mention, Figwheel uses its own REPL implementation, not the standard cljs.repl one, so editors like Cider need to have special support for it as well.

1 Like