@vitejs/plugin-react 4.5.1 → 4.5.2
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 +4 -0
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +6 -1
- package/package.json +6 -6
package/README.md
CHANGED
@@ -129,6 +129,10 @@ Otherwise, you'll probably get this error:
|
|
129
129
|
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
|
130
130
|
```
|
131
131
|
|
132
|
+
### disableOxcRecommendation
|
133
|
+
|
134
|
+
If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured).
|
135
|
+
|
132
136
|
## Consistent components exports
|
133
137
|
|
134
138
|
For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
|
package/dist/index.cjs
CHANGED
@@ -177,7 +177,7 @@ function viteReact(opts = {}) {
|
|
177
177
|
jsx: "automatic",
|
178
178
|
jsxImportSource: opts.jsxImportSource
|
179
179
|
},
|
180
|
-
optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
|
180
|
+
optimizeDeps: "rolldownVersion" in vite__namespace ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
181
181
|
};
|
182
182
|
}
|
183
183
|
},
|
@@ -191,6 +191,11 @@ function viteReact(opts = {}) {
|
|
191
191
|
);
|
192
192
|
}
|
193
193
|
const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
|
194
|
+
if ("rolldownVersion" in vite__namespace && !opts.babel && !hooks.length && !opts.disableOxcRecommendation) {
|
195
|
+
config.logger.warn(
|
196
|
+
"[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown"
|
197
|
+
);
|
198
|
+
}
|
194
199
|
if (hooks.length > 0) {
|
195
200
|
runPluginOverrides = (babelOptions, context) => {
|
196
201
|
hooks.forEach((hook) => hook(babelOptions, context, config));
|
package/dist/index.d.cts
CHANGED
@@ -29,6 +29,10 @@ interface Options {
|
|
29
29
|
* reactRefreshHost: 'http://localhost:3000'
|
30
30
|
*/
|
31
31
|
reactRefreshHost?: string;
|
32
|
+
/**
|
33
|
+
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
34
|
+
*/
|
35
|
+
disableOxcRecommendation?: boolean;
|
32
36
|
}
|
33
37
|
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
34
38
|
/**
|
package/dist/index.d.mts
CHANGED
@@ -29,6 +29,10 @@ interface Options {
|
|
29
29
|
* reactRefreshHost: 'http://localhost:3000'
|
30
30
|
*/
|
31
31
|
reactRefreshHost?: string;
|
32
|
+
/**
|
33
|
+
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
34
|
+
*/
|
35
|
+
disableOxcRecommendation?: boolean;
|
32
36
|
}
|
33
37
|
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
34
38
|
/**
|
package/dist/index.d.ts
CHANGED
@@ -29,6 +29,10 @@ interface Options {
|
|
29
29
|
* reactRefreshHost: 'http://localhost:3000'
|
30
30
|
*/
|
31
31
|
reactRefreshHost?: string;
|
32
|
+
/**
|
33
|
+
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
34
|
+
*/
|
35
|
+
disableOxcRecommendation?: boolean;
|
32
36
|
}
|
33
37
|
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
34
38
|
/**
|
package/dist/index.mjs
CHANGED
@@ -161,7 +161,7 @@ function viteReact(opts = {}) {
|
|
161
161
|
jsx: "automatic",
|
162
162
|
jsxImportSource: opts.jsxImportSource
|
163
163
|
},
|
164
|
-
optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
|
164
|
+
optimizeDeps: "rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
165
165
|
};
|
166
166
|
}
|
167
167
|
},
|
@@ -175,6 +175,11 @@ function viteReact(opts = {}) {
|
|
175
175
|
);
|
176
176
|
}
|
177
177
|
const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
|
178
|
+
if ("rolldownVersion" in vite && !opts.babel && !hooks.length && !opts.disableOxcRecommendation) {
|
179
|
+
config.logger.warn(
|
180
|
+
"[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown"
|
181
|
+
);
|
182
|
+
}
|
178
183
|
if (hooks.length > 0) {
|
179
184
|
runPluginOverrides = (babelOptions, context) => {
|
180
185
|
hooks.forEach((hook) => hook(babelOptions, context, config));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitejs/plugin-react",
|
3
|
-
"version": "4.5.
|
3
|
+
"version": "4.5.2",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Evan You",
|
6
6
|
"description": "The default Vite plugin for React projects",
|
@@ -48,15 +48,15 @@
|
|
48
48
|
},
|
49
49
|
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
|
50
50
|
"dependencies": {
|
51
|
-
"@babel/core": "^7.
|
52
|
-
"@babel/plugin-transform-react-jsx-self": "^7.
|
53
|
-
"@babel/plugin-transform-react-jsx-source": "^7.
|
54
|
-
"@rolldown/pluginutils": "1.0.0-beta.
|
51
|
+
"@babel/core": "^7.27.4",
|
52
|
+
"@babel/plugin-transform-react-jsx-self": "^7.27.1",
|
53
|
+
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
|
54
|
+
"@rolldown/pluginutils": "1.0.0-beta.11",
|
55
55
|
"@types/babel__core": "^7.20.5",
|
56
56
|
"react-refresh": "^0.17.0"
|
57
57
|
},
|
58
58
|
"peerDependencies": {
|
59
|
-
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0"
|
59
|
+
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0-beta.0"
|
60
60
|
},
|
61
61
|
"devDependencies": {
|
62
62
|
"@vitejs/react-common": "workspace:*",
|