Repository navigation
feat(typescript): support modules imported with import attributes in Rollup 5 - #2074
Open
lukastaegert wants to merge 1 commit into
Open
lukastaegert wants to merge 1 commit into
lukastaegert wants to merge 1 commit into
Conversation
…Rollup 5 Rollup 5 appends an encoded attributes suffix to module ids. The load and resolve hooks now use the rawId/importerRawId they receive for watch files, TypeScript file lists and module resolution, so modules imported with import attributes are compiled like their plain counterparts. The load filter keeps using the composite id because @rollup/pluginutils 5.6.0 strips the attributes suffix itself; the plugin now requires @rollup/pluginutils ^5.6.0. The tests pass the attribute-encoded id together with the raw id, pin the resolve hook's importerRawId for node16 module resolution, and cover the hook calls that Rollup 2-4 still use; the attribute tests are skipped below Rollup 5. The package-local @types/node is bumped to ^20.19.0 because rollup 5's type declarations reference Symbol.asyncDispose, which @types/node@14 no longer polyfills when it shadows the root @types/node@20 under the ES6 lib target.
lukastaegert
marked this pull request as ready for review
December 3, 2026 12:22
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rollup Plugin Name:
typescriptThis PR contains:
Are tests included?
Breaking Changes?
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 onfoo.jsnow seefoo.js?attributes=%7B%22type%22%3A%22json%22%7D.The plugin handed the encoded id to TypeScript:
addWatchFile, the file list TypeScript is configured with, and the output-file lookup all receivedfile.ts?attributes=%7B%22type%22%3A%22ts%22%7D, so attributed modules were not compiled by the plugin and Rollup fell back to parsing raw TypeScript.importerRawIdis likewise needed for the containing file undernode16/nodenext, where the encoded importer makes TypeScript pick therequireinstead of theimportcondition.Filtering stays on the composite id because
@rollup/pluginutils5.6.0 strips the attribute suffix itself, and the plugin now depends on that version. The package-local@types/nodemoves to ^20.19.0 because rollup 5's declarations referenceSymbol.asyncDispose, which@types/node@14no longer polyfills when it shadows the root@types/node@20under thees6lib.The tests cover attribute bundling, the no-options
loadcall that Rollup 2-4 use, and the resolve hook'simporterRawIdfor node16 module resolution; each fails without its part of the change.