Skip to content

feat(dynamic-import-vars): support modules imported with import attributes in Rollup 5 - #2065

Open
lukastaegert wants to merge 1 commit into
masterfrom
feat/rollup-5/dynamic-import-vars
Open

lukastaegert wants to merge 1 commit into
masterfrom
feat/rollup-5/dynamic-import-vars

Conversation

@lukastaegert

Copy link
Copy Markdown
Member

Rollup Plugin Name: dynamic-import-vars

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.

Filtering is handled by @rollup/pluginutils 5.6.0, whose createFilter now strips the attribute suffix, so the plugin depends on that version. Two user-visible strings still used the encoded id: the No files found in ... when trying to load ... from <id> error and the file field of the emitted sourcemap.

Both now use the raw id. The tests assert the exact error text and the sourcemap file name and fail without the change.

Note: rewritten dynamic import() calls still drop import attributes because the plugin works on the original ImportExpression arguments. That is a pre-existing limitation independent of this change.

…butes in Rollup 5

Rollup 5 appends an encoded attributes suffix to module ids. The "No files found" error text and the sourcemap file now use the rawId passed to the transform hook instead, so modules imported with import attributes are handled like their plain counterparts.
The plugin now requires @rollup/pluginutils ^5.6.0, whose createFilter strips the attributes suffix itself, so the filter keeps taking the hook id.
The tests cover the attribute-encoded id together with rawId for both cases and through a real build, and the two-argument hook call that Rollup 1-4 uses.
@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.

Reviews (1) · Last reviewed commit: "feat(dynamic-import-vars): support modul..." · 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