0.1.17 • Published 24 days ago

cherry-cljs v0.1.17

Weekly downloads
-
License
-
Repository
-
Last release
24 days ago

Cherry :cherries:

Experimental ClojureScript to ES6 module compiler.

Reducing friction between ClojureScript and JS tooling.

:warning: This project is an experiment and not recommended to be used in production. It currently has many bugs and will undergo many breaking changes.

Also check out Squint which is a CLJS syntax to JS compiler.

Quickstart

Although it's early days and far from complete, you're welcome to try out cherry and submit issues.

$ mkdir cherry-test && cd cherry-test
$ npm init -y
$ npm install cherry-cljs@latest

Create a .cljs file, e.g. example.cljs:

(ns example
  (:require ["fs" :as fs]
            ["url" :refer [fileURLToPath]]))

(prn (fs/existsSync (fileURLToPath js/import.meta.url)))

(defn foo [{:keys [a b c]}]
  (+ a b c))

(js/console.log (foo {:a 1 :b 2 :c 3}))

Then compile and run (run does both):

$ npx cherry run example.cljs
true
6

Run npx cherry --help to see all command line options.

Examples

A few examples of currenly working projects compiled by cherry:

See the examples directory for more.

Project goals

Goals of cherry:

  • Compile .cljs files on the fly into ES6-compatible .mjs files.
  • Compiler will be available on NPM and can be used from JS tooling, but isn't part of the compiled output unless explicitly used.
  • Compiled JS files are fairly readable and have source map support for debugging
  • Compiled JS files are linked to one shared NPM module "cherry-cljs" which contains cljs.core.js, cljs.string, etc. such that libraries written in cherry can be compiled and hosted on NPM, while all sharing the same standard library and data structures. See this tweet on how that looks.
  • Output linked to older versions of cherry will work with newer versions of cherry: i.e. 'binary' compatibility.
  • Light-weight and fast: heavy lifting such as optimizations are expected to be done by JS tooling
  • No dependency on Google Closure: this project will use it for bootstrapping itself (by using the CLJS compiler), but users of this project won't use it for compilation
  • Macro support
  • REPL support
  • Async/await support. See this tweet for a demo.
  • Native support for JS object destructuring: [^:js {:keys [a b]} #js {:a 1 :b 2}]
  • Native support for JSX via #jsx reader tag. See example.

Cherry may introduce new constructs such as js-await which won't be compatible with current CLJS. Also it might not support all features that CLJS offers. As such, using existing libraries from the CLJS ecosystem or compiling Cherry CLJS code with the CLJS compiler may become challenging. However, some results of this experiment may end up as improvements in the CLJS compiler if they turn out to be of value.

See slides of a presentation given at Dutch Clojure Days 2022 about cherry and squint.

Depending on interest both from people working on this and the broader community, the above goals may or may not be pursued. If you are interested in maturing cherry, please submit issues for bug reports or share your thoughts on Github Discussions.

Cherry started out as a fork of Scriptjure. Currently it's being reworked to meet the above goals.

Embed cherry in a CLJS/shadow app

See embed.md.

Development

$ git clone git@github.com:squint-cljs/cherry.git
$ cd cherry
$ bb dev

defclass

See squint docs.

js-template

See squint docs.

License

Cherry is licensed under the EPL, the same as Clojure core and Scriptjure. See epl-v10.html in the root directory for more information.

0.1.17

24 days ago

0.1.16

5 months ago

0.1.15

5 months ago

0.1.10

5 months ago

0.1.11

5 months ago

0.1.12

5 months ago

0.1.13

5 months ago

0.1.14

5 months ago

0.1.8

8 months ago

0.1.7

9 months ago

0.1.9

7 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.4

11 months ago

0.0.1

1 year ago

0.0.0-alpha.57

2 years ago

0.0.0-alpha.59

2 years ago

0.0.0-alpha.58

2 years ago

0.0.0-alpha.60

1 year ago

0.0.0-alpha.56

2 years ago

0.0.0-alpha.55

2 years ago

0.0.0-alpha.54

2 years ago

0.0.0-alpha.51

2 years ago

0.0.0-alpha.50

2 years ago

0.0.0-alpha.49

2 years ago

0.0.0-alpha.48

2 years ago

0.0.0-alpha.47

2 years ago

0.0.0-alpha.46

2 years ago

0.0.0-alpha.45

2 years ago

0.0.0-alpha.44

2 years ago

0.0.0-alpha.43

2 years ago

0.0.0-alpha.42

2 years ago

0.0.0-alpha.41

2 years ago

0.0.0-alpha.40

2 years ago

0.0.0-alpha.39

2 years ago

0.0.0-alpha.38

2 years ago

0.0.0-alpha.37

2 years ago

0.0.0-alpha.36

2 years ago

0.0.0-alpha.35

2 years ago

0.0.0-alpha.34

2 years ago

0.0.0-alpha.33

2 years ago

0.0.0-alpha.32

2 years ago

0.0.0-alpha.31

2 years ago

0.0.0-alpha.30

2 years ago

0.0.0-alpha.29

2 years ago

0.0.0-alpha.28

2 years ago

0.0.0-alpha.27

2 years ago

0.0.0-alpha.26

2 years ago

0.0.0-alpha.25

2 years ago

0.0.0-alpha.24

2 years ago

0.0.0-alpha.23

2 years ago

0.0.0-alpha.22

2 years ago

0.0.0-alpha.21

2 years ago

0.0.0-alpha.20

2 years ago

0.0.0-alpha.19

2 years ago

0.0.0-alpha.18

2 years ago

0.0.0-alpha.17

2 years ago

0.0.0-alpha.16

2 years ago

0.0.0-alpha.15

2 years ago

0.0.0-alpha.14

2 years ago

0.0.0-alpha.13

2 years ago

0.0.0-alpha.12

2 years ago

0.0.0-alpha.11

2 years ago

0.0.0-alpha.10

2 years ago

0.0.0-alpha.9

2 years ago

0.0.0-alpha.8

2 years ago

0.0.0-alpha.7

2 years ago

0.0.0-alpha.6

2 years ago

0.0.0-alpha.4

2 years ago

0.0.0-alpha.3

2 years ago

0.0.0-alpha.2

2 years ago

0.0.0-alpha.1

2 years ago

0.0.0-alpha.0

2 years ago