Skip to content

feat(json): add Rollup 5 compatibility - #2017

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

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

Conversation

@TrickyPi

@TrickyPi TrickyPi commented Jul 26, 2026 •

Copy link
Copy Markdown
Member

Rollup Plugin Name: json

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

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:
related to rollup/rollup#6266

Description

Rollup 5 will support importing the same module with different import attributes. As a result, the id passed as the second argument to the transform hook may include encoded import attributes, causing the existing id.slice(-5) !== '.json' check to incorrectly skip JSON modules.
This PR uses transformOptions.rawId for the JSON extension check when it is available and falls back to id for compatibility with earlier Rollup versions.

@TrickyPi
TrickyPi requested a review from shellscape as a code owner July 26, 2026 12:38
@TrickyPi TrickyPi changed the title feat: add Rollup 5 compatibility feat(json): add Rollup 5 compatibility Jul 26, 2026
@shellscape

Copy link
Copy Markdown
Collaborator

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Reviews (9) · Last reviewed commit: "feat(json): add Rollup 5 compatibility" · Reviewed by Greptile

Comment thread packages/json/src/index.js Resolved

@lukastaegert lukastaegert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, thank you for taking care! I had a look at the changes and the fix looks good, however it would be nice to extend the testing a little more.
The pre-release version of rollup@5 is now basically complete, so we could switch the json plugin to directly test with this version. Maybe you can do it like #2037, #2038, #2039 by defining a catalog version? Then all other update PRs can also use that.

Comment thread packages/json/test/test.js Resolved
@lukastaegert

Copy link
Copy Markdown
Member

As I managed to get a review for the babel plugin and merge/release that one, could you merge/rebase on latest master, then the catalog version commit can be dropped and I would approve and merge this one.

@TrickyPi

TrickyPi commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

As I managed to get a review for the babel plugin and merge/release that one, could you merge/rebase on latest master, then the catalog version commit can be dropped and I would approve and merge this one.

Done! I updated my other PRs (#2050, #2051, #2052, #2054, #2055, #2056, #2057) the same way too.

@lukastaegert
lukastaegert force-pushed the feat/rollup-5/json branch 2 times, most recently from 79a9d94 to 7e69580 Compare December 3, 2026 15:55
Rollup 5 appends an encoded attributes suffix to the id of a module imported with attributes, so the id no longer ends in `.json` and the include/exclude filter saw a different path.

The extension check now uses the `rawId` the hook receives, and the plugin requires `@rollup/pluginutils` ^5.6.0, whose `createFilter` strips the attribute suffix before matching. That also moves the lockfile from pluginutils 5.1.0 to 5.6.0, picking up the `dataToEsm` change from rollup#2002 that consumers already resolve through `^5.1.0`: reserved-word keys such as `function` and `null` are now also exported by name, so four snapshots change.

The tests bundle a JSON module imported with attributes and check that include patterns match and exclude patterns do not match the encoded id; the bundle test is skipped below Rollup 5.

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 were identified for the JSON plugin’s Rollup 5 compatibility update.

No open issues 🎉

1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

Adds Rollup 5 compatibility to the JSON plugin while preserving support for earlier Rollup versions.

Changes:

  • Uses transformOptions.rawId, when available, for JSON extension checks.
  • Updates dependencies and tests against the Rollup 5 prerelease.
  • Adds import-attribute tests and refreshes generated-code snapshots.
File Description
pnpm-lock.yaml Locks updated plugin utilities and Rollup dependencies.
packages/​json/​test/​test.js Adds import-attribute conversion and filtering tests.
packages/​json/​test/​snapshots/​test.js.snap Updates expected reserved-name exports.
packages/​json/​test/​fixtures/​with-type/​main.js Imports JSON with a type attribute.
packages/​json/​test/​fixtures/​with-type/​config.json Provides JSON fixture data.
packages/​json/​src/​index.js Checks the JSON extension using the raw module ID.
packages/​json/​package.json Declares Rollup 5 support and updates dependencies.

Review effort: Balanced

@lukastaegert
lukastaegert merged commit f303b50 into rollup:master Dec 4, 2026
6 checks passed

@lukastaegert lukastaegert left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

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.

4 participants