Skip to content

Instantly share code, notes, and snippets.

@mhuebert
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhuebert/1b2dd588e34d1ada7fb1 to your computer and use it in GitHub Desktop.
Save mhuebert/1b2dd588e34d1ada7fb1 to your computer and use it in GitHub Desktop.
ClojureScript with zero dependencies (browser)

ClojureScript from master w/ zero dependencies

  1. git clone https://github.com/clojure/clojurescript.git
  2. cd clojurescript; ./scripts/uberjar
  3. (^this creates cljs.jar in clojurescript/target; you will use it below)
  4. Create the following directory & file structure
 foo
 ├── build.clj
 ├── cljs.jar ;(created above)
 ├── index.html
 └── src
     └──foo
        └── core.cljs

in build.clj:

(require 'cljs.build.api)
(cljs.build.api/build "src" {:output-to "out/main.js"})

in index.html

<!DOCTYPE html>
<html>
  <body>
    <script type="text/javascript" src="out/goog/base.js"></script>
    <script src="out/main.js"></script>
    <script type="text/javascript">
            goog.require("foo.core");
    </script>
  </body>
</html>

in core.cljs:

(ns foo.core)
; your code here

run java -cp cljs.jar:src clojure.main build.clj from ./my-example

then open index.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment