Making a ClojureScript REPL work in a deps.edn project with Cursive

I haven’t been able to set this up. The official Cursive guide doesn’t talk about ClojureScript much.

So far, I have used the following command adapted from the official ClojureScript tutorial:

clj --main cljs.main --repl

# which *roughly* translates to:
# java -cp "cljs.jar" --main cljs.main --repl

The REPL launched thus gives access to stuff like Google Closure lib, but lacks the more interactive nature of REPL provided by Cursive.

My deps.edn:

{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}}

The command used in cursive to launch REPL is similar to:

/path/to/java
    "-javaagent: <redacted>"
    -Dfile.encoding=UTF-8
    -classpath <includes cljs too>
    clojure.main -r

# uses clojure.main, not cljs.main

My thinking here is what I want might work if I can somehow instruct car safe to use cljs.main instead of clojure.main.

Is there an easy way to configure a deps.edn project in Cursive to launch a cljs REPL? In case cursive is difficult to work with w.r.t. cljs, can you suggest me a non-Emacs alternative?

1 Like

There’s really nothing special to do. When you create the REPL configuration choose the clojure.main option. Then in the Parameters: field of that configuration add your ClojureScript REPL parameters.

That didn’t work. As an example, I still couldn’t import goog.Uri. I think a screenshot will better explain my current configuration.

  1. clojure.main
  2. Run with Deps

My understanding is that I don’t need to fill anything in the Parameters if I want to launch a barebones cljs REPL.

Please forgive me if I’m missing anything obvious. I’m quite new to this.

Never mind! I was reading the commands wrong.

To invoke the REPL with cljs, I am supposed to specify cljs.main as the entry point.

So I added --main cljs.main to the Parameters option. It worked!

Just for reference:

Thank you for the pointer!

1 Like

You did not supply anything to Parameters: as I said you must above. You are simply starting a Clojure REPL each time if you don’t supply Parameters:. And your screenshot verifies that. If there is some Cursive documentation that says you don’t need to supply Parameters: that’s news to me.

This is how I’ve started ClojureScript REPLs in Cursive for the past 2 years.

Glad you got it working!