Skip to content

PackageToJS: Add selectable UWASI runtime - #811

Draft
krodak wants to merge 1 commit into
swiftwasm:mainfrom
PassiveLogic:kr/package-to-js-uwasi
Draft

PackageToJS: Add selectable UWASI runtime#811
krodak wants to merge 1 commit 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. The selected runtime flows through template preprocessing, generated browser and Node setup, package metadata, and MiniMake cache fingerprints.

The UWASI adapter uses the public WASI.setInstance and lineBuffered APIs from swiftwasm/uwasi#26. Browser main-thread setup rejects blocking poll_oneoff waits instead of busy-waiting, while browser workers and Node retain UWASI's blocking implementation.

1. Package generation

  • Add the WASIRuntime option and CLI parsing.
  • Generate the UWASI helper only when selected.
  • Preserve existing output when the option is omitted.

2. Adapter behavior

  • Delegate instance binding and line buffering to UWASI.
  • Preserve PackageToJS's Node extractFile contract.
  • Apply the fail-fast sleep policy only when a browser document is present.

3. Tests and documentation

  • Type-check browser, Node, and shared-memory template variants.
  • Snapshot the UWASI planner graph.
  • Exercise only PackageToJS-owned adapter wiring.
  • Document the CLI option and generated package shape.

Todo

Test Plan

  • npm ci
  • ./Utilities/format.swift
  • swift test --package-path ./Plugins/PackageToJS
  • node --test Plugins/PackageToJS/Tests/Inputs/UWASIAdapterTests.mjs
  • swift format lint --strict Plugins/PackageToJS/Sources/PackageToJS.swift Plugins/PackageToJS/Sources/PackageToJSPlugin.swift Plugins/PackageToJS/Tests/TemplatesTests.swift Plugins/PackageToJS/Tests/PackagingPlannerTests.swift
  • git diff --check

@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
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.

1 participant