Skip to content

feat(wasm): support wasm modules in ESM output with compile and preserve modes#1726

Open
elecmonkey wants to merge 5 commits into
mainfrom
feat/wasm-phase-1
Open

feat(wasm): support wasm modules in ESM output with compile and preserve modes#1726
elecmonkey wants to merge 5 commits into
mainfrom
feat/wasm-phase-1

Conversation

@elecmonkey

Copy link
Copy Markdown
Member

Summary

Add a wasm library option to control how .wasm modules are handled in ESM output.

wasm.mode:

  • 'compile' — Rspack parses the .wasm module and generates the JS glue and runtime to load it.
  • 'preserve' — keep .wasm as a real ESM import and emit the binary. In bundle mode the binary is emitted as a content-hashed asset; in bundleless mode it keeps the source-relative path and original filename.

When mode is unset, it defaults to 'compile' for bundle: true and 'preserve' for bundle: false. The option is only effective for format: 'esm'.

Includes integration tests covering compile/preserve × bundle/bundleless, and a new WebAssembly guide (EN + ZH) documenting the modes, supported import forms (static, dynamic, import source, import.source()), and wasm-bindgen usage.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings June 28, 2026 16:23

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rslib with  Cloudflare Pages  Cloudflare Pages

Latest commit: 012cf20
Status: ✅  Deploy successful!
Preview URL: https://e6214e9a.rslib.pages.dev
Branch Preview URL: https://feat-wasm-phase-1.rslib.pages.dev

View logs

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.

2 participants