-
Notifications
You must be signed in to change notification settings - Fork 790
Running REPLs
As of 0.0-2665 REPLs have changed significantly enough that many existing third party REPLs and REPL launchers no longer work. While they are likely to be updated in the near future the following demonstrates how to run REPLs directly without using anything more than Leiningen itself.
All that is required is to make a REPL runner .clj file. For example if your cljsbuild entry looks like the following:
{:id "dev"
:source-paths ["src"]
:compiler {
:output-to "hello_world.js"
:output-dir "out"
:optimizations :none
:cache-analysis true
:source-map true}}
Then your repl.clj file should look like the following for Node.js:
(require
'[cljs.repl :as repl]
'[cljs.repl.node :as node])
(repl/repl* (node/repl-env)
{:output-dir "out"
:optimizations :none
:cache-analysis true
:source-map true})
Or for Rhino:
(require
'[cljs.repl :as repl]
'[cljs.repl.rhino :as rhino])
(repl/repl* (rhino/repl-env)
{:output-dir "out"
:optimizations :none
:cache-analysis true
:source-map true})
You can then run the REPL against your build with the following:
lein trampoline run -m clojure.main repl.clj
For better behavior at the command line, install rlwrap (under OS X easily done with brew), then:
rlwrap lein trampoline run -m clojure.main repl.clj
Browser REPL is almost exactly the same setting up a Node.js REPL.
Your browser_repl.clj
should look like the following:
(require
'[cljs.repl :as repl]
'[cljs.repl.browser :as browser])
(repl/repl* (browser/repl-env)
{:output-dir "out"
:optimizations :none
:cache-analysis true
:source-map true})
Remember that you must change your source file to include the browser REPL:
(ns hello-world.core
(:require [clojure.browser.repl :as repl]))
(repl/connect "http://localhost:9000/repl")
(enable-console-print!)
(println "Hello world!")
Then build your project:
lein cljsbuild once hello-world
Now you can launch your browser REPL:
lein trampoline run -m clojure.main browser_repl.clj
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)