## A minimum setting to use browser REPL of ClojureScript Assumed that you have set [leiningen](https://github.com/technomancy/leiningen) up and can use it. ### 1. Prepare files Copy `project.clj`, `repl-test.cljs` and `brepl-test.html` from this gist or git clone this gist and move or copy repl-test.cljs under `src` directory. ``` $ git clone https://gist.github.com/6183122.git $ cd 6183122/ $ mkdir src $ mv repl-test.cljs src/ ``` ### 2. Compile Compile `repl-test.cljs` into `brepl-test.js`. ``` $ lein cljsbuild once ``` Note that a JavaScript file whose name starts with `repl` raises an error like ``` Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:9000/repl-test.js". ``` at step 4. ### 3. Run a ClojureScript REPL ``` $ lein trampoline cljsbuild repl-listen Running ClojureScript REPL, listening on port 9000. "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> ``` This repl also works as a lightweight web server serving the project directory as the document root. ### 4. Open the HTML file Open brepl-test.html on a web browser via the repl web server. ``` http://localhost:9000/brepl-test.html ``` Note that openning as a local file with `file:` doesn't work. Also note that a HTML file whose name starts with `repl` raises an error like ``` No 'xpc' param provided to child iframe. ``` Of course, it's O.K. to serve HTML and JavaScript files with whatever web server you like. In the case, HTML and JavaScript file whose name starts with `repl` isn't inhibitted. Refer [how to use browser REPL of ClojureScript with compojure](https://gist.github.com/kohyama/6191281). ### 5. Use it ``` ClojureScript:cljs.user> (js/alert "Hello world from CLJS REPL!") ``` If the web browser pops an alert window up, it works.