shadaj/scala-native-wasm
Running Scala in WebAssembly through Scala Native
{ "createdAt": "2019-01-12T05:03:30Z", "defaultBranch": "master", "description": "Running Scala in WebAssembly through Scala Native", "fullName": "shadaj/scala-native-wasm", "homepage": null, "language": "Scala", "name": "scala-native-wasm", "pushedAt": "2019-01-12T05:03:41Z", "stargazersCount": 107, "topics": [], "updatedAt": "2025-06-21T12:21:36Z", "url": "https://github.com/shadaj/scala-native-wasm"}Scala Native on WebAssembly Demo
Section titled “Scala Native on WebAssembly Demo”First, locally publish https://github.com/scala-native/scala-native/pull/1363 with sbt rebuild_x32.
Then, run the Scala Native linker with sbt nativeLink, this will produce errors during compilation and linking, but this is okay because we only care about the generated LLVM.
Finally, run Emscripten to compile to WebAssembly:
emcc target/scala-2.11/native/lib/*.c target/scala-2.11/native/lib/gc/none/**.c target/scala-2.11/native/lib/*.cpp target/scala-2.11/native/*.ll -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o index.htmlThen open up index.html in a web browser (you may need to serve the directory as a local server due to security restrictions).