Hi there. I am trying to build Clojurescript with GraalVM
I did edit the MANIFEST.MF to include Main-Class: cljs.main
The I ran native-image -jar clojurescript-1.12.21.jar -H:Name=cljs-native on it
Error: Main entry point class 'cljs.main' neither found on
classpath: '/home/shalok/Dokumente/Code/Source/Clojure/clojurescript/target/clojurescript-1.12.21.jar' nor
modulepath: '/usr/lib/jvm/java-22-graalvm-ee/lib/svm/library-support.jar'.Its there, though
I wanna utilize Clojurescript outside of JVM, to make a long story short: I intend to use a WebAssembly compiler on the outputted JS. Just in case anyone is wondering, why I am trying this at all. The intention is to create a toolkit, that translates Clojure into WebAssembly.
thanks a lot, that makes a lot of sense!
One of the absolute core design decisions in CLJS was that macros during compilation are expanded using the CLJ runtime. That allowed omitting the entire compiler stack from the final produced output, making the produced output much much smaller.
with graalvm you are essentially locking down the CLJ parts that make extending the runtime at runtime (i.e. loading additional namespaces) essentially impossible, therefore making CLJS very unflexible by only allowing your preloaded predefined macros
you can opt to go for self hosted CLJS, which includes the entire compiler and once built requires ONLY the JS runtime and no JVM/CLJ at all
long story short: graalvm makes no sense in a CLJS setting, even less so when going for wasm
I feel like the JVM would make the process more setup heavy, and I promise myself a simpler workflow, from having Clojurescript as a binary.
Thanks a lot in advance
Hi Matthias, I’m not sure if I am misunderstanding your goal, because you mention both clojurescript and jvm, but FWIW I had at least an adjacent interest recently to compile clojurescript to wasm. My approach was a little different as I didn’t use graalvm but sharing in case it’s useful to you: https://github.com/manetu/lambda-sdk-clj
My main stack was shadow-cljs + javy
It works quite nicely, and could be adapted to a general solution outside of our concept of lambda functions
My plan is to use Clojurescript --> Javy
Thanks a lot for your tip!
As far as I know, you’d use graalvm for jvm clojure, not clojurescript per se. See my README about using shadow-cljs to compile clojurescript to an ESM module. Might offer you a different path
I also set Main-Class to main.clj
For future reference - when you have new info that you'd like to add, please edit the original post or add it under the post in a thread, so that people aren't notified exessively.