You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/plugin-react/CHANGELOG.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,55 @@
2
2
3
3
## Unreleased
4
4
5
+
### Remove Babel Related Features ([#1123](https://github.com/vitejs/vite-plugin-react/pull/1123))
6
+
7
+
Vite 8+ can handle React Refresh Transform by Oxc and doesn't need Babel for it. With that, there are no transform applied that requires Babel. To reduce the installation size of this plugin, babel is no longer a dependency of this plugin and the related features are removed.
8
+
9
+
If you are using Babel, you can use `@rolldown/plugin-babel` together with this plugin:
Copy file name to clipboardExpand all lines: packages/plugin-react/README.md
+23-34Lines changed: 23 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,6 @@ The default Vite plugin for React projects.
4
4
5
5
- enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development (requires react >= 16.9)
6
6
- use the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
7
-
- use custom Babel plugins/presets
8
7
- small installation size
9
8
10
9
```js
@@ -68,56 +67,46 @@ By default, the plugin uses the [automatic JSX runtime](https://legacy.reactjs.o
68
67
react({ jsxRuntime:'classic' })
69
68
```
70
69
71
-
### babel
70
+
### reactRefreshHost
72
71
73
-
The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each included file.
72
+
The `reactRefreshHost` option is only necessary in a module federation context. It enables HMR to work between a remote & host application. In your remote Vite config, you would add your host origin:
74
73
75
74
```js
76
-
react({
77
-
babel: {
78
-
presets: [...],
79
-
// Your plugins run before any built-in transform (eg: Fast Refresh)
Note: When not using plugins, only esbuild is used for production builds, resulting in faster builds.
78
+
Under the hood, this simply updates the React Fash Refresh runtime URL from `/@react-refresh` to `http://localhost:3000/@react-refresh` to ensure there is only one Refresh runtime across the whole application. Note that if you define `base` option in the host application, you need to include it in the option, like: `http://localhost:3000/{base}`.
90
79
91
-
#### Proposed syntax
80
+
##React Compiler
92
81
93
-
If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them with the `babel.parserOpts.plugins` option:
82
+
[React Compiler](https://react.dev/learn/react-compiler) support is available via the exported `reactCompilerPreset` helper, which requires [`@rolldown/plugin-babel`](https://npmx.dev/package/@rolldown/plugin-babel) and [`babel-plugin-react-compiler`](https://npmx.dev/package/babel-plugin-react-compiler) as peer dependencies:
The `reactCompilerPreset` accepts an optional options object with the following properties:
112
100
113
-
The `reactRefreshHost` option is only necessary in a module federation context. It enables HMR to work between a remote & host application. In your remote Vite config, you would add your host origin:
101
+
-`compilationMode` — Set to `'annotation'` to only compile components annotated with `"use memo"`.
102
+
-`target` — Set to `'17'` or `'18'` to target older React versions (uses `react-compiler-runtime` instead of `react/compiler-runtime`).
Under the hood, this simply updates the React Fash Refresh runtime URL from `/@react-refresh` to `http://localhost:3000/@react-refresh` to ensure there is only one Refresh runtime across the whole application. Note that if you define `base` option in the host application, you need to include it in the option, like: `http://localhost:3000/{base}`.
120
-
121
110
## `@vitejs/plugin-react/preamble`
122
111
123
112
The package provides `@vitejs/plugin-react/preamble` to initialize HMR runtime from client entrypoint for SSR applications which don't use [`transformIndexHtml` API](https://vite.dev/guide/api-javascript.html#vitedevserver). For example:
0 commit comments