Skip to content

Add wasip1 npm build target - #4733

Draft
jakebailey wants to merge 2 commits into
mainfrom
jabaile/wasip1
Draft

Add wasip1 npm build target#4733
jakebailey wants to merge 2 commits into
mainfrom
jabaile/wasip1

Conversation

@jakebailey

@jakebailey jakebailey commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes #4633
Fixes #4706

This does not bundle teh lib.d.ts files in the binary, but instead assumes that tsc.wasm will live in the right place, which implies the host has mounted the files. I feel like this is probably fine, but, maybe it's not.

Copilot AI review requested due to automatic review settings July 24, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an official WASI Preview 1 WebAssembly npm build target and avoids unsupported signal handling under WASI.

Changes:

  • Publishes standalone wasip1/wasm platform packages.
  • Produces .wasm binaries with adjacent TypeScript libraries.
  • Replaces signal watchers with cancellable contexts on WASI.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Herebyfile.mjs Adds WASI packaging, naming, and release support.
cmd/tsgo/main.go Introduces WASI-safe context creation.
cmd/tsgo/lsp.go Uses the WASI-safe context for LSP.
cmd/tsgo/api.go Uses the WASI-safe context for API mode.

Comment thread Herebyfile.mjs
...inputPackageJson,
name: mainNativePreviewPackage.npmPackageName,
optionalDependencies: Object.fromEntries(platforms.map(p => [p.npmPackageName, getVersion()])),
optionalDependencies: Object.fromEntries(platforms.filter(p => p.nodeOs !== "wasip1").map(p => [p.npmPackageName, getVersion()])),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's basically expected at this stage, unless we make the shim able to load in Node the wasm blob, which, as far as I can tell is unstable. But I need to recheck.

@jakebailey

Copy link
Copy Markdown
Member Author

wasip1 lacks os.Executable, so this breaks, currently.

@jakebailey
jakebailey marked this pull request as draft July 24, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants