Assumed that you have set leiningen up and can use it.
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/
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.
$ 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.
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.
ClojureScript:cljs.user> (js/alert "Hello world from CLJS REPL!")
If the web browser pops an alert window up, it works.
Thanks to @swannodette, @ktsujister and @otabat_
https://twitter.com/kohyama/status/365409226425761792
now it runs.
Environment:
Mac OS X Snow Leopard
Leiningen 2.2.1-SNAPSHOT on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM
Google Chrome 28.0.1500.95