File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
packages/plugin-react/src Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -355,6 +355,34 @@ export default function viteReact(opts: Options = {}): Plugin[] {
355
355
const viteRefreshWrapper : Plugin = {
356
356
name : 'vite:react:refresh-wrapper' ,
357
357
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
+ nativePlugin = ( await import ( 'vite/internal' ) ) . reactRefreshWrapperPlugin
366
+ } catch { }
367
+ if (
368
+ ! nativePlugin ||
369
+ [ '7.1.10' , '7.1.11' , '7.1.12' ] . includes ( vite . version )
370
+ ) {
371
+ // the native plugin in 7.1.10 and 7.1.11 and 7.1.12 does not support dev properly
372
+ return true
373
+ }
374
+
375
+ delete viteRefreshWrapper . transform
376
+
377
+ return nativePlugin ( {
378
+ cwd : process . cwd ( ) ,
379
+ include : makeIdFiltersToMatchWithQuery ( include ) ,
380
+ exclude : makeIdFiltersToMatchWithQuery ( exclude ) ,
381
+ jsxImportSource,
382
+ reactRefreshHost : opts . reactRefreshHost ?? '' ,
383
+ } ) as unknown as boolean
384
+ } ,
385
+ // we can remove this transform hook when we drop support for rolldown-vite 7.1.12 and below
358
386
transform : {
359
387
filter : {
360
388
id : {
You can’t perform that action at this time.
0 commit comments