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

reload-clojure causes compilation failure in portable projects #488

Open
JoshuaXX opened this issue Mar 23, 2018 · 4 comments
Open

reload-clojure causes compilation failure in portable projects #488

JoshuaXX opened this issue Mar 23, 2018 · 4 comments

Comments

@JoshuaXX
Copy link

I see this has been fixed long ago, but it still being encountered by me recently. I am using lein-cljsbuild 1.1.7.

(ns atpco.record.intlfare
#?(:cljs (:require-macros [farefront.tools.core :as tools ]))
#?(:clj (:require [farecommon.tools.core :as tools])))

there are two macros with the same name defined in clojure in farefront.tools.core and farecommon.tools.core namespace respectively. these two macro act on same piece of data whith the above mentioned reader conditional.

I still encounter the reload-clojure issue, the error messages are just annoying, but the js files get generated successfully.

@danielcompton
Copy link
Contributor

danielcompton commented Mar 24, 2018

What is the original issue/commit that fixed this? Also, is this a lein-cljsbuild specific issue? Lastly, can you restate the actual issue you're having here? It's not completely clear from your description above what is going wrong (including error messages is helpful).

@JoshuaXX
Copy link
Author

JoshuaXX commented Mar 26, 2018

yes. it is lein-cljsbuild specific.

I issued the command "lein cljsbuild once dev" to build all file under src/cljs directory and src/cljc directory.

Error Message:
Reloading Clojure file "atpco.record.rule.intlfare" failed.
clojure.lang.Compiler$CompilerException: java.lang.ExceptionInInitializerError, compiling:(atpco/record/intlfare.cljc:1:1)
Compiler.java:7526 clojure.lang.Compiler.load
RT.java:379 clojure.lang.RT.loadResourceScript
RT.java:370 clojure.lang.RT.loadResourceScript
RT.java:460 clojure.lang.RT.load
RT.java:426 clojure.lang.RT.load
core.clj:6046 clojure.core/load[fn]
core.clj:6045 clojure.core/load
core.clj:6029 clojure.core/load
RestFn.java:408 clojure.lang.RestFn.invoke
core.clj:5848 clojure.core/load-one
core.clj:5843 clojure.core/load-one
core.clj:5888 clojure.core/load-lib[fn]
core.clj:5887 clojure.core/load-lib
core.clj:5868 clojure.core/load-lib
RestFn.java:142 clojure.lang.RestFn.applyTo
core.clj:659 clojure.core/apply
core.clj:5925 clojure.core/load-libs
core.clj:5909 clojure.core/load-libs
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:659 clojure.core/apply
core.clj:5947 clojure.core/require
.....

I think this issue is similar with #210.

During the build process, some clojure code is loading which cause this error message.

It seems to me the error is due to this reason:
even if I used reader conditional like
(ns atpco.record.intlfare
#?(:cljs (:require-macros [farefront.tools.core :as tools ]))
#?(:clj (:require [farecommon.tools.core :as tools])))
in .cljc file, the cljsbuild always trying to read farecommon.tools.core namespace, which is clojure code.
lein-cljsbuild should not trying to read that namespace. It only should read farefront.tools.core namespace.

Best regards

@mneise
Copy link
Collaborator

mneise commented Jul 3, 2018

@JoshuaXX Would you mind setting up a minimal repo where this issue can be reproduced?

@mtruyens
Copy link

Hi,

I just rain into this issue myself. Please find attached a minimal test case (created using lein new luminus myapp +cljs).

Essentially, it just:

  • created a CLJ file (dummy.clj) with a single function (dummy)
  • tried to require this CLJ file from within a CLJC file (validation.cljc) using
(ns myapp.validation
  (:require [struct.core :as st]
            #?(:clj [myapp.dummy :as dummy])))

When invoking lein cljsbuild once the error message is as fllows:

Compiling ["target/cljsbuild/public/js/app.js"] from ["src/cljs" "src/cljc" "env/dev/cljs"]...
WARNING: No such namespace: dummy, could not locate dummy.cljs, dummy.cljc, or JavaScript source providing "dummy" at line 7 src/cljc/myapp/validation.cljc
WARNING: Use of undeclared Var dummy/dummy-fn at line 7 src/cljc/myapp/validation.cljc

Everything eventually builds fine, however.
myapp.zip

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

No branches or pull requests

4 participants