@vitejs/plugin-react 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,10 +79,16 @@ Under the hood, this simply updates the React Fash Refresh runtime URL from `/@r
79
79
 
80
80
  ## React Compiler
81
81
 
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:
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) and [`@babel/core`](https://npmx.dev/package/@babel/core) as peer dependencies:
83
83
 
84
84
  ```sh
85
- npm install -D @rolldown/plugin-babel babel-plugin-react-compiler
85
+ npm install -D @rolldown/plugin-babel @babel/core babel-plugin-react-compiler
86
+ ```
87
+
88
+ If you are using TypeScript, you will also need to install [`@types/babel__core`](https://npmx.dev/package/@types/babel__core):
89
+
90
+ ```sh
91
+ npm install -D @types/babel__core
86
92
  ```
87
93
 
88
94
  ```js
@@ -101,6 +107,8 @@ The `reactCompilerPreset` accepts an optional options object with the following
101
107
  - `compilationMode` — Set to `'annotation'` to only compile components annotated with `"use memo"`.
102
108
  - `target` — Set to `'17'` or `'18'` to target older React versions (uses `react-compiler-runtime` instead of `react/compiler-runtime`).
103
109
 
110
+ Additional options can be found in the [documentation](https://react.dev/reference/react-compiler/configuration).
111
+
104
112
  ```js
105
113
  babel({
106
114
  presets: [reactCompilerPreset({ compilationMode: 'annotation' })],
@@ -158,4 +166,4 @@ For React refresh to work correctly, your file should only export React componen
158
166
 
159
167
  If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.
160
168
 
161
- You can catch mistakes and get more detailed warnings with this [ESLint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh), or the equivalent [Oxlint rule](https://oxc.rs/docs/guide/usage/linter/rules/react/only-export-components.html).
169
+ You can catch mistakes and get more detailed warnings with this [ESLint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh), this [Oxlint rule](https://oxc.rs/docs/guide/usage/linter/rules/react/only-export-components.html), or this [Biome rule](https://biomejs.dev/linter/rules/use-component-export-only-modules).
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Plugin } from "vite";
2
2
  import { ReactCompilerBabelPluginOptions, RolldownBabelPreset } from "#optionalTypes";
3
3
 
4
4
  //#region src/reactCompilerPreset.d.ts
5
- declare const reactCompilerPreset: (options?: Pick<ReactCompilerBabelPluginOptions, "compilationMode" | "target">) => RolldownBabelPreset;
5
+ declare const reactCompilerPreset: (options?: ReactCompilerBabelPluginOptions) => RolldownBabelPreset;
6
6
  //#endregion
7
7
  //#region src/index.d.ts
8
8
  interface Options {
package/dist/index.js CHANGED
@@ -41,10 +41,11 @@ const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warni
41
41
  } } });
42
42
  //#endregion
43
43
  //#region src/reactCompilerPreset.ts
44
+ const defaultCodeFilter = /forwardRef|memo|(?:const|let|var|function)\s+(?:[A-Z]|use[A-Z0-9])|(?:[A-Z]|use[A-Z0-9])[^\s:=(){}[\],;]*\s*(?:\(|[:=]\s*(?:function|\())/;
44
45
  const reactCompilerPreset = (options = {}) => ({
45
46
  preset: () => ({ plugins: [["babel-plugin-react-compiler", options]] }),
46
47
  rolldown: {
47
- filter: { code: options.compilationMode === "annotation" ? /['"]use memo['"]/ : /\b[A-Z]|\buse/ },
48
+ filter: { code: options.compilationMode === "annotation" ? /['"]use memo['"]/ : defaultCodeFilter },
48
49
  applyToEnvironmentHook: (env) => env.config.consumer === "client",
49
50
  optimizeDeps: { include: options.target === "17" || options.target === "18" ? ["react-compiler-runtime"] : ["react/compiler-runtime"] }
50
51
  }
@@ -137,7 +138,7 @@ function viteReact(opts = {}) {
137
138
  if (!skipFastRefresh && isBundledDev) return [{
138
139
  tag: "script",
139
140
  attrs: { type: "module" },
140
- children: getPreambleCode(base)
141
+ children: getPreambleCode("/")
141
142
  }];
142
143
  },
143
144
  order: "pre"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "The default Vite plugin for React projects",
5
5
  "keywords": [
6
6
  "fast refresh",
@@ -43,18 +43,18 @@
43
43
  "test-unit": "vitest run"
44
44
  },
45
45
  "dependencies": {
46
- "@rolldown/pluginutils": "1.0.0-rc.7"
46
+ "@rolldown/pluginutils": "^1.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/core": "8.0.0-rc.2",
50
- "@rolldown/plugin-babel": "^0.2.0",
49
+ "@babel/core": "8.0.0-rc.6",
50
+ "@rolldown/plugin-babel": "^0.2.3",
51
51
  "@vitejs/react-common": "workspace:*",
52
52
  "babel-plugin-react-compiler": "^1.0.0",
53
- "react": "^19.2.4",
54
- "react-dom": "^19.2.4",
55
- "rolldown": "1.0.0-rc.7",
56
- "tsdown": "^0.21.0",
57
- "vite": "^8.0.0-beta.16"
53
+ "react": "^19.2.7",
54
+ "react-dom": "^19.2.7",
55
+ "rolldown": "^1.1.1",
56
+ "tsdown": "^0.22.2",
57
+ "vite": "^8.0.16"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0",
@@ -76,7 +76,7 @@
76
76
  "schemaVersion": 1,
77
77
  "rolldown": {
78
78
  "type": "compatible",
79
- "versions": "^1.0.0-beta.44",
79
+ "versions": "^1.0.0",
80
80
  "note": "You can use Rolldown's built-in feature directly."
81
81
  },
82
82
  "rollup": {