This repository is a proof of concept about the process of calling WASM code generated in Rust from ClojureScript through JavaScript interoperability.
To run this project you need Rust and Clojure.
I am using clojure 1.10.2
, rustup 1.26.0
(stable channel) and rustc 1.70.0
.
This project includes a makefile
that will automatically:
- install some tools with specific versions
- build wasm
- copy wasm files to web site project
- build web site
- serve web site
You can run it executing:
make
I didn't found a way to serve the web site using ClojureScript. That means, that we cannot use the REPL. If you try to do that, you will find the following problem:
TypeError: WebAssembly: Response has unsupported MIME type 'text/html; charset=utf-8' expected 'application/wasm'
and
Uncaught CompileError: wasm validation error: at offset 4: failed to match magic number
If you search for the first error message you will find https://clojure.atlassian.net/browse/CLJS-3387. The problem seems to be solved, but Will Cohen complains that is still not working.
If you want to check that error. You have to move out
, wasm
and index.html
from clojurescript-addition/public
to clojurescript-addition/
. Then run clojure -M -m cljs.main -c addition.core --repl
.
Probably, you are going to build a web site using ClojureScript with a build tool. If you are going to use shadow cljs. I highly recommend that you take a look into a demo using wasm with clojurescript from the shadow cljs creator.