Skip to content

feat(wasm): support rollup 5 - #2047

Merged
lukastaegert merged 1 commit into
masterfrom
wasm-rollup-5
Dec 4, 2026
Merged

lukastaegert merged 1 commit into
masterfrom
wasm-rollup-5

Conversation

@lukastaegert

@lukastaegert lukastaegert commented Nov 7, 2026 •

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 extension check, the file access, the watched file, the emitted file name and the asset and sync lookups, 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 include/exclude filter relies on @rollup/pluginutils ^5.6.0, which strips the attribute suffix before matching. The peer range is extended to Rollup 5 and the package tests against rollup@5.0.0-5 through the rollup-next catalog.

The attributes build test uses an include pattern, so it also covers that filtering works on attributed ids — which it only does because @rollup/pluginutils 5.6.0 strips the suffix before matching. Both new build tests are skipped below Rollup 5, where ids carry no attributes.

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

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Plain or attributed Wasm import] --> B[Filter without attribute suffix]
  B --> C[Read and watch rawId]
  C --> D{Inline or synchronous?}
  D -->|Yes| E[Loader with embedded bytes]
  D -->|No| F[Store asset by rawId]
  F --> G[Loader with public path]
  F --> H[Emit one asset per rawId]
Loading

Reviews (5) · Last reviewed commit: "feat(wasm): support rollup 5" · Reviewed by Greptile

Comment thread packages/wasm/package.json Resolved

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

Comment thread packages/wasm/package.json Resolved
Comment thread packages/wasm/test/test.mjs Resolved
Rollup 5 encodes import attributes into the module id, so the load and transform hooks received ids like `sample.wasm?attributes=...` and rejected the module, after which Rollup tried to parse the binary as JavaScript.

The hooks now use the `rawId` they receive for the extension check, the file access, the watched file, the emitted file name and the asset and sync lookups, so the plain and attributed variants of a module share one asset. The include/exclude filter relies on `@rollup/pluginutils` ^5.6.0, which strips the attribute suffix before matching, and the peer range is extended to Rollup 5.

Two build tests cover loading a `.wasm` module imported with attributes and that importing it with and without attributes emits a single asset which both variants load from. Both are skipped below Rollup 5, where ids carry no attributes.

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.

🟢 Approved

No active review issues block the Wasm plugin’s Rollup 5 compatibility changes.

No open issues 🎉

2 resolved since last review
1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

@lukastaegert
lukastaegert merged commit 01f904e into master Dec 4, 2026
12 checks passed
@lukastaegert
lukastaegert deleted the wasm-rollup-5 branch December 4, 2026 12:21
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