Experimental ClojureScript syntax to JavaScript compiler.
⚠️ This project is an experiment and not recommended to be used in production. It currently has many bugs and will undergo many breaking changes.
Although it's early days and far from complete, you're welcome to try out clava
and submit issues.
$ mkdir clava-test && cd clava-test
$ npm init -y
$ npm install clavascript@latest
Create a .cljs
file, e.g. example.cljs
:
(ns example
(:require ["fs" :as fs]
["url" :refer [fileURLToPath]]))
(println (fs/existsSync (fileURLToPath js/import.meta.url)))
(defn foo [{:keys [a b c]}]
(+ a b c))
(println (foo {:a 1 :b 2 :c 3}))
Then compile and run (run
does both):
$ npx clava run example.cljs
true
6
Run npx clavascript --help
to see all command line options.
- Keywords are translated into strings
- Maps and vectors are translated into objects and arrays
assoc!
anddissoc!
perform in place mutation on objectsprintln
is a synonym forconsole.log
- Truth semantics of JS
Clava is licensed under the EPL, the same as Clojure core and Scriptjure. See epl-v10.html in the root directory for more information.