Skip to content

Refactor Rollup filtering#2672

Open
remcohaszing wants to merge 2 commits intomainfrom
rollup
Open

Refactor Rollup filtering#2672
remcohaszing wants to merge 2 commits intomainfrom
rollup

Conversation

@remcohaszing
Copy link
Copy Markdown
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

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 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.

I tested all of this against a React Router project with Vite 7, including the ?raw query parameter.

Closes #2657
Closes #2671

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
@remcohaszing remcohaszing added 🐛 type/bug This is a problem 📦 area/deps This affects dependencies 🗄 area/interface This affects the public interface ☂️ area/types This affects typings 👶 semver/patch This is a backwards-compatible fix 🤞 phase/open Post is being triaged manually labels Mar 20, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (579f20e) to head (40b625c).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

})
}
transform: {
filter: {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 area/deps This affects dependencies 🗄 area/interface This affects the public interface ☂️ area/types This affects typings 🤞 phase/open Post is being triaged manually 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem

Development

Successfully merging this pull request may close these issues.

Create a new @mdx-js/rolldown package Cannot use query parameters in Vite import.meta.glob

1 participant