Skip to content

feat: add filter #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: add filter #470

wants to merge 2 commits into from

Conversation

sapphi-red
Copy link
Member

Description

Adds filter so that it makes these plugin performant when used in rolldown-vite.

@sapphi-red sapphi-red marked this pull request as draft April 28, 2025 08:22
@sapphi-red sapphi-red marked this pull request as ready for review April 28, 2025 09:01
: undefined,
resolveId: {
filter: { id: exactRegex(runtimePublicPath) },
handler: (id) => (id === runtimePublicPath ? id : undefined),
Copy link
Member Author

Choose a reason for hiding this comment

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

We still need to keep the if statements to keep the compat for Vite older than v6.3.

Comment on lines +200 to +205
id: {
include: ensureArray(include).map(matchWithQuery),
exclude: [
...(exclude ? ensureArray(exclude).map(matchWithQuery) : []),
/\/node_modules\//,
],
Copy link
Member

Choose a reason for hiding this comment

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

This filter conversion and the two utils feels a bit tricky IMO.
Could this be upstream into the Vite createFilter function so that it can be reused by other plugins?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we add a util function to Vite, we need to bump the required peer dep in this plugin (and the other plugins that wants to use that) which is a breaking change. I think if we do that we probably should add it to a separate package.

I'll consider if we can have @rolldown/pluginutils (since I sent a PR to @rollup/pluginutils that adds some utils functions and it's taking some time to be merged).

Copy link
Member

Choose a reason for hiding this comment

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

This could be added and then we could do import * as Vite from 'vite' and check for the export name existence so that people using the latest version have the speedup (which is expecting for people running rolldown vite)

Comment on lines +191 to +192
skipFastRefresh &&
isProduction
Copy link
Member

Choose a reason for hiding this comment

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

isProduction implies skipFastRefresh for now so we can skip the second check but it doesn't hurt so up to you

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

Successfully merging this pull request may close these issues.

2 participants