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
2 changes: 2 additions & 0 deletions packages/plugin-react-oxc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

### Return `Plugin[]` instead of `PluginOption[]`

## 0.2.3 (2025-06-16)

### Disable refresh transform when `server.hmr: false` is set [#502](https://github.com/vitejs/vite-plugin-react/pull/502)
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-oxc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { readFileSync } from 'node:fs'
import type { BuildOptions, Plugin, PluginOption } from 'vite'
import type { BuildOptions, Plugin } from 'vite'
import {
addRefreshWrapper,
avoidSourceMapOption,
Expand Down Expand Up @@ -30,7 +30,7 @@ export interface Options {

const defaultIncludeRE = /\.[tj]sx?(?:$|\?)/

export default function viteReact(opts: Options = {}): PluginOption[] {
export default function viteReact(opts: Options = {}): Plugin[] {
const include = opts.include ?? defaultIncludeRE
const exclude = [
...(Array.isArray(opts.exclude)
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-react-swc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

### Return `Plugin[]` instead of `PluginOption[]`

## 3.10.2 (2025-06-10)

### Suggest `@vitejs/plugin-react-oxc` if rolldown-vite is detected [#491](https://github.com/vitejs/vite-plugin-react/pull/491)
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-swc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type Options as SWCOptions,
transform,
} from '@swc/core'
import type { PluginOption } from 'vite'
import type { Plugin } from 'vite'
import {
addRefreshWrapper,
getPreambleCode,
Expand Down Expand Up @@ -83,7 +83,7 @@ type Options = {
disableOxcRecommendation?: boolean
}

const react = (_options?: Options): PluginOption[] => {
const react = (_options?: Options): Plugin[] => {
let hmrDisabled = false
const options = {
jsxImportSource: _options?.jsxImportSource ?? 'react',
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

### Return `Plugin[]` instead of `PluginOption[]`

The return type has changed from `react(): PluginOption[]` to more specialized type `react(): Plugin[]`. This allows for type-safe manipulation of plugins, for example:

```tsx
// previously this causes type errors
react({ babel: { plugins: ['babel-plugin-react-compiler'] } })
.map(p => ({ ...p, applyToEnvironment: e => e.name === 'client' }))
```

## 4.6.0 (2025-06-23)

### Add raw Rolldown support
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type * as babelCore from '@babel/core'
import type { ParserOptions, TransformOptions } from '@babel/core'
import { createFilter } from 'vite'
import * as vite from 'vite'
import type { Plugin, PluginOption, ResolvedConfig } from 'vite'
import type { Plugin, ResolvedConfig } from 'vite'
import {
addRefreshWrapper,
getPreambleCode,
Expand Down Expand Up @@ -109,7 +109,7 @@ export type ViteReactPluginApi = {
const defaultIncludeRE = /\.[tj]sx?$/
const tsRE = /\.tsx?$/

export default function viteReact(opts: Options = {}): PluginOption[] {
export default function viteReact(opts: Options = {}): Plugin[] {
const include = opts.include ?? defaultIncludeRE
const exclude = opts.exclude
const filter = createFilter(include, exclude)
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-rsc/examples/basic/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export default defineConfig({
plugins: [
tailwindcss(),
process.env.TEST_REACT_COMPILER
? (react({
? react({
babel: { plugins: ['babel-plugin-react-compiler'] },
}).map((p) => ({
...p,
applyToEnvironment: (e: any) => e.name === 'client',
})) as any)
applyToEnvironment: (e) => e.name === 'client',
}))
: react(),
vitePluginUseCache(),
rsc({
Expand Down
Loading