This is a friendly fork of Scala.js, targeting stand-alone Wasm runtimes such as wasmtime, leveraging WASIp2 and Wasm Component Model.
scala-wasm is available as 1.21.1-wasm.4.
In project/plugins.sbt:
addSbtPlugin("io.github.scala-wasm" % "sbt-scalajs" % "1.21.1-wasm.4")cargo install wit-bindgen-scala --version 0.1.0-rc.1- (optional) wkg
- Required if you want to add Wasm Component Model dependencies.
- (optional) Required for running
test-component-model:- wac
- Setting up Rust
- cargo component
cargo component >= 0.18.0may not work(?)
sbt:Scala.js> set Global/enableWasmEverywhere := true
sbt:Scala.js> set scalaJSLinkerConfig in testSuite.v2_12 ~= (_.withModuleKind(ModuleKind.MinimalWasmModule))
sbt:Scala.js> testSuite2_12/testTests that do not link in pure Wasm are filtered out from unmanagedSourceDirectories and sources, see testSuiteCommonSettings.
Test suites for Wasm Component Model based interop.
Build Wasm Component from Scala.
$ sbt
sbt:Scala.js> set Global/enableWasmEverywhere := true
sbt:Scala.js> testComponentModel2_12/fastLinkJSBuild 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 -rCompose Wasm Components and run.
$ cd examples/test-component-model
$ make run SCALA_VERSION=2.12What 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.