clojurescript

Matthias Schuster 2025-01-07T21:54:16.467079Z

Hi there. I am trying to build Clojurescript with GraalVM

Matthias Schuster 2025-01-07T21:55:01.137419Z

I did edit the MANIFEST.MF to include Main-Class: cljs.main

Matthias Schuster 2025-01-07T21:55:30.475009Z

The I ran native-image -jar clojurescript-1.12.21.jar -H:Name=cljs-native on it

Matthias Schuster 2025-01-07T21:55:50.140969Z

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'.

Matthias Schuster 2025-01-07T21:56:44.796909Z

Its there, though

Matthias Schuster 2025-01-07T21:59:17.196279Z

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.

Matthias Schuster 2025-01-08T14:25:01.794819Z

thanks a lot, that makes a lot of sense!

thheller 2025-01-08T07:21:46.122559Z

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.

thheller 2025-01-08T07:22:56.478209Z

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

thheller 2025-01-08T07:23:34.429159Z

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

thheller 2025-01-08T07:24:44.585309Z

long story short: graalvm makes no sense in a CLJS setting, even less so when going for wasm

👍🏽 1
Matthias Schuster 2025-01-07T22:00:19.564909Z

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.

Matthias Schuster 2025-01-07T22:00:28.193909Z

Thanks a lot in advance

ghaskins 2025-01-07T23:53:42.101769Z

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

ghaskins 2025-01-07T23:54:28.796309Z

My main stack was shadow-cljs + javy

ghaskins 2025-01-07T23:55:31.190209Z

It works quite nicely, and could be adapted to a general solution outside of our concept of lambda functions

Matthias Schuster 2025-01-08T00:08:22.443559Z

My plan is to use Clojurescript --> Javy

Matthias Schuster 2025-01-08T00:10:35.787049Z

Thanks a lot for your tip!

ghaskins 2025-01-08T00:17:38.981139Z

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

Matthias Schuster 2025-01-07T22:24:40.182359Z

I also set Main-Class to main.clj

p-himik 2025-01-07T22:27:43.465879Z

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.

👍 1
💯 1