【发布时间】:2015-12-23 02:01:11
【问题描述】:
我正在 ClojureScript 中构建一个 Node.js 应用程序并测试宏。
目录结构:
├── project.clj
└── src
└── lists
├── core.cljs
└── lib.clj
project.clj:
(defproject lists "0.1.0-SNAPSHOT"
:source-paths ["src/"]
:dependencies [[org.clojure/clojure "1.7.0"]]
:plugins [[lein-cljsbuild "1.1.2"]]
:cljsbuild {:builds
[{:source-paths ["src"]
:compiler {:output-to "target/lists.js"
:optimizations :simple
:target :nodejs}}]})
src/lists/core.cljs:
(ns lists.core
(:require [lists.lib :as lib :include-macros true]))
(enable-console-print!)
(lib/defmain [& args]
(console.log "hello world"))
src/lists/lib.clj:
(ns lists.lib)
(defmacro defmain [& body]
`(set! *main-cli-fn* (fn ~@body)))
当我运行 lein cljsbuild once 时,我得到一个巨大的错误回溯,其中包含:
Caused by: clojure.lang.ExceptionInfo: No such namespace: lists.lib, could not locate lists/lib.cljs or lists/lib.cljc at line 1 src/lists/core.cljs {:file "src/lists/core.cljs", :line 1, :column 1, :tag :cljs/analysis-error}
文件夹结构是正确的,:source-paths 存在于两个外部
defproject 调用和内部 :cljsbuild :builds 对象。更奇怪的是
有时它会退出而不打印任何内容。有人有什么想法吗?
【问题讨论】:
-
您在
project.clj中缺少对 ClojureScript 的依赖。 -
试试
(:require-macros [lists.lib :as lib]))可能吗?
标签: clojure clojurescript