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 2
2
3
3
## Unreleased
4
4
5
+ ### Perf: use native refresh wrapper plugin in rolldown-vite ([ #881 ] ( https://github.com/vitejs/vite-plugin-react/pull/881 ) )
6
+
5
7
## 5.0.3 (2025-09-17)
6
8
7
9
### 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 @@ -362,6 +362,36 @@ export default function viteReact(opts: Options = {}): Plugin[] {
362
362
const viteRefreshWrapper : Plugin = {
363
363
name : 'vite:react:refresh-wrapper' ,
364
364
apply : 'serve' ,
365
+ async applyToEnvironment ( env ) {
366
+ if ( env . config . consumer !== 'client' || skipFastRefresh ) {
367
+ return false
368
+ }
369
+
370
+ let nativePlugin : ( ( options : any ) => Plugin ) | undefined
371
+ try {
372
+ // NOTE: `+` is to bypass lint & typecheck. vite/internal exists for newer rolldown-vite
373
+ nativePlugin = ( await import ( 'vite' + '/internal' ) )
374
+ . reactRefreshWrapperPlugin
375
+ } catch { }
376
+ if (
377
+ ! nativePlugin ||
378
+ [ '7.1.10' , '7.1.11' , '7.1.12' ] . includes ( vite . version )
379
+ ) {
380
+ // the native plugin in 7.1.10 and 7.1.11 and 7.1.12 does not support dev properly
381
+ return true
382
+ }
383
+
384
+ delete viteRefreshWrapper . transform
385
+
386
+ return nativePlugin ( {
387
+ cwd : process . cwd ( ) ,
388
+ include : makeIdFiltersToMatchWithQuery ( include ) ,
389
+ exclude : makeIdFiltersToMatchWithQuery ( exclude ) ,
390
+ jsxImportSource,
391
+ reactRefreshHost : opts . reactRefreshHost ?? '' ,
392
+ } ) as unknown as boolean
393
+ } ,
394
+ // we can remove this transform hook when we drop support for rolldown-vite 7.1.12 and below
365
395
transform : {
366
396
filter : {
367
397
id : {
You can’t perform that action at this time.
0 commit comments