Repository navigation
feat(wasm): support rollup 5 - #2047
lukastaegert wants to merge 2 commits into
Conversation
To test plugins against the upcoming Rollup 5 release.
Rollup 5 encodes import attributes in the module id, so the load and transform hooks rejected attributed .wasm imports and Rollup tried to parse the binary as JavaScript. Match on the rawId option instead, falling back to the id for older Rollup versions, and key emitted assets by the raw id so attribute variants share one asset. Disable tree-shaking in the target environment tests, which assert emitted helper code that Rollup 5 otherwise removes.
[Medium impact] The behavior change is limited to the Wasm plugin and its Rollup 5 compatibility. The plugin changes appear safe to merge, with a non-blocking build-environment mismatch to address. Findings
Reviews (1) · Last reviewed commit: "feat(wasm): support rollup 5" · Reviewed by Greptile |
| "@rollup/plugin-typescript": "^9.0.1", | ||
| "del-cli": "^5.0.0", | ||
| "rollup": "^4.0.0-24", | ||
| "rollup": "catalog:rollup-next", |
There was a problem hiding this comment.
Both CI matrices and .nvmrc still select Node 20, but catalog:rollup-next selects Rollup 5, which requires Node 22.22.0 or newer. The package's build script runs that Rollup directly, putting local builds and the Node 20 CI jobs outside its supported environment. Update the build environment alongside this dependency, or keep a supported build tool for Node 20.
There was a problem hiding this comment.
🟡 Changes recommended
Rollup 5.0.0-2 requires Node >=22.22.0, but CI still runs the Wasm build and tests on Node 20, leaving those jobs on an unsupported runtime.
2 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Adds Rollup 5 compatibility to the Wasm plugin, addressing attribute-encoded module IDs while retaining fallback behavior for earlier Rollup versions.
Changes:
- Uses
rawIdfor filtering, file access, sync matching, and emitted-asset tracking. - Adds import-attribute tests and disables tree-shaking in environment-specific tests.
- Extends the Rollup peer range and selects Rollup 5 for development.
| File | Description |
|---|---|
pnpm-workspace.yaml |
Adds the shared Rollup 5 development catalog. |
pnpm-lock.yaml |
Locks Rollup 5 and its dependency resolutions. |
packages/wasm/test/test.mjs |
Tests attributed imports and asset deduplication; adjusts environment tests. |
packages/wasm/test/fixtures/attributes.js |
Exercises execution of an attributed Wasm import. |
packages/wasm/test/fixtures/attributes-and-plain.js |
Imports one Wasm file with and without attributes. |
packages/wasm/src/index.ts |
Handles attributed module IDs through rawId. |
packages/wasm/package.json |
Declares Rollup 5 support and updates the development dependency. |
Review effort: Balanced
| "@rollup/plugin-typescript": "^9.0.1", | ||
| "del-cli": "^5.0.0", | ||
| "rollup": "^4.0.0-24", | ||
| "rollup": "catalog:rollup-next", |
| expect.assertions(1); | ||
| const bundle = await rollup({ | ||
| input: 'fixtures/attributes.js', | ||
| plugins: [wasmPlugin()] |


Rollup Plugin Name:
wasmThis PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
Rollup 5 makes import attributes part of module identity, so the id of an attributed import is the file path with an encoded
?attributes=...suffix. As the plugin matched ids with/\.wasm$/andcreateFilter, attributed Wasm imports were never loaded or transformed, and Rollup tried to parse the binary as JavaScript.The
loadandtransformhooks now use therawIdoption for the filter, the extension check, the watched file, the file operations and the key of the emitted asset map, falling back to the id for earlier Rollup versions that do not pass it. Keying assets by the raw id keeps a single emitted file when the same Wasm is imported with different attributes.The target environment tests now run without tree-shaking since Rollup 5 removes the helper branches they assert on.