Skip to content

feat(wasm): support rollup 5 - #2047

Open
lukastaegert wants to merge 2 commits into
masterfrom
wasm-rollup-5
Open

lukastaegert wants to merge 2 commits into
masterfrom
wasm-rollup-5

Conversation

@lukastaegert

Copy link
Copy Markdown
Member

Rollup Plugin Name: wasm

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

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$/ and createFilter, attributed Wasm imports were never loaded or transformed, and Rollup tried to parse the binary as JavaScript.

The load and transform hooks now use the rawId option 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.

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.
Copilot AI balanced review requested due to automatic review settings November 7, 2026 05:58
@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P2 Build tool outgrows Node 20 ▶

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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Build tool outgrows Node 20

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 rawId for 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()]
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