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 22
33## Unreleased
44
5+ ### Return ` Plugin[] ` instead of ` PluginOption[] `
6+
57## 0.2.3 (2025-06-16)
68
79### 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 11import { dirname , join } from 'node:path'
22import { fileURLToPath } from 'node:url'
33import { readFileSync } from 'node:fs'
4- import type { BuildOptions , Plugin , PluginOption } from 'vite'
4+ import type { BuildOptions , Plugin } from 'vite'
55import {
66 addRefreshWrapper ,
77 avoidSourceMapOption ,
@@ -30,7 +30,7 @@ export interface Options {
3030
3131const defaultIncludeRE = / \. [ t j ] s x ? (?: $ | \? ) /
3232
33- export default function viteReact ( opts : Options = { } ) : PluginOption [ ] {
33+ export default function viteReact ( opts : Options = { } ) : Plugin [ ] {
3434 const include = opts . include ?? defaultIncludeRE
3535 const exclude = [
3636 ...( Array . isArray ( opts . exclude )
Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### Return ` Plugin[] ` instead of ` PluginOption[] `
6+
57## 3.10.2 (2025-06-10)
68
79### 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 {
1111 type Options as SWCOptions ,
1212 transform ,
1313} from '@swc/core'
14- import type { PluginOption } from 'vite'
14+ import type { Plugin } from 'vite'
1515import {
1616 addRefreshWrapper ,
1717 getPreambleCode ,
@@ -83,7 +83,7 @@ type Options = {
8383 disableOxcRecommendation ?: boolean
8484}
8585
86- const react = ( _options ?: Options ) : PluginOption [ ] => {
86+ const react = ( _options ?: Options ) : Plugin [ ] => {
8787 let hmrDisabled = false
8888 const options = {
8989 jsxImportSource : _options ?. jsxImportSource ?? 'react' ,
Original file line number Diff line number Diff line change 22
33## Unreleased
44
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+
515## 4.6.0 (2025-06-23)
616
717### 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'
55import type { ParserOptions , TransformOptions } from '@babel/core'
66import { createFilter } from 'vite'
77import * as vite from 'vite'
8- import type { Plugin , PluginOption , ResolvedConfig } from 'vite'
8+ import type { Plugin , ResolvedConfig } from 'vite'
99import {
1010 addRefreshWrapper ,
1111 getPreambleCode ,
@@ -109,7 +109,7 @@ export type ViteReactPluginApi = {
109109const defaultIncludeRE = / \. [ t j ] s x ? $ /
110110const tsRE = / \. t s x ? $ /
111111
112- export default function viteReact ( opts : Options = { } ) : PluginOption [ ] {
112+ export default function viteReact ( opts : Options = { } ) : Plugin [ ] {
113113 const include = opts . include ?? defaultIncludeRE
114114 const exclude = opts . exclude
115115 const filter = createFilter ( include , exclude )
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ export default defineConfig({
2323 plugins : [
2424 tailwindcss ( ) ,
2525 process . env . TEST_REACT_COMPILER
26- ? ( react ( {
26+ ? react ( {
2727 babel : { plugins : [ 'babel-plugin-react-compiler' ] } ,
2828 } ) . map ( ( p ) => ( {
2929 ...p ,
30- applyToEnvironment : ( e : any ) => e . name === 'client' ,
31- } ) ) as any )
30+ applyToEnvironment : ( e ) => e . name === 'client' ,
31+ } ) )
3232 : react ( ) ,
3333 vitePluginUseCache ( ) ,
3434 rsc ( {
You can’t perform that action at this time.
0 commit comments