Skip to content

PackageToJS: Add selectable UWASI runtime - #811

Merged
krodak merged 2 commits into
swiftwasm:mainfrom
PassiveLogic:kr/package-to-js-uwasi
Sep 7, 2026
Merged

PackageToJS: Add selectable UWASI runtime#811
krodak merged 2 commits into
swiftwasm:mainfrom
PassiveLogic:kr/package-to-js-uwasi

Conversation

@krodak

@krodak krodak commented Sep 4, 2026

Copy link
Copy Markdown
Member

Overview

Add --wasi-runtime uwasi to PackageToJS while preserving
@bjorn3/browser_wasi_shim as the default. Generated packages, CDN imports, and
adapter tests use the published uwasi@1.5.2, including the host APIs from
swiftwasm/uwasi#26.

1. Package generation

Pass the selected runtime through CLI parsing, template preprocessing, package
metadata, and MiniMake cache fingerprints. Generate the UWASI helper only when
selected.

2. Adapter behavior

Use UWASI's public WASI.setInstance and lineBuffered APIs and preserve Node's
extractFile contract. Reject blocking poll_oneoff waits on the browser main
thread; Node and browser workers retain UWASI's blocking implementation.

3. Tests and documentation

Type-check browser, Node, and shared-memory templates, snapshot the UWASI planner
graph, test adapter wiring, and document runtime selection. Freeze the monotonic
clock in the sleep-policy test so its deadline cannot expire before the callback.

Test Plan

  • npm ci
  • swift test --package-path ./Plugins/PackageToJS
  • swift format lint --strict Plugins/PackageToJS/Sources/PackageToJS.swift Plugins/PackageToJS/Sources/PackageToJSPlugin.swift Plugins/PackageToJS/Tests/TemplatesTests.swift Plugins/PackageToJS/Tests/PackagingPlannerTests.swift
  • In Examples/NodeJS: swift package --swift-sdk swift-6.3-RELEASE_wasm js --wasi-runtime uwasi, then node main.mjs.
  • Loaded the uwasi@1.5.2 CDN module and checked required exports.
  • Checked real UWASI line buffering, shared-memory binding, and relative/missing/directory file extraction.

@krodak krodak self-assigned this Sep 4, 2026
@krodak
krodak force-pushed the kr/package-to-js-uwasi branch from f850b1f to e0b98d8 Compare September 4, 2026 09:40
@krodak
krodak marked this pull request as ready for review September 7, 2026 11:13
@krodak
krodak merged commit 991755e into swiftwasm:main Sep 7, 2026
16 checks passed
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.

2 participants