File tree Expand file tree Collapse file tree 10 files changed +206
-126
lines changed Expand file tree Collapse file tree 10 files changed +206
-126
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### Add ` filter ` for rolldown-vite
6+
7+ Added ` filter ` so that it is more performant when running this plugin with rolldown-powered version of Vite.
8+
59## 0.1.1 (2025-04-10)
610
711## 0.1.0 (2025-04-09)
Original file line number Diff line number Diff line change 4646 "@vitejs/react-common" : " workspace:*" ,
4747 "unbuild" : " ^3.5.0" ,
4848 "vite" : " catalog:rolldown-vite"
49+ },
50+ "dependencies" : {
51+ "@rolldown/pluginutils" : " 1.0.0-beta.9"
4952 }
5053}
Original file line number Diff line number Diff line change 99 runtimePublicPath ,
1010 silenceUseClientWarning ,
1111} from '@vitejs/react-common'
12+ import { exactRegex } from '@rolldown/pluginutils'
1213
1314const _dirname = dirname ( fileURLToPath ( import . meta. url ) )
1415
@@ -149,12 +150,3 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
149150
150151 return [ viteConfig , viteRefreshRuntime , viteRefreshWrapper ]
151152}
152-
153- function exactRegex ( input : string ) : RegExp {
154- return new RegExp ( `^${ escapeRegex ( input ) } $` )
155- }
156-
157- const escapeRegexRE = / [ - / \\ ^ $ * + ? . ( ) | [ \] { } ] / g
158- function escapeRegex ( str : string ) : string {
159- return str . replace ( escapeRegexRE , '\\$&' )
160- }
Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### Add ` filter ` for rolldown-vite
6+
7+ Added ` filter ` so that it is more performant when running this plugin with rolldown-powered version of Vite.
8+
59### Skip HMR preamble in Vitest browser mode
610
711This was causing annoying ` Sourcemap for "/@react-refresh" points to missing source files ` and is unnecessary in test mode.
Original file line number Diff line number Diff line change 2929 },
3030 "homepage" : " https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme" ,
3131 "dependencies" : {
32+ "@rolldown/pluginutils" : " 1.0.0-beta.9" ,
3233 "@swc/core" : " ^1.11.22"
3334 },
3435 "peerDependencies" : {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 runtimePublicPath ,
1919 silenceUseClientWarning ,
2020} from '@vitejs/react-common'
21+ import { exactRegex } from '@rolldown/pluginutils'
2122
2223/* eslint-disable no-restricted-globals */
2324const _dirname =
@@ -96,14 +97,23 @@ const react = (_options?: Options): PluginOption[] => {
9697 name : 'vite:react-swc:resolve-runtime' ,
9798 apply : 'serve' ,
9899 enforce : 'pre' , // Run before Vite default resolve to avoid syscalls
99- resolveId : ( id ) => ( id === runtimePublicPath ? id : undefined ) ,
100- load : ( id ) =>
101- id === runtimePublicPath
102- ? readFileSync ( join ( _dirname , 'refresh-runtime.js' ) , 'utf-8' ) . replace (
103- / _ _ R E A D M E _ U R L _ _ / g,
104- 'https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc' ,
105- )
106- : undefined ,
100+ resolveId : {
101+ filter : { id : exactRegex ( runtimePublicPath ) } ,
102+ handler : ( id ) => ( id === runtimePublicPath ? id : undefined ) ,
103+ } ,
104+ load : {
105+ filter : { id : exactRegex ( runtimePublicPath ) } ,
106+ handler : ( id ) =>
107+ id === runtimePublicPath
108+ ? readFileSync (
109+ join ( _dirname , 'refresh-runtime.js' ) ,
110+ 'utf-8' ,
111+ ) . replace (
112+ / _ _ R E A D M E _ U R L _ _ / g,
113+ 'https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc' ,
114+ )
115+ : undefined ,
116+ } ,
107117 } ,
108118 {
109119 name : 'vite:react-swc' ,
Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### Add ` filter ` for rolldown-vite
6+
7+ Added ` filter ` so that it is more performant when running this plugin with rolldown-powered version of Vite.
8+
59## 4.4.1 (2025-04-19)
610
711Fix type issue when using ` moduleResolution: "node" ` in tsconfig [ #462 ] ( https://github.com/vitejs/vite-plugin-react/pull/462 )
Original file line number Diff line number Diff line change 5151 "@babel/core" : " ^7.26.10" ,
5252 "@babel/plugin-transform-react-jsx-self" : " ^7.25.9" ,
5353 "@babel/plugin-transform-react-jsx-source" : " ^7.25.9" ,
54+ "@rolldown/pluginutils" : " 1.0.0-beta.9" ,
5455 "@types/babel__core" : " ^7.20.5" ,
5556 "react-refresh" : " ^0.17.0"
5657 },
You can’t perform that action at this time.
0 commit comments