GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PackageToJS: Import only the UWASI features Swift needs by krodak · Pull Request #827 · swiftwasm/JavaScriptKit

Conversation

@krodak

@krodak krodak commented Nov 3, 2026

Copy link
Copy Markdown
Member

Overview

With --wasi-runtime uwasi, the generated platform wrappers import useAll and MemoryFileSystem, so every bundle ships UWASI's in-memory file system. That makes it larger than the @bjorn3/browser_wasi_shim default, and most apps never open a file.

Bundled with esbuild (minified, gzip):

Setup Size
@bjorn3/browser_wasi_shim (current default) 4.9 KB
UWASI with useAll (before) 8.8 KB
UWASI without the file system (after) 4.8 KB

1. Default feature set

The wrappers now import useStdio, useArgs, useEnviron, useClock, usePoll, useProc and useRandom. A Swift executable needs args, environ, random, clock and proc to start, and wasi-libc needs fd_prestat_get to return EBADF while it scans for preopens. Stdio also keeps runtime errors such as Fatal error: Index out of range visible. File syscalls now return ENOSYS.

2. Code coverage

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, and nothing imports useAll.

3. Custom setups

An app that needs a file system or a different feature set can pass its own wasi object to the generated instantiate.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/PackageToJS
  • node --test Plugins/PackageToJS/Tests/Inputs/UWASIAdapterTests.mjs
  • Examples/NodeJS with --wasi-runtime uwasi: node main.mjs prints the greeting, and the generated wrappers import no file system
  • A Swift executable that calls print and fopen: output works, and fopen fails without the file system

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krodak
PackageToJS: Import only the UWASI features Swift needs
817304f
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 krodak self-assigned this Nov 3, 2026
@krodak
krodak requested a review from kateinoigakukun November 3, 2026 15:49
kateinoigakukun
kateinoigakukun approved these changes Nov 4, 2026
View reviewed changes
@krodak
krodak merged commit 3f1087c into swiftwasm:main Nov 4, 2026
16 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kateinoigakukun kateinoigakukun kateinoigakukun approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@krodak krodak

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@krodak @kateinoigakukun
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.