• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Clojure
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ClojureScript compiling ClojureScript

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.

More Repositories

1

mori

ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript
Clojure
3,385
star
2

logic-tutorial

A Very Gentle Introduction to Relational Programming
Clojure
936
star
3

lt-cljs-tutorial

A ClojureScript Programming Language Tutorial for Light Table Users
Clojure
864
star
4

enlive-tutorial

An Easy Introduction to Enlive
Clojure
612
star
5

mies

Minimal ClojureScript project template
Clojure
369
star
6

delimc

Delimited continuations for Clojure
Clojure
213
star
7

hello-cljsc

Hello ClojureScript Compiler
Clojure
190
star
8

om-sync

A reusable Om component for keeping local application state in sync with server application state
Clojure
168
star
9

om-next-demo

TodoMVC with Om Next
Clojure
137
star
10

mies-node-template

A minimal ClojureScript Node.js template
Clojure
115
star
11

async-tests

Having fun with core.async
Clojure
103
star
12

swannodette.github.com

Clojure
80
star
13

clojure-snippets

Yasnippet's for Clojure
79
star
14

chambered

Port of Notch's Minecraft JavaScript demo to ClojureScript
Clojure
70
star
15

mies-om

Less is More template for Om
Clojure
53
star
16

jsx-fun

Experiments in transforming from React Native JSX/Flow into Closure Modules
JavaScript
30
star
17

clj-nehe

Nehe Tutorials in Clojure using Penumbra
Clojure
29
star
18

ejecta-cljs-template

ClojureScript + Ambly + Ejecta
Objective-C
29
star
19

native-deps

Native dependencies plugin for Leiningen
Clojure
29
star
20

react-cljs

Facebook React package for deployment to Clojars
JavaScript
28
star
21

om-datascript

Om Next w/ DataScript
Clojure
26
star
22

transit-example

A basic Transit example for Clojure/ClojureScript users
Clojure
21
star
23

om-async-tut

Template for Om Asyn Application State tutorial
Clojure
21
star
24

fun.coffee

Putting the funk into your coffee
CoffeeScript
19
star
25

cljs-master

ClojureScript Master Class
Clojure
17
star
26

transit-js-example

A transit-js example
JavaScript
17
star
27

cljs-demo

Demo repo for BK.js and NYC.js
JavaScript
16
star
28

hs-async

Examples for Tuesday
Clojure
15
star
29

om-nashorn

Om example that you can run with Nashorn
Clojure
14
star
30

GistPad

Gists for the iPad
Objective-C
12
star
31

cljs-ess

ClojureScript Essentials
Clojure
12
star
32

sicp

Chapters 4 and 5 of SICP
Scheme
11
star
33

ob-sml

org-babel support for Standard ML
Emacs Lisp
10
star
34

Vector2D

Basic fast 2D vector math for Objective-C
Objective-C
9
star
35

paip

Paradigms of Artificial Intelligence
Common Lisp
9
star
36

littlecomputers

Source code files for the ITP Little Computers class
Objective-C
8
star
37

es6-demo

ES6 support demo
Clojure
8
star
38

worlds

Worlds management for Om
Clojure
8
star
39

flocking

Dan Shiffman's flocking code ported to Clojure
Clojure
7
star
40

hs-compilers

Compilers Made Easy talk
Clojure
6
star
41

minikanren

My study of miniKanren in Racket
Scheme
6
star
42

sol

Python based library for talking to HPGL pen plotters
Python
5
star
43

underoop

Classes and Modules for Underscore.js
JavaScript
5
star
44

ui-check

Playground for testing transaction event generation for automated UI testing
Clojure
5
star
45

baduk

My Go/Weiqi/Baduk Blog
SCSS
5
star
46

ArtAndCode

Repository for Art && Code mobile iPhone workshop
Objective-C
4
star
47

fairKanren

miniKanren with fair conjunction
Scheme
4
star
48

cocoahelpers

some helpers for Cocoa programming
4
star
49

nyt-gen-talk

Code for the NYT ES6 Generators talk tomorrow
JavaScript
3
star
50

django-bbcode

a git fork of http://bitbucket.org/ojii/django-bbcode/
Python
3
star
51

alphaKanren

Understanding the alphaKanren implementation
Scheme
3
star
52

lt-settings

My Light Table Settings
2
star
53

cljs-material

Using NPM Material from CLJS
Clojure
2
star
54

js-snippets

JavaScript yasnippets
1
star
55

promisejs

Future and promises for server and client-side JavaScript
1
star
56

cljs-stl

Code for Strange Loop
Clojure
1
star
57

cljs-no-ns-test

Clojure
1
star
58

jampack

Useful instruments for Om
1
star
59

om-weasel-repro

Clojure
1
star
60

convex-hull

Optimized version of Uncle Bob's code
Clojure
1
star
61

techmesh-logic

TechMesh Conference Logic Demo Code
Clojure
1
star
62

techmesh-cljs

TechMesh Conference ClojureScript Demo Code
Clojure
1
star
63

zrch-logic

Logic Programming examples from Zurich Clojure Meetup
Clojure
1
star