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 [email protected], 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
[email protected] CDN module and checked required exports.
- Checked real UWASI line buffering, shared-memory binding, and relative/missing/directory file extraction.