How to turn `clj -m cljs.main` into a single command line?

With new guide showing what we can do with ClojureScript 1.10 ,

clj -m cljs.main -re node

I think it would be more interesting to turn that into a command line tool call cljs. Can we achieve that?

You can create a main args alias in your ~/.clojure/deps.edn:

 {:cljs {:main-opts ["-m" "cljs.main" "-re" "node"]
         :extra-deps {org.clojure/clojurescript {:mvn/version "1.10.238"}}}}}

Then run it with:

clj -A:cljs

There’s always

alias cljs='clj -m cljs.main -re node'



What Alex has suggested is actually significantly more powerful and I would argue the recommended way. Aliases can group command line options and dependencies. So you can imagine the following commands are possible:

cljs -A:cljs:node ...
cljs -A:cljs:test ...
cljs -A:cljs:test:release ...

The kinds of things people wanted profiles to do but which didn’t really deliver the right level of composition or granularity.


Not only that, you can append additional main args to the end of cljs -A:whatever and they will be appended to the command line after the alias args.

Probably what I’m looking for…

brew install clojurescript

What is that giving you? You can do this with lumo or planck now.

This is only worth doing if there is some additional value to be had.

1 Like

as I can see:

  • fewer letters to type.
  • when you introduce ClojureScript to a new developer, it takes far less time to explain clj and -m and -A and -X:xyz syntax issues. Just to say install clojurescript and run cljs to play.

There actually is a clojurescript brew formula now which provides cljsc. I suppose it could add a cljs that wraps clj but we would need to think carefully about how to make the mechanics of that script compatible with clj and composable with likely needs.

1 Like

What is wrong with shadow-cljs?

$ mkdir foo
$ cd foo
$ npm init -y
$ npm install --save-dev shadow-cljs
$ npx shadow-cljs init

# then either
$ npx shadow-cljs node-repl
# or
$ npx shadow-cljs browser-repl

The install steps could be optional but shadow-cljs currently assumes the existence of a config file.

I’m not convinced that cljs.main is “better” for beginners than an actual build tool. The whole point of shadow-cljs is to make configuration easier and eliminate as much boilerplate as possible. cljs.main lets you compose your stuff manually which is neat if you know what you are doing but even a simple example of one browser-targeted build with a “dev” and “release” build setup will be more complex than just using shadow-cljs.

I’m seriously curious which benefits you see with cljs.main that shadow-cljs doesn’t already provide?

I’m still using shadow-cljs for my cljs projects. I would like to try cljs command for just trying small piece of code.

clj -m cljs.main looks like bringing unnecessary complexity to beginners if they learn compiling ClojureScript from official guide.

This hasn’t been my impression from the overall feedback on the Quick Start guide, anecdotally quite the opposite so far. Since many ClojureScript beginners are people who are coming from Clojure or will find it in short order - there’s just far less value in talking about tooling specific to ClojureScript rather than the whole ecosystem because beginners are not beginners for very long.

In the end, we did not work on cljs.main specifically for beginners. It’s a tool for users with all levels of experience and it should be understood in terms of that goal.


Fair point. It makes ClojureScript guide more consistent with Clojure guide.

I haven’t been coding Java in all of my jobs. It’s kind of fear of Java in me and I want all tools to hide Java from the scene. I would think new arrivers similar to me may have same feelings.


Its a lie to pretend Clojure/Script are independent from Java. As much as I want more people to come over to Clojureland, trying to hide all Java to fool them into thinking there is none is deceiving. Clojure/Script are parasitic languages, they extend and harmonize with their host language, like pro-biotics :stuck_out_tongue: It will make you faster and more productive if you just accept Java, and spend a bit of time getting familiar with its ecosystem. In the long run it will be time well spent, and Clojure will make more sense.

That said, from the recent survey, we see more and more people are coming to ClojureScript from JavaScript. It would be nice now that self-hosted ClojureScript is real to see Java and the JVM dependencies eventually disappear from the ClojureScript stack. JavaScript knowledge should be required for ClojureScript, but I’m not sure Java knowledge should. In the end, that choice is up to the core team, the compiler is Java based I believe, sand I don’t think they’re looking into changing it to self-hosted ClojureScript anytime soon.

1 Like

I want to hide Java. Like code always runs with Assembly, people barely read assembly. ClojureScript might require Java during compilation, but it’s fine. It won’t take me time to dig into Java issues using creating web pages with ClojureScript, and it will make be feel at ease.

And during teaching, it becomes more important to make sure few concepts are introduced, and fewer chances to be mistaken.

Let me rephrase my thoughts to better express myself.

I mean if using Clojure, knowing Java and the JVM is a must.

Similarly, if using ClojureScript, knowing JavaScript and its runtimes is a must.

Thus programming in Clojure/ClojureScript full stack requires knowledge of Java, the JVM, JavaScript and its runtimes.

And, unfortunately, using only ClojureScript still requires knowledge of at least the JVM, but eventually Java too. I wish this becomes less true in the future, but today one must install and configure the JVM by themselves, and they must either know how to bootstrap the ClojureScript compiler into a Java process, or use Clojure based build tools like Lein and Boot. Both of which requires Clojure (and thus) Java knowledge to extend. I’d like to see a full ClojureScript ecosystem. Lumo is a great start. A ClojureScript compiler in ClojureScript or at least wrapped in a cli that bundles the JVM, with a build and dependency tool in ClojureScript or similarly bundled.

I think that would help people coming from JavaScript who want to avoid the JVM and Java.

1 Like

So I bet on shadow-cljs and Lumo. shadow-cljs wraps JVM and I don’t even need to know JVM is running except for chances shadow-cljs throw exceptions from itself.


I’ve found with shadow-cljs there is no need to know anything about the JVM when doing Clojurescript development.

But I would agree that knowledge of JavaScript is a must. In fact, I think that clojurescript is powerful precisely because of it reliance on JavaScript and easy interop.

I think accepting the importance of the underlying host language with clojure/clojurescript and not trying to hide it is very important to productive development with these languages.