Skip to content

feat(commonjs): support Rollup 5 and import attributes - #2057

Merged
lukastaegert merged 1 commit into
rollup:masterfrom
TrickyPi:feat/rollup-5/commonjs
Dec 4, 2026
Merged

lukastaegert merged 1 commit into
rollup:masterfrom
TrickyPi:feat/rollup-5/commonjs

Conversation

@TrickyPi

@TrickyPi TrickyPi commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Rollup Plugin Name: commonjs

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

Support Rollup 5 (^5.0.0) and import attributes in @rollup/plugin-commonjs (still compatible with Rollup 2–4).

Because Rollup 5 encodes import attributes into module IDs, suffix checks like ?commonjs-es-import and proxy generation broke when a CJS module was imported with attributes. This switches those checks to rawId / importerRawId with fallbacks for older Rollup versions, and forwards resolved import attributes through proxies, this.load, this.getModuleInfo, and extension resolution.

@TrickyPi
TrickyPi requested a review from shellscape as a code owner November 28, 2026 03:54
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The reviewed changes appear safe to merge; no actionable defects were established.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Import with attributes] --> B[Resolve CommonJS module]
  B --> C[Load and transform module]
  C --> D[Create entry or import proxy]
  D --> E[Forward resolved attributes]
  E --> F[Import wrapped module]
Loading

Reviews (4) · Last reviewed commit: "feat(commonjs): support Rollup 5 and imp..." · Reviewed by Greptile

Rollup 5 appends import attributes to module ids and passes raw ids and
attributes to plugin hooks. CommonJS proxies only knew the plain id, so entry
proxies threw as getModuleInfo(plainId) returned null and modules imported with
attributes were loaded as a second instance.

Use raw ids where an id is path shaped or user visible, pass id plus attributes
where a module instance is addressed, keep them through extension resolution and
repeat them on the proxy's own import so that it targets the same instance.
Attributes are only stripped where an id feeds a generated variable name.

Bump `@rollup/pluginutils` to `^5.6.0`, whose `createFilter` strips attributes.

# Conflicts:
#	pnpm-lock.yaml
@lukastaegert
lukastaegert force-pushed the feat/rollup-5/commonjs branch from 2d9e138 to 5cbca64 Compare December 4, 2026 12:53
@lukastaegert
lukastaegert merged commit 9fec772 into rollup:master Dec 4, 2026
6 checks passed
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