Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/plugin-react-oxc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Add `filter` for rolldown-vite

Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite.

## 0.1.1 (2025-04-10)

## 0.1.0 (2025-04-09)
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-react-oxc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@
"@vitejs/react-common": "workspace:*",
"unbuild": "^3.5.0",
"vite": "catalog:rolldown-vite"
},
"dependencies": {
"@rolldown/pluginutils": "1.0.0-beta.9"
}
}
10 changes: 1 addition & 9 deletions packages/plugin-react-oxc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
runtimePublicPath,
silenceUseClientWarning,
} from '@vitejs/react-common'
import { exactRegex } from '@rolldown/pluginutils'

const _dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -149,12 +150,3 @@ export default function viteReact(opts: Options = {}): PluginOption[] {

return [viteConfig, viteRefreshRuntime, viteRefreshWrapper]
}

function exactRegex(input: string): RegExp {
return new RegExp(`^${escapeRegex(input)}$`)
}

const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g
function escapeRegex(str: string): string {
return str.replace(escapeRegexRE, '\\$&')
}
4 changes: 4 additions & 0 deletions packages/plugin-react-swc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Add `filter` for rolldown-vite

Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite.

### Skip HMR preamble in Vitest browser mode

This was causing annoying `Sourcemap for "/@react-refresh" points to missing source files` and is unnecessary in test mode.
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-react-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme",
"dependencies": {
"@rolldown/pluginutils": "1.0.0-beta.9",
"@swc/core": "^1.11.22"
},
"peerDependencies": {
Expand Down
26 changes: 18 additions & 8 deletions packages/plugin-react-swc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
runtimePublicPath,
silenceUseClientWarning,
} from '@vitejs/react-common'
import { exactRegex } from '@rolldown/pluginutils'

/* eslint-disable no-restricted-globals */
const _dirname =
Expand Down Expand Up @@ -96,14 +97,23 @@ const react = (_options?: Options): PluginOption[] => {
name: 'vite:react-swc:resolve-runtime',
apply: 'serve',
enforce: 'pre', // Run before Vite default resolve to avoid syscalls
resolveId: (id) => (id === runtimePublicPath ? id : undefined),
load: (id) =>
id === runtimePublicPath
? readFileSync(join(_dirname, 'refresh-runtime.js'), 'utf-8').replace(
/__README_URL__/g,
'https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc',
)
: undefined,
resolveId: {
filter: { id: exactRegex(runtimePublicPath) },
handler: (id) => (id === runtimePublicPath ? id : undefined),
Copy link
Member Author

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.

},
load: {
filter: { id: exactRegex(runtimePublicPath) },
handler: (id) =>
id === runtimePublicPath
? readFileSync(
join(_dirname, 'refresh-runtime.js'),
'utf-8',
).replace(
/__README_URL__/g,
'https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc',
)
: undefined,
},
},
{
name: 'vite:react-swc',
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Add `filter` for rolldown-vite

Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite.

## 4.4.1 (2025-04-19)

Fix type issue when using `moduleResolution: "node"` in tsconfig [#462](https://github.com/vitejs/vite-plugin-react/pull/462)
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@babel/core": "^7.26.10",
"@babel/plugin-transform-react-jsx-self": "^7.25.9",
"@babel/plugin-transform-react-jsx-source": "^7.25.9",
"@rolldown/pluginutils": "1.0.0-beta.9",
"@types/babel__core": "^7.20.5",
"react-refresh": "^0.17.0"
},
Expand Down
Loading
Loading