Skip to content

Instantly share code, notes, and snippets.

@kanaka
Last active August 29, 2015 14:23
Show Gist options
  • Save kanaka/728961ce861c81a11bc6 to your computer and use it in GitHub Desktop.
Save kanaka/728961ce861c81a11bc6 to your computer and use it in GitHub Desktop.
cljs-bootstrap crib sheet
# Step-by-step distilled from: https://github.com/swannodette/cljs-bootstrap
git clone https://github.com/clojure/clojurescript
git clone https://github.com/swannodette/cljs-bootstrap
#git clone https://github.com/clojure/tools.reader
git clone https://github.com/swannodette/tools.reader
cd clojurescript/
./script/build
cd ../tools.reader
lein install
cd ../cljs-bootstrap
vi project.def # update clojurescript dep to match installed clojurescript version above
lein npm install
mkdir -p resources/cljs
Start Clojure REPL to copy core:
user=>
(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")))
Launch ClojureScript REPL:
rlwrap lein trampoline run -m clojure.main script/repl.clj
cljs.user=>
(load-file "resources/cljs/core.cljc")
(require 'cljs-bootstrap.core)
(in-ns 'cljs-bootstrap.core)
(def e (assoc (ana/empty-env) :context :expr))
(js/eval (with-out-str (c/emit (ensure (ana/analyze e :foo)))))
(js/eval (with-out-str (c/emit (ensure (ana/analyze e 3)))))
(js/eval (with-out-str (c/emit (ensure (ana/analyze e (list [2 3 4] 1))))))
(js/eval (with-out-str (c/emit (ensure (ana/analyze e '(+ 2 3))))))
(js/eval (with-out-str (ensure (c/emit (no-warn (ana/analyze e `(first [7 8 9])))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment