File tree Expand file tree Collapse file tree 4 files changed +362
-481
lines changed Expand file tree Collapse file tree 4 files changed +362
-481
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### Perf: use native refresh wrapper plugin in rolldown-vite ([ #881 ] ( https://github.com/vitejs/vite-plugin-react/pull/881 ) )
6+
57## 5.0.3 (2025-09-17)
68
79### HMR did not work for components imported with queries with rolldown-vite ([ #872 ] ( https://github.com/vitejs/vite-plugin-react/pull/872 ) )
Original file line number Diff line number Diff line change @@ -355,6 +355,36 @@ export default function viteReact(opts: Options = {}): Plugin[] {
355355 const viteRefreshWrapper : Plugin = {
356356 name : 'vite:react:refresh-wrapper' ,
357357 apply : 'serve' ,
358+ async applyToEnvironment ( env ) {
359+ if ( env . config . consumer !== 'client' || skipFastRefresh ) {
360+ return false
361+ }
362+
363+ let nativePlugin : ( ( options : any ) => Plugin ) | undefined
364+ try {
365+ // NOTE: `+` is to bypass lint & typecheck. vite/internal exists for newer rolldown-vite
366+ nativePlugin = ( await import ( 'vite' + '/internal' ) )
367+ . reactRefreshWrapperPlugin
368+ } catch { }
369+ if (
370+ ! nativePlugin ||
371+ [ '7.1.10' , '7.1.11' , '7.1.12' ] . includes ( vite . version )
372+ ) {
373+ // the native plugin in 7.1.10 and 7.1.11 and 7.1.12 does not support dev properly
374+ return true
375+ }
376+
377+ delete viteRefreshWrapper . transform
378+
379+ return nativePlugin ( {
380+ cwd : process . cwd ( ) ,
381+ include : makeIdFiltersToMatchWithQuery ( include ) ,
382+ exclude : makeIdFiltersToMatchWithQuery ( exclude ) ,
383+ jsxImportSource,
384+ reactRefreshHost : opts . reactRefreshHost ?? '' ,
385+ } ) as unknown as boolean
386+ } ,
387+ // we can remove this transform hook when we drop support for rolldown-vite 7.1.12 and below
358388 transform : {
359389 filter : {
360390 id : {
You can’t perform that action at this time.
0 commit comments