Refactor Rollup filtering#2672
Open
remcohaszing wants to merge 2 commits intomainfrom
Open
Conversation
This change refactors how we filter Rollup IDs. In #2629 we stripped any query parameters before further processing. This is correct for our extension based filtering, but turned out to be incorrect for the Rollup filtering. We defined the Rollup plugin `transform` property as a handler function. This is valid, but it’s also valid to define it as an object which has an additional `filter` property. This property defines filters, which work the same as the `filter` function from `@rollup/pluginutils`. This is now used instead, removing the dependency on `@rollup/pluginutils`. This also means we no longer need a peer dependency on `rollup`. We now use the `vite.Plugin` type annotation to get type inference for the plugin implementation. This extends `rollup.Plugin`. This import is internal only, it isn’t exposed. The plugin type is exposed as the minimal shape required to satisfy the Rollup/Vite plugin constraints. It only defines `name`. Closes #2657 Closes #2671
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2672 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 21
Lines 2649 2649
Branches 2 2
=========================================
Hits 2649 2649 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
remcohaszing
commented
Mar 27, 2026
| }) | ||
| } | ||
| transform: { | ||
| filter: { |
Member
Author
There was a problem hiding this comment.
Actually it looks like support for filter was added in Rollup 4.38.0 (rollup/rollup#5882). So we can’t use it without a breaking change.
6 tasks
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.
Initial checklist
Description of changes
This change refactors how we filter Rollup IDs.
In #2629 we stripped any query parameters before further processing. This is correct for our extension based filtering, but turned out to be incorrect for the Rollup filtering.
We defined the Rollup plugin
transformproperty as a handler function. This is valid, but it’s also valid to define it as an object which has an additionalfilterproperty. This property defines filters, which work the same as thefilterfunction from@rollup/pluginutils. This is now used instead, removing the dependency on@rollup/pluginutils. This also means we no longer need a peer dependency onrollup.We now use the
vite.Plugintype annotation to get type inference for the plugin implementation. This extendsrollup.Plugin. This import is internal only, it isn’t exposed.The plugin type is exposed as the minimal shape required to satisfy the Rollup/Vite plugin constraints. It only defines
name.I tested all of this against a React Router project with Vite 7, including the
?rawquery parameter.Closes #2657
Closes #2671