16

Is it possible to compile ClojureScript without Java?

I read the clojurescript nodejs quickstart but I see they still use java to compile.

I checked cljs-bootstrap but they also depend on java.

Is there any way to just use npm install and start using clojurescript?

3 Answers 3

9

Now there is Lumo: https://www.npmjs.com/package/lumo-cljs

Lumo is a standalone ClojureScript environment that runs on Node.js and the V8 JavaScript engine. It starts up instantaneously and has out-of-the-box access to the entire Node.js ecosystem.

Lumo also provides a ClojureScript build API, making it possible to compile ClojureScript projects entirely without the JVM, thanks to the experimental JavaScript version of the Google Closure Compiler.

Cheers.

Sign up to request clarification or add additional context in comments.

Comments

7

Until ClojureScript is self-hosted (implemented in ClojureScript rather than Clojure), Java is needed as well as Node/NPM. However, David Nolen said in his April 20, 2015 talk at Clojure West, relatively little work remains before the compiler can be bootstrapped in itself. [The talk may be interesting to watch for other reasons as well.] So this may change in the not-too-distant future.

Comments

3

As of ClojureScript 1.7 self compilation is now supported, see

This Post

To set up

(ns self-compile.core
  (:require cljs.js))

(set! cljs.js/*eval-fn* cljs.js/js-eval)
(def state (cljs.js/empty-state))

(defn my-compiler [str-to-compile]
  (cljs.js/eval-str state str-to-compile
                  (fn [response]
                    ;evaluated code here
                  ))

The initial compilation must be done on the JVM, however once this is done the function my-compiler above will compile strings. To create a sample project with up to date config use the lein mies template

lein new mies my-project

3 Comments

I'm not sure how to get started, can you explain a bit more? It seems to me they are still depending on lein which depends on java... let's say I don't have java installed, can I run clojurescript with just nodejs?
I believe that you need to invoke the JVM at least once to get started, after that you should be all good with just node.js.
Orlando William, to try clojurescript on nodejs check out github.com/whamtet/dogfort

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.