Fork me on GitHub
#cljs-dev
<
2021-05-28
>
Braden Shepherdson15:05:20

I'm struggling a bit with running CLJS compiler under Bazel (new rules from scratch for reasons, not using the shared Bazel Clojure libs) and can't figure out what causes this error:

Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/loader__init.class, cljs/loader.clj or cljs/loader.cljc on classpat
h.                                                                                                                                                 
        at clojure.lang.RT.load(RT.java:466)                                                                                                       
        at clojure.lang.RT.load(RT.java:424)                          
        at clojure.core$load$fn__7800.invoke(core.clj:6126)                                                                                                at clojure.core$load.invokeStatic(core.clj:6125)                                                                                           
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)                                                                                       
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$compile$fn__7805.invoke(core.clj:6137)
        at clojure.core$compile.invokeStatic(core.clj:6136)
        at clojure.core$compile.invoke(core.clj:6128)
        at clojure.lang.Var.invoke(Var.java:384)
        at clojure.lang.Compile.main(Compile.java:70)
I gather that cljs.loader is very special, and I'm having a hard time figuring out where it actually gets loaded and what might be wrong.

thheller17:05:40

@braden.shepherdson that is an error trying to load a CLJS file from CLJ. that ns isn't special, it is just CLJS code not CLJ code.

Braden Shepherdson17:05:49

am I reading it right that src/main/clojure should be the input to clojure.main , while src/main/cljs should be data files available at runtime?

thheller17:05:14

not really? all the files are required by the CLJS compiler. none of the are required at "runtime" if you are referring to the runtime of the final JS output? (as the CLJS compiler will have turned the relevant files into JS code)

Braden Shepherdson17:05:49

I think the problem is actually that this rule wants to AOT-compile the Clojure code and then run it, hence the compile- and run-time distinction.

thheller18:05:15

if you have everything AOT compiled and those classes available you can maybe get away with just src/main/cljs. but there are some .cljc files so might be safer to just keep src/main/clojure as well, if you run the self-hosted compiler you'll need all of it regardless

Braden Shepherdson18:05:14

hm. maybe that's the trouble; I don't think I tried it with src/main/clojure as the srcs and both as data.

Braden Shepherdson18:05:58

🎉 I managed to get --help to work.