Share your thoughts in the 2025 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in ClojureScript by

Running cljs.main with just --repl doesn't preload whatever is on :preloads.

Given that the quickest way of trying ClojureScript is by running a command like :

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.12.134"}}}}' -M -m cljs.main --repl

it would be great (and I think expected) to be able to run a repl with some dev tooling, like :

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.12.134"} binaryage/devtools {:mvn/version "1.0.7"}}}}' -M -m cljs.main -co '{:preloads [devtools.preload]}' --repl

but it doesn't work.

It reads the file (it complains if you misspell the preload namespace) but then nothing gets loaded.

The problem seems to be related to ClojureScript not compiling the preload namespace when you run with just --repl

If you create a small single file project (like on the start guide) and then do :

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.12.134"} binaryage/devtools {:mvn/version "1.0.7"}}}}' -M -m cljs.main -co '{:preloads [devtools.preload]}' --compile hello-world.core --repl

it works.
After the compile generates the out folder you can run just with --repl and the preload will work.

Please log in or register to answer this question.

...