Reputation: 31
I'm building a Node.js app in ClojureScript and testing out macros.
Directory structure:
├── 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)))
When I run lein cljsbuild once
, I get a huge error traceback containing:
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}
The folder structure is right, and :source-paths
is present in both the outer
defproject
call and inner :cljsbuild :builds
object. What's even weirder is
that sometimes it exits without printing anything. Anyone have any ideas?
Upvotes: 3
Views: 568
Reputation: 530
cljsbuild is throwing an exception because it doesn't understand .clj files, it's looking for .cljs or .cljc files in the "src" directory. You have to rename lib.clj to lib.cljc check using cljc on the clojurescript wiki.
Upvotes: 1