-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
feat: add filter #470
Conversation
: undefined, | ||
resolveId: { | ||
filter: { id: exactRegex(runtimePublicPath) }, | ||
handler: (id) => (id === runtimePublicPath ? id : undefined), |
There was a problem hiding this comment.
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.
packages/plugin-react/src/index.ts
Outdated
id: { | ||
include: ensureArray(include).map(matchWithQuery), | ||
exclude: [ | ||
...(exclude ? ensureArray(exclude).map(matchWithQuery) : []), | ||
/\/node_modules\//, | ||
], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to use @rolldown/pluginutils
. ensureArray
is still there because we need to combine with /\/node_modules\//
, but I think it is now simple enough.
packages/plugin-react/src/index.ts
Outdated
skipFastRefresh && | ||
isProduction |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this is needed. For example, when config.command === 'build' && !isProduction
is true (NODE_ENV=development vite build
), this if block should not be executed. Otherwise @babel/plugin-transform-react-jsx-self
/ @babel/plugin-transform-react-jsx-source
won't run.
Just noticed that I forgot to add the changelog. Added 👍 |
| datasource | package | from | to | | ---------- | -------------------- | ----- | ----- | | npm | @vitejs/plugin-react | 4.4.1 | 4.5.0 | ## [v4.5.0](https://github.com/vitejs/vite-plugin-react/blob/HEAD/packages/plugin-react/CHANGELOG.md#450-2025-05-23) ##### Add `filter` for rolldown-vite [#470](vitejs/vite-plugin-react#470) Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite. ##### Skip HMR for JSX files with hooks [#480](vitejs/vite-plugin-react#480) This removes the HMR warning for hooks with JSX.
| datasource | package | from | to | | ---------- | -------------------- | ----- | ----- | | npm | @vitejs/plugin-react | 4.4.1 | 4.5.0 | ## [v4.5.0](https://github.com/vitejs/vite-plugin-react/blob/HEAD/packages/plugin-react/CHANGELOG.md#450-2025-05-23) ##### Add `filter` for rolldown-vite [#470](vitejs/vite-plugin-react#470) Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite. ##### Skip HMR for JSX files with hooks [#480](vitejs/vite-plugin-react#480) This removes the HMR warning for hooks with JSX.
| datasource | package | from | to | | ---------- | -------------------- | ----- | ----- | | npm | @vitejs/plugin-react | 4.4.1 | 4.5.0 | ## [v4.5.0](https://github.com/vitejs/vite-plugin-react/blob/HEAD/packages/plugin-react/CHANGELOG.md#450-2025-05-23) ##### Add `filter` for rolldown-vite [#470](vitejs/vite-plugin-react#470) Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite. ##### Skip HMR for JSX files with hooks [#480](vitejs/vite-plugin-react#480) This removes the HMR warning for hooks with JSX.
Description
Adds
filter
so that it makes these plugin performant when used in rolldown-vite.