File tree Expand file tree Collapse file tree 7 files changed +23
-9
lines changed
plugin-rsc/examples/basic Expand file tree Collapse file tree 7 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Return ` Plugin[] ` instead of ` PluginOption[] `
6
+
5
7
## 0.2.3 (2025-06-16)
6
8
7
9
### Disable refresh transform when ` server.hmr: false ` is set [ #502 ] ( https://github.com/vitejs/vite-plugin-react/pull/502 )
Original file line number Diff line number Diff line change 1
1
import { dirname , join } from 'node:path'
2
2
import { fileURLToPath } from 'node:url'
3
3
import { readFileSync } from 'node:fs'
4
- import type { BuildOptions , Plugin , PluginOption } from 'vite'
4
+ import type { BuildOptions , Plugin } from 'vite'
5
5
import {
6
6
addRefreshWrapper ,
7
7
avoidSourceMapOption ,
@@ -30,7 +30,7 @@ export interface Options {
30
30
31
31
const defaultIncludeRE = / \. [ t j ] s x ? (?: $ | \? ) /
32
32
33
- export default function viteReact ( opts : Options = { } ) : PluginOption [ ] {
33
+ export default function viteReact ( opts : Options = { } ) : Plugin [ ] {
34
34
const include = opts . include ?? defaultIncludeRE
35
35
const exclude = [
36
36
...( Array . isArray ( opts . exclude )
Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Return ` Plugin[] ` instead of ` PluginOption[] `
6
+
5
7
## 3.10.2 (2025-06-10)
6
8
7
9
### Suggest ` @vitejs/plugin-react-oxc ` if rolldown-vite is detected [ #491 ] ( https://github.com/vitejs/vite-plugin-react/pull/491 )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
11
11
type Options as SWCOptions ,
12
12
transform ,
13
13
} from '@swc/core'
14
- import type { PluginOption } from 'vite'
14
+ import type { Plugin } from 'vite'
15
15
import {
16
16
addRefreshWrapper ,
17
17
getPreambleCode ,
@@ -83,7 +83,7 @@ type Options = {
83
83
disableOxcRecommendation ?: boolean
84
84
}
85
85
86
- const react = ( _options ?: Options ) : PluginOption [ ] => {
86
+ const react = ( _options ?: Options ) : Plugin [ ] => {
87
87
let hmrDisabled = false
88
88
const options = {
89
89
jsxImportSource : _options ?. jsxImportSource ?? 'react' ,
Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Return ` Plugin[] ` instead of ` PluginOption[] `
6
+
7
+ The return type has changed from ` react(): PluginOption[] ` to more specialized type ` react(): Plugin[] ` . This allows for type-safe manipulation of plugins, for example:
8
+
9
+ ``` tsx
10
+ // previously this causes type errors
11
+ react ({ babel: { plugins: [' babel-plugin-react-compiler' ] } })
12
+ .map (p => ({ ... p , applyToEnvironment : e => e .name === ' client' }))
13
+ ```
14
+
5
15
## 4.6.0 (2025-06-23)
6
16
7
17
### Add raw Rolldown support
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type * as babelCore from '@babel/core'
5
5
import type { ParserOptions , TransformOptions } from '@babel/core'
6
6
import { createFilter } from 'vite'
7
7
import * as vite from 'vite'
8
- import type { Plugin , PluginOption , ResolvedConfig } from 'vite'
8
+ import type { Plugin , ResolvedConfig } from 'vite'
9
9
import {
10
10
addRefreshWrapper ,
11
11
getPreambleCode ,
@@ -109,7 +109,7 @@ export type ViteReactPluginApi = {
109
109
const defaultIncludeRE = / \. [ t j ] s x ? $ /
110
110
const tsRE = / \. t s x ? $ /
111
111
112
- export default function viteReact ( opts : Options = { } ) : PluginOption [ ] {
112
+ export default function viteReact ( opts : Options = { } ) : Plugin [ ] {
113
113
const include = opts . include ?? defaultIncludeRE
114
114
const exclude = opts . exclude
115
115
const filter = createFilter ( include , exclude )
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ export default defineConfig({
23
23
plugins : [
24
24
tailwindcss ( ) ,
25
25
process . env . TEST_REACT_COMPILER
26
- ? ( react ( {
26
+ ? react ( {
27
27
babel : { plugins : [ 'babel-plugin-react-compiler' ] } ,
28
28
} ) . map ( ( p ) => ( {
29
29
...p ,
30
- applyToEnvironment : ( e : any ) => e . name === 'client' ,
31
- } ) ) as any )
30
+ applyToEnvironment : ( e ) => e . name === 'client' ,
31
+ } ) )
32
32
: react ( ) ,
33
33
vitePluginUseCache ( ) ,
34
34
rsc ( {
You can’t perform that action at this time.
0 commit comments