我正在尝试连接到ClojureScript浏览器REPL,我遇到了麻烦clojure.browser.repl/connect.我编译的JavaScript会TypeError尝试调用顶部的Google Closure代码块中appendChild的null对象.我按照ClojureScript中的说明进行操作:启动和运行(第9章,第78页,预览版中提供),并想知道自发布以来这个工具是否发生了变化.
我正在使用Leiningen 2.0.0,Java 1.6.0_37,OS X 10.7.5,以及我的依赖项project.clj:
(defproject brepl-hello "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/clojurescript "0.0-1552"]
[compojure "1.1.5"]
[ring/ring-jetty-adapter "1.1.8"]]
:plugins [[lein-cljsbuild "0.3.0"]]
:source-paths ["src/clj"]
:cljsbuild {:builds [{
:source-paths ["src/cljs"]
:compiler {
:output-to "resources/public/brepl-hello.js"
:optimizations :whitespace
:pretty-print true}}]})
Run Code Online (Sandbox Code Playgroud)
这是唯一的ClojureScript源文件,src/cljs/brepl_hello/brepl-hello.cljs:
(ns brepl-hello
(:require [clojure.browser.repl :as repl]))
(repl/connect "http://localhost:9000/repl")
Run Code Online (Sandbox Code Playgroud)
这将编译到resources/public/brepl-hello.js我index.html在同一目录中插入的文件:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="brepl-hello.js"></script>
</head>
<body>
</body> …Run Code Online (Sandbox Code Playgroud) clojure google-closure google-closure-compiler leiningen clojurescript