PackageToJS: Add selectable UWASI runtime - #811
Merged
Conversation
krodak
force-pushed
the
kr/package-to-js-uwasi
branch
from
September 4, 2026 09:40
f850b1f to
e0b98d8
Compare
krodak
marked this pull request as ready for review
September 7, 2026 11:13
kateinoigakukun
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add
--wasi-runtime uwasito PackageToJS while preserving@bjorn3/browser_wasi_shimas the default. Generated packages, CDN imports, andadapter tests use the published
uwasi@1.5.2, including the host APIs fromswiftwasm/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.setInstanceandlineBufferedAPIs and preserve Node'sextractFilecontract. Reject blockingpoll_oneoffwaits on the browser mainthread; 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 ciswift test --package-path ./Plugins/PackageToJSswift format lint --strict Plugins/PackageToJS/Sources/PackageToJS.swift Plugins/PackageToJS/Sources/PackageToJSPlugin.swift Plugins/PackageToJS/Tests/TemplatesTests.swift Plugins/PackageToJS/Tests/PackagingPlannerTests.swiftExamples/NodeJS:swift package --swift-sdk swift-6.3-RELEASE_wasm js --wasi-runtime uwasi, thennode main.mjs.uwasi@1.5.2CDN module and checked required exports.