Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile .cljs files #24

Closed
vmfhrmfoaj opened this issue Jun 17, 2021 · 3 comments
Closed

Can't compile .cljs files #24

vmfhrmfoaj opened this issue Jun 17, 2021 · 3 comments

Comments

@vmfhrmfoaj
Copy link

vmfhrmfoaj commented Jun 17, 2021

ClojureScript compiler complained can't find a file that contain spy.test.cljs namespace.
So, I checked a jar file, the jar file is not included "src/cljs/spy/test/cljs.clj" file.

Is there recommendation how to build .cljs files?


For now, I modified 'project.clj' and installed it locally to avoid compile error as shown below:

   :plugins [[lein-codox "0.10.3"]
             [lein-cloverage "1.0.10"]]
   :dependencies [[org.clojure/clojure "1.10.1"]]
-  :source-paths ["src/clj" "src/cljc"]
+  :source-paths ["src/clj" "src/cljc" "src/cljs"]
   :test-paths ["test/clj" "test/cljc"]
   :deploy-repositories [["releases" :clojars]])

Output:

~/Desktop/Projects/notification $ lein cljsbuild once dev
Compiling ClojureScript...
Compiling ["resources/public/js/app.js"] from ["src" "spec" "test" "tool"]...
Compiling ["resources/public/js/app.js"] failed.
clojure.lang.ExceptionInfo: failed compiling file:resources/public/js/out/spy/core.cljc {:file #object[java.io.File 0x59501e6 "resources/public/js/out/spy/core.cljc"], :clojure.error/phase :compilation}
	at cljs.compiler$compile_file$fn__4001.invoke(compiler.cljc:1747)
	at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1707)
	at cljs.compiler$compile_file.invoke(compiler.cljc:1683)
	at cljs.closure$compile_file.invokeStatic(closure.clj:651)
	at cljs.closure$compile_file.invoke(closure.clj:629)
	at cljs.closure$fn__5492.invokeStatic(closure.clj:725)
	at cljs.closure$fn__5492.invoke(closure.clj:719)
	at cljs.closure$fn__5405$G__5398__5412.invoke(closure.clj:547)
	at cljs.closure$compile_from_jar.invokeStatic(closure.clj:698)
	at cljs.closure$compile_from_jar.invoke(closure.clj:688)
	at cljs.closure$fn__5496.invokeStatic(closure.clj:735)
	at cljs.closure$fn__5496.invoke(closure.clj:719)
	at cljs.closure$fn__5405$G__5398__5412.invoke(closure.clj:547)
	at cljs.closure$compile_task$fn__5588.invoke(closure.clj:1045)
	at cljs.closure$compile_task.invokeStatic(closure.clj:1043)
	at cljs.closure$compile_task.invoke(closure.clj:1035)
	at cljs.closure$parallel_compile_sources$fn__5594.invoke(closure.clj:1073)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1977)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1977)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invokeStatic(core.clj:671)
	at clojure.core$bound_fn_STAR_$fn__5767.doInvoke(core.clj:2007)
	at clojure.lang.RestFn.invoke(RestFn.java:397)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: clojure.lang.ExceptionInfo: null #:clojure.error{:source nil, :line nil, :column nil, :phase :compilation}
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:4229)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:4215)
	at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1563)
	at cljs.compiler$emit_source.invoke(compiler.cljc:1536)
	at cljs.compiler$compile_file_STAR_$fn__3970.invoke(compiler.cljc:1650)
	at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1456)
	at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1445)
	at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1634)
	at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1627)
	at cljs.compiler$compile_file$fn__4001.invoke(compiler.cljc:1732)
	... 31 more
Caused by: clojure.lang.ExceptionInfo: Could not locate spy/test/cljs__init.class, spy/test/cljs.clj or spy/test/cljs.cljc on classpath. in file resources/public/js/out/spy/core.cljc {:tag :cljs/analysis-error}
	at cljs.analyzer$error.invokeStatic(analyzer.cljc:719)
	at cljs.analyzer$error.invoke(analyzer.cljc:715)
	... 41 more
Caused by: java.io.FileNotFoundException: Could not locate spy/test/cljs__init.class, spy/test/cljs.clj or spy/test/cljs.cljc on classpath.
	at clojure.lang.RT.load(RT.java:462)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6856.invoke(core.clj:6115)
	at clojure.core$load.invokeStatic(core.clj:6114)
	at clojure.core$load.doInvoke(core.clj:6098)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5897)
	at clojure.core$load_one.invoke(core.clj:5892)
	at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
	at clojure.core$load_lib.invokeStatic(core.clj:5936)
	at clojure.core$load_lib.doInvoke(core.clj:5917)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:5974)
	at clojure.core$load_libs.doInvoke(core.clj:5958)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:5996)
	at clojure.core$require.doInvoke(core.clj:5996)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at cljs.analyzer$ns_side_effects$fn__2802.invoke(analyzer.cljc:4115)
	at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:4114)
	at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:4086)
	at cljs.analyzer$analyze_STAR_$fn__2855.invoke(analyzer.cljc:4213)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
	at clojure.core$reduce.invokeStatic(core.clj:6829)
	at clojure.core$reduce.invoke(core.clj:6812)
	at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:4213)
	at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:4204)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:4232)
	... 40 more
Subprocess failed (exit code: 1)

cljsbuild:

:cljsbuild
  {:builds {:dev {:source-paths ["src" "spec" "test" "tool"]
                  :compiler {:main notification.core
                             :preloads [dev.tool]
                             :asset-path "/js/out"
                             :output-to  "resources/public/js/app.js"
                             :output-dir "resources/public/js/out"
                             :optimizations :none
                             :source-map-timestamp true
                             :warnings {:single-segment-namespace false}
                             :parallel-build true}
                  :figwheel {:on-jsload dev.tool/on-reload
                             :websocket-host :js-client-host}}}

core_test.cljs:

(ns ^:figwheel-load notification.core-test
  (:require [cljs.test :refer-macros [async deftest is testing]]
            [notification.core :as target]
            [spy.core :as spy]
            [test.tool :as tool]))

(deftest a-test
  (testing "a sample test."
    (is (let [it (spy/stub nil)]
          (it 1 2 3 4)
          (spy/called-with? it 1 2 3 4)))))

(deftest a-async-test
  (async done
         (js/setTimeout (fn []
                          (testing "a async test."
                            (is true)
                            (done)))
                        1000)))

You can see another files at https://gitlab.com/vmfhrmfoaj/notification

@alexanderjamesking
Copy link
Owner

Thanks for reporting this, I will investigate it and get back to you

@alexanderjamesking
Copy link
Owner

Thanks @vmfhrmfoaj fixed in d80749c and released in 2.5.0

@alexanderjamesking
Copy link
Owner

For the record: it was a regression when the CLJS build was switched over to use shadow cljs, I guess most people are using this in Clojure projects rather than ClojureScript at present which is why it hadn't been reported earlier (or perhaps people hadn't upgraded). Anyway, it is fixed now, I'll be sure to check this properly next time to ensure it is working for both CLJ and CLJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants