Repository navigation
Conversation
The UWASI platform wrappers imported `useAll` and `MemoryFileSystem`, so bundles always carried UWASI's in-memory file system and came out larger than the browser_wasi_shim default. Import `useStdio`, `useArgs`, `useEnviron`, `useClock`, `usePoll`, `useProc` and `useRandom` instead. File syscalls now return ENOSYS. With `--enable-code-coverage`, the Node wrapper adds `useMemoryFS`, because the test runner reads the coverage profile through `extractFile`. The browser wrapper never imports a file system.
krodak
force-pushed
the
kr/package-to-js-uwasi-minimal
branch
from
November 3, 2026 15:14
e89d7ae to
817304f
Compare
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
With
--wasi-runtime uwasi, the generated platform wrappers importuseAllandMemoryFileSystem, so every bundle ships UWASI's in-memory file system. That makes it larger than the@bjorn3/browser_wasi_shimdefault, and most apps never open a file.Bundled with esbuild (minified, gzip):
@bjorn3/browser_wasi_shim(current default)useAll(before)1. Default feature set
The wrappers now import
useStdio,useArgs,useEnviron,useClock,usePoll,useProcanduseRandom. A Swift executable needs args, environ, random, clock and proc to start, and wasi-libc needsfd_prestat_getto returnEBADFwhile it scans for preopens. Stdio also keeps runtime errors such asFatal error: Index out of rangevisible. File syscalls now returnENOSYS.2. Code coverage
With
--enable-code-coverage, the Node wrapper addsuseMemoryFS, because the test runner reads the coverage profile throughextractFile. The browser wrapper never imports a file system, and nothing importsuseAll.3. Custom setups
An app that needs a file system or a different feature set can pass its own
wasiobject to the generatedinstantiate.js. The README and the package output docs describe this. If that turns out to be too much work for users, we can add a config flag later.Test Plan
swift test --package-path ./Plugins/PackageToJSnode --test Plugins/PackageToJS/Tests/Inputs/UWASIAdapterTests.mjsExamples/NodeJSwith--wasi-runtime uwasi:node main.mjsprints the greeting, and the generated wrappers import no file systemprintandfopen: output works, andfopenfails without the file system