Skip to content

feat(data-uri): support modules imported with import attributes in Rollup 5 - #2064

Open
lukastaegert wants to merge 1 commit into
masterfrom
feat/rollup-5/data-uri
Open

lukastaegert wants to merge 1 commit into
masterfrom
feat/rollup-5/data-uri

Conversation

@lukastaegert

Copy link
Copy Markdown
Member

Rollup Plugin Name: data-uri

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes
  • no

Breaking Changes?

  • yes
  • no

List any relevant issue numbers:

#2037

Description

Rollup 5 appends an encoded ?attributes=... suffix to the id of every module imported with import attributes, so hooks that ran on foo.js now see foo.js?attributes=%7B%22type%22%3A%22json%22%7D.

The plugin resolves data: ids itself and remembers the decoded content in order to return it from load. Under Rollup 5 the load hook receives the attribute-encoded id, the lookup missed, and Rollup fell back to reading the id as a file, failing with Could not load data:application/json,...?attributes=... ENOENT.

load now looks the id up by its rawId, falling back to the id itself for Rollup 1-4 and other callers that pass no hook options. The attribute tests cover the bundling case and the two-argument hook call.

…llup 5

Rollup 5 appends an encoded attributes suffix to module ids. The `load` hook now resolves the cached data URI through the `rawId` it receives, falling back to `id` when the hook is called with a single argument as in Rollup 1-4, so data URIs imported with attributes are decoded instead of being read from disk.
The tests bundle a fixture that imports a data URI with attributes and also call `load` directly with a Rollup 5 shaped id alongside a Rollup 1-4 shaped call.
`@rollup/pluginutils` is bumped to ^5.6.0 for dependency alignment, not for behaviour: the plugin only uses `dataToEsm`.
@lukastaegert
lukastaegert marked this pull request as ready for review December 3, 2026 12:23
@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

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

Reviews (1) · Last reviewed commit: "feat(data-uri): support modules imported..." · Reviewed by Greptile

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.

1 participant