This is a friendly fork of Scala.js, targeting stand-alone Wasm runtimes such as wasmtime, leveraging WASIp2 and Wasm Component Model.
- wasm-tools
- wasmtime
- (optional) wkg
- Required if you wanna add Wasm Component Model dependencies.
- optional (required for running
test-component-model
)- wac
- Setting up Rust
- cargo component
cargo component >= 0.18.0
may not work(?)
Copy of test-suites
that works without JS-interop (except for some "essential imports").
sbt:Scala.js> set Global/enableWasmEverywhere := true
sbt:Scala.js> testSuiteWASI2_12/run
Test suites for Wasm Component Model based interop.
Build Wasm Compoennt from Scala.
$ sbt
sbt:Scala.js> set Global/enableWasmEverywhere := true
sbt:Scala.js> testComponentModel2_12/fastLinkJS
$ cd examples/test-component-model
$ wasm-tools component embed wit .2.12/target/scala-2.12/testing-module-for-component-model-fastopt/main.wasm -o main.wasm -w scala --encoding utf16
$ wasm-tools component new main.wasm -o main.wasm
Build Wasm Components from Rust.
$ cd examples/test-component-model/rust-exports
$ cargo component build --target wasm32-wasip2 -r
$ cd examples/test-component-model/rust-run
$ cargo component build --target wasm32-wasip2 -r
Compose Wasm Components and run.
$ wac plug --plug rust-exports/target/wasm32-wasip1/release/rust_exports.wasm main.wasm -o scala.wasm
$ wac plug --plug scala.wasm rust-run/target/wasm32-wasip1/release/rust_run.wasm -o out.wasm
$ wasmtime -W function-references,gc -C collector=null out.wasm
Once we implement wit-bindgen
for us, this tests should migrate to https://github.com/bytecodealliance/wit-bindgen
What follows below is README.md
of the upstream scala-js project
Chat: #scala-js on Discord.
This is the repository for Scala.js, the Scala to JavaScript compiler.
Scala.js is distributed under the Apache License Version 2.0.