Skip to content

Add WASM support: --wasm flag with Node.js and Deno runtimes#1

Open
lostflydev wants to merge 123 commits into
mainfrom
scala-wasm-support
Open

Add WASM support: --wasm flag with Node.js and Deno runtimes#1
lostflydev wants to merge 123 commits into
mainfrom
scala-wasm-support

Conversation

@lostflydev
Copy link
Copy Markdown
Owner

Implements scala-cli issue VirtusLab#3316: integrate WebAssembly with Scala CLI.

What's added

  • --wasm CLI flag and //> using wasm directive to enable WASM output
  • --wasm-runtime <runtime> option and //> using wasmRuntime directive Supported values: node (default), deno, wasmtime, wasmedge, wasmer
  • --deno-version, --wasmtime-version, --wasmer-version options and corresponding directives for pinning runtime versions

Runtime support

@lostflydev lostflydev force-pushed the scala-wasm-support branch 5 times, most recently from c6453eb to ddfadbc Compare March 9, 2026 05:51
Gedochao and others added 3 commits March 9, 2026 13:33
…VirtusLab#4173)

Bumps the npm-dependencies group in /website with 1 update: [@algolia/client-search](https://github.com/algolia/algoliasearch-client-javascript).


Updates `@algolia/client-search` from 5.49.1 to 5.49.2
- [Release notes](https://github.com/algolia/algoliasearch-client-javascript/releases)
- [Changelog](https://github.com/algolia/algoliasearch-client-javascript/blob/main/CHANGELOG.md)
- [Commits](algolia/algoliasearch-client-javascript@5.49.1...5.49.2)

---
updated-dependencies:
- dependency-name: "@algolia/client-search"
  dependency-version: 5.49.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the github-actions group with 4 updates: [docker/login-action](https://github.com/docker/login-action), [docker/metadata-action](https://github.com/docker/metadata-action), [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) and [docker/build-push-action](https://github.com/docker/build-push-action).


Updates `docker/login-action` from 3 to 4
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v3...v4)

Updates `docker/metadata-action` from 5 to 6
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@v5...v6)

Updates `docker/setup-buildx-action` from 3 to 4
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@v3...v4)

Updates `docker/build-push-action` from 6 to 7
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v6...v7)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: docker/metadata-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: docker/setup-buildx-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: docker/build-push-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Gedochao and others added 16 commits March 12, 2026 11:42
Bumps [undici](https://github.com/nodejs/undici) from 7.18.2 to 7.24.1.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v7.18.2...v7.24.1)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 7.24.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the github-actions group with 1 update: [webfactory/ssh-agent](https://github.com/webfactory/ssh-agent).


Updates `webfactory/ssh-agent` from 0.9.1 to 0.10.0
- [Release notes](https://github.com/webfactory/ssh-agent/releases)
- [Changelog](https://github.com/webfactory/ssh-agent/blob/master/CHANGELOG.md)
- [Commits](webfactory/ssh-agent@a6f90b1...e838748)

---
updated-dependencies:
- dependency-name: webfactory/ssh-agent
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the npm-dependencies group in /website with 1 update: [sass](https://github.com/sass/dart-sass).


Updates `sass` from 1.97.3 to 1.98.0
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md)
- [Commits](sass/dart-sass@1.97.3...1.98.0)

---
updated-dependencies:
- dependency-name: sass
  dependency-version: 1.98.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@lostflydev lostflydev force-pushed the scala-wasm-support branch from 2d8329a to b37dae0 Compare May 15, 2026 15:45
Gedochao and others added 21 commits May 15, 2026 19:11
Restore BSP base directory to the original workspace regardless of permissions/ownership
…arn/website/npm-dependencies-863fd9a70c

Bump the npm-dependencies group in /website with 3 updates
…arn/website/webpack-dev-server-5.2.4

Bump webpack-dev-server from 5.2.2 to 5.2.4 in /website
Improve dependency update actionable diagnostic handling for slow/unresponsive custom repositories
* Add support for JSHELL in `repl`

* Add support for `--repl-init-script-file` to enable testing JSHELL on Windows

* Extract Jshell integration tests to a dedicated trait

* Test JSHELL with the supported JVMs

* Refactor

* Refactor some more

* Make JSHELL non-experimental

* Refactor some more

* Allow to run pure Java projects in Scala REPL

* Enable usage of Scala dependencies in pure Java projects

* Refactor some more
Improve error for when JVM-only dependencies are not found on other platforms
…#4287)

Bumps the npm-dependencies group in /website with 2 updates: [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) and [sass](https://github.com/sass/dart-sass).


Updates `@types/react` from 19.2.14 to 19.2.15
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

Updates `sass` from 1.99.0 to 1.100.0
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md)
- [Commits](sass/dart-sass@1.99.0...1.100.0)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-version: 19.2.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
- dependency-name: sass
  dependency-version: 1.100.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Implements scala-cli issue VirtusLab#3316: integrate WebAssembly with Scala CLI.

- `--wasm` CLI flag and `//> using wasm` directive to enable WASM output
- `--wasm-runtime <runtime>` option and `//> using wasmRuntime` directive
  Supported values: node (default), deno
- `--deno-version`, `--wasmtime-version`, `--wasmer-version` options
  and corresponding directives for pinning runtime versions

- **Node.js** (default): runs Scala.js WASM output with
  `--experimental-wasm-exnref` flag, requires Node.js >= 22
- **Deno**: runs Scala.js WASM output
…imes

- Move --wasm flag to dedicated Wasm help group with --help-wasm option
- Simplify wasmOptions parsing with fold/toRight pattern
- Add runtime validation with UnrecognizedWasmRuntimeError in directives
- Auto-enable WASM when wasmRuntime directive is set
- Update reference documentation

Code style: simplify denoNeedsWasmFlag, explicit runtime match cases, clean type annotation, scalfmt
…smRuntime bun)

  - Add BunNotFoundError with install hint
  - Add integration test for Bun (conditional on bun being on PATH)
  - Add actions/setup-node@v6 node-version:24 to all Linux integration test
    jobs: the default Node.js on ubuntu-24.04 runners is too old for Scala.js
    WASM GC (which requires Node.js >= 22). Matches docs-tests job which
    already pins node-version: 24
Node 24 still ships V8 12.x where wasm-exnref is gated behind --experimental-wasm-exnref; the flag only flips to default in V8 13.x (Node 25+). The previous nodeMajorVersion < 24 guard therefore left Node 24 (the version pinned in CI) without the flag, which made any Scala.js WASM code using exception bytecodes, runtime throws, JS interop or Scala 3 @main fail at runtime. Same reasoning applies to Deno (Deno 2.x = V8 12.x).

Until V8 13.x is the default everywhere, just always set the flag, there is no any overhead
…efactor into ScalaJsOptions

- Replace "WASM" with "Wasm" per WebAssembly spec: contraction, not acronym
- Fix nodeNeedsWasmFlag to be version-aware: only pass --experimental-wasm-exnref
  for Node < 25 (V8 12.x); Node 25+ has it enabled by default, Node 26+ may remove it
- Remove Node/Bun pre-flight version checks; let runtime fail naturally on old versions
- Remove else-if-emitWasm branch (not needed)
- Refactor WasmOptions into ScalaJsOptions: jsEmitWasm and wasmRuntime are now fields
  of ScalaJsOptions at both build and CLI layers; CLI flags are now --js-emit-wasm and
  --js-wasm-runtime under the Wasm help group; WasmOptions classes removed
- linkerConfig() now forces ESModule when jsEmitWasm=true
- Update all integration test CLI flags to --js-emit-wasm / --js-wasm-runtime
@lostflydev lostflydev force-pushed the scala-wasm-support branch from 6d26adc to 0022b06 Compare May 27, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants