Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

cljs-bootstrap

ClojureScript compiling ClojureScript

Subscribe to updates I use cljs-bootstrap


Statistics on cljs-bootstrap

Number of watchers on Github 140
Number of open issues 3
Average time to close an issue 17 days
Main language Clojure
Average time to merge a PR less than a minute
Open pull requests 1+
Closed pull requests 1+
Last commit about 4 years ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 604 KB
Organization / Authorswannodette
Contributors2
Page Updated
Do you use cljs-bootstrap? Leave a review!
View open issues (3)
View cljs-bootstrap activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating cljs-bootstrap for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

cljs-bootstrap

Use ClojureScript to compile itself.

Usage

Install ClojureScript from master. Checkout the ClojureScript repo and build and install into your local Maven:

cd clojurescript
./script/build

Note the ClojureScript version number. Modify this repo's project.clj file to reflect the version number.

Checkout my fork of tools.reader from master and switch to the cljs-bootstrap branch. Install it into your local Maven:

cd tools.reader
lein install

Install the NPM dependencies to get reasonable stack traces:

cd cljs-bootstrap
lein npm install

Start the REPL:

lein trampoline run -m clojure.main script/repl.clj 

Try the following at the REPL by loading the necessary namespaces:

(require-macros '[cljs.env.macros :refer [ensure]])
(require '[cljs.analyzer :as ana] '[cljs.compiler :as c])

Now you can eval. Note currently only trivial expressions work. Arbitrary source code requires macro support which has not yet landed in ClojureScript master:

(js/eval
  (with-out-str
    (c/emit
      (ensure
        (ana/analyze-keyword
          (assoc (ana/empty-env) :context :expr)
          :foo)))))

Hacking

Progress is constantly being made against master. If you are feeling adventurous the following will let you see the current state of things. In a Clojure REPL copy the cljs/core.cljc macros file and the cljs/core.cljs standard library file into resources (make sure you've created the resources/cljs parent directory).

(require '[clojure.java.io :as io])
(spit "resources/cljs/core.cljc" (slurp (io/resource "cljs/core.cljc")))
(spit "resources/cljs/core.cljs" (slurp (io/resource "cljs/core.cljs")))
(spit "resources/cljs/core.cljs.cache.aot.edn" 
  (slurp (io/resource "cljs/core.cljs.cache.aot.edn")))

Start a ClojureScript REPL. First you must load the macros file at the REPL:

(load-file "/full/path/to/resources/cljs/core.cljc")

Then load this project's namespace:

(require 'cljs-bootstrap.core)

Switch into this namespace and you should be able to eval the comment snippets in the src/cljs_bootstrap/core.cljs source file.

Compiling cljs.core in the browser and benchmarking

After setting up, compile cljs-bootstrap.dev which contains the benchmarking code:

lein run -m clojure.main script/browser.clj

Then start a local server to view the files:

python -m SimpleHTTPServer 8000

Go to http://localhost:8000/index.html, where you'll see a button: Compile Core!. When you click it, the script we compiled earlier, cljs-bootstrap.dev, will fetch cljs.core, compile it, and then present you with how it took to compile (not to fetch).

License

Copyright 2015 David Nolen, Rich Hickey & Contributors

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

cljs-bootstrap open issues Ask a question     (View All Issues)
  • about 4 years Error connecting to http://localhost:9000/repl
cljs-bootstrap open pull requests (View All Pulls)
  • change ana/analyze-keyword to ana/analyze
cljs-bootstrap list of languages used
Other projects in Clojure