没有 Java 的 ClojureScript

ClojureScript without Java

是否可以在没有 Java 的情况下编译 ClojureScript?

我读了 clojurescript nodejs quickstart 但我看到他们仍然使用 java 来编译。

我检查了 cljs-bootstrap 但它们也依赖于 java。

有什么方法可以只使用 npm install 并开始使用 clojurescript 吗?

在 ClojureScript 自托管(在 ClojureScript 而不是 Clojure 中实现)之前,需要 Java 以及 Node/NPM。然而,David Nolen 在 his April 20, 2015 talk at Clojure West 中表示,在编译器可以自行引导之前,剩下的工作相对较少。 [由于其他原因,该演讲可能也很有趣。]所以这可能会在不久的将来发生变化。

现在支持 ClojureScript 1.7 自编译,请参阅

This Post

设置

(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
                  ))

初始编译必须在 JVM 上完成,但是一旦完成,上面的函数 my-compiler 将编译字符串。要创建具有最新配置的示例项目,请使用 lein mies 模板

lein new mies my-project

现在有鲁墨了: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.

干杯。