I followed the first part of https://clojurescript.org/guides/javascript-modules and the part where I execute lein trampoline run -m clojure.main watch.clj
shows this
Building ...
WARNING: JavaScript file found on classpath for library `js.hello`, but does not contain a corresponding `goog.provide` declaration: file:/Users/kcase/projects/hello-es6/src/js/hello.js
Copying jar:file:/Users/kcase/.m2/repository/org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar!/cljs/core.cljs to out/cljs/core.cljs
Reading analysis cache for jar:file:/Users/kcase/.m2/repository/org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar!/cljs/core.cljs
Compiling out/cljs/core.cljs
Using cached cljs.core out/cljs/core.cljs
Copying jar:file:/Users/kcase/.m2/repository/org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar!/cljs/nodejs.cljs to out/cljs/nodejs.cljs
Compiling out/cljs/nodejs.cljs
Compiling src/hello_es6/core.cljs
WARNING: JavaScript file found on classpath for library `js.hello`, but does not contain a corresponding `goog.provide` declaration: file:/Users/kcase/projects/hello-es6/src/js/hello.js
clojure.lang.ExceptionInfo: failed compiling file:src/hello_es6/core.cljs {:file #object[java.io.File 0x14ecd835 "src/hello_es6/core.cljs"]}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at cljs.compiler$compile_file$fn__4440.invoke(compiler.cljc:1521)
at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1482)
at cljs.compiler$compile_file.invoke(compiler.cljc:1458)
at cljs.closure$compile_file.invokeStatic(closure.clj:533)
at cljs.closure$compile_file.invoke(closure.clj:524)
at cljs.closure$eval6681$fn__6682.invoke(closure.clj:602)
at cljs.closure$eval6617$fn__6618$G__6606__6625.invoke(closure.clj:486)
at cljs.closure$compile_sources$iter__6805__6809$fn__6810.invoke(closure.clj:947)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.next(RT.java:703)
at clojure.core$next__6406.invokeStatic(core.clj:64)
at clojure.core$dorun.invokeStatic(core.clj:3115)
at clojure.core$doall.invokeStatic(core.clj:3121)
at clojure.core$doall.invoke(core.clj:3121)
at cljs.closure$compile_sources.invokeStatic(closure.clj:943)
at cljs.closure$compile_sources.invoke(closure.clj:932)
at cljs.closure$build.invokeStatic(closure.clj:2528)
at cljs.closure$build.invoke(closure.clj:2444)
at cljs.closure$watch$buildf__7486.invoke(closure.clj:2647)
at cljs.closure$watch.invokeStatic(closure.clj:2679)
at cljs.closure$watch.invoke(closure.clj:2623)
at cljs.build.api$watch.invokeStatic(api.clj:219)
at cljs.build.api$watch.invoke(api.clj:207)
at cljs.build.api$watch.invokeStatic(api.clj:216)
at cljs.build.api$watch.invoke(api.clj:207)
at cljs.build.api$watch.invokeStatic(api.clj:210)
at cljs.build.api$watch.invoke(api.clj:207)
at user$eval7609.invokeStatic(watch.clj:3)
at user$eval7609.invoke(watch.clj:3)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.load(Compiler.java:7430)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$script_opt.invokeStatic(main.clj:337)
at clojure.main$script_opt.invoke(main.clj:332)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at user$eval15.invokeStatic(form-init5230861038763741865.clj:1)
at user$eval15.invoke(form-init5230861038763741865.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.eval(Compiler.java:6968)
at clojure.lang.Compiler.load(Compiler.java:7430)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$init_opt.invokeStatic(main.clj:279)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invokeStatic(main.clj:310)
at clojure.main$null_opt.invokeStatic(main.clj:344)
at clojure.main$null_opt.invoke(main.clj:341)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: No such namespace: js.hello, could not locate js/hello.cljs, js/hello.cljc, or JavaScript source providing "js.hello" in file src/hello_es6/core.cljs {:tag :cljs/analysis-error}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at cljs.analyzer$error.invokeStatic(analyzer.cljc:694)
at cljs.analyzer$error.invoke(analyzer.cljc:690)
at cljs.analyzer$error.invokeStatic(analyzer.cljc:692)
at cljs.analyzer$error.invoke(analyzer.cljc:690)
at cljs.analyzer$analyze_deps.invokeStatic(analyzer.cljc:2111)
at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:2085)
at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:3430)
at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:3425)
at cljs.analyzer$analyze_STAR_$fn__3152.invoke(analyzer.cljc:3547)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
at clojure.core$reduce.invokeStatic(core.clj:6703)
at clojure.core$reduce.invoke(core.clj:6686)
at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:3547)
at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:3537)
at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:3571)
at cljs.analyzer$analyze.invoke(analyzer.cljc:3554)
at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1340)
at cljs.compiler$emit_source.invoke(compiler.cljc:1319)
at cljs.compiler$compile_file_STAR_$fn__4409.invoke(compiler.cljc:1425)
at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1226)
at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1215)
at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1410)
at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1403)
at cljs.compiler$compile_file$fn__4440.invoke(compiler.cljc:1507)
... 70 more
It sounds like it is complaining that the js.hello
namespace has not been created by goog.provide()
. I'm expecting the ClojureScript compiler to do that since the guide says
JavaScript files do not declare namespaces, so the ClojureScript compiler will compute one based on the location of the entry.
Am I missing something?
I think it's all about CLJS version.
Try this:
project.clj
(defproject hello-es6 "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0-alpha14"]
[org.clojure/clojurescript "1.9.908"]]
:jvm-opts ^:replace ["-Xmx1g" "-server"])
watch.clj
(require '[cljs.build.api :as b])
(b/watch "src"
{:output-to "main.js"
:output-dir "out"
:main 'hello-es6.core
:optimizations :advanced
:target :nodejs
:foreign-libs [{:file "src"
:module-type :es6}] ;; or :commonjs / :amd
:verbose true})
Optimizations should be :advanced
I think this helps you to run example from Guide.