@vitejs/plugin-react 6.0.2 → 6.0.4
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 +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +11 -8
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -166,4 +166,4 @@ For React refresh to work correctly, your file should only export React componen
|
|
|
166
166
|
|
|
167
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.
|
|
168
168
|
|
|
169
|
-
You can catch mistakes and get more detailed warnings with this [ESLint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh),
|
|
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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
import { ReactCompilerBabelPluginOptions, RolldownBabelPreset } from "#optionalTypes";
|
|
3
|
-
|
|
4
3
|
//#region src/reactCompilerPreset.d.ts
|
|
5
4
|
declare const reactCompilerPreset: (options?: ReactCompilerBabelPluginOptions) => RolldownBabelPreset;
|
|
6
5
|
//#endregion
|
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
|
-
preset: () => ({ plugins: [["babel-plugin-react-compiler", options]] }),
|
|
46
|
+
preset: () => ({ plugins: [[fileURLToPath(import.meta.resolve("babel-plugin-react-compiler")), options]] }),
|
|
46
47
|
rolldown: {
|
|
47
|
-
filter: { code: options.compilationMode === "annotation" ? /['"]use memo['"]/ :
|
|
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
|
}
|
|
@@ -61,10 +62,12 @@ function viteReact(opts = {}) {
|
|
|
61
62
|
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
|
62
63
|
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
|
63
64
|
let runningInVite = false;
|
|
64
|
-
let isProduction = true;
|
|
65
65
|
let skipFastRefresh = true;
|
|
66
66
|
let base;
|
|
67
67
|
let isBundledDev = false;
|
|
68
|
+
function calculateSkipFastRefresh(isProduction, command, hmr) {
|
|
69
|
+
return isProduction || command === "build" || hmr === false;
|
|
70
|
+
}
|
|
68
71
|
const viteBabel = {
|
|
69
72
|
name: "vite:react-babel",
|
|
70
73
|
enforce: "pre",
|
|
@@ -94,8 +97,7 @@ function viteReact(opts = {}) {
|
|
|
94
97
|
runningInVite = true;
|
|
95
98
|
base = config.base;
|
|
96
99
|
if (config.experimental.bundledDev) isBundledDev = true;
|
|
97
|
-
isProduction
|
|
98
|
-
skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
|
|
100
|
+
if (skipFastRefresh !== calculateSkipFastRefresh(config.isProduction, config.command, config.server?.hmr)) this.warn(`NODE_ENV (${JSON.stringify(process.env.NODE_ENV)}) or server.hmr was changed by plugins after the react plugin read the config. This may cause unexpected behavior.`);
|
|
99
101
|
},
|
|
100
102
|
options(options) {
|
|
101
103
|
if (!runningInVite) {
|
|
@@ -125,8 +127,9 @@ function viteReact(opts = {}) {
|
|
|
125
127
|
const viteConfigPost = {
|
|
126
128
|
name: "vite:react:config-post",
|
|
127
129
|
enforce: "post",
|
|
128
|
-
config(userConfig) {
|
|
129
|
-
|
|
130
|
+
config(userConfig, { command }) {
|
|
131
|
+
skipFastRefresh = calculateSkipFastRefresh(process.env.NODE_ENV === "production", command, userConfig.server?.hmr);
|
|
132
|
+
if (skipFastRefresh) return { oxc: { jsx: { refresh: false } } };
|
|
130
133
|
}
|
|
131
134
|
};
|
|
132
135
|
const viteReactRefreshBundledDevMode = {
|
|
@@ -137,7 +140,7 @@ function viteReact(opts = {}) {
|
|
|
137
140
|
if (!skipFastRefresh && isBundledDev) return [{
|
|
138
141
|
tag: "script",
|
|
139
142
|
attrs: { type: "module" },
|
|
140
|
-
children: getPreambleCode(
|
|
143
|
+
children: getPreambleCode("/")
|
|
141
144
|
}];
|
|
142
145
|
},
|
|
143
146
|
order: "pre"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
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.
|
|
46
|
+
"@rolldown/pluginutils": "^1.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "8.0.
|
|
49
|
+
"@babel/core": "8.0.1",
|
|
50
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.
|
|
54
|
-
"react-dom": "^19.2.
|
|
55
|
-
"rolldown": "^1.
|
|
56
|
-
"tsdown": "^0.22.
|
|
57
|
-
"vite": "^8.
|
|
53
|
+
"react": "^19.2.8",
|
|
54
|
+
"react-dom": "^19.2.8",
|
|
55
|
+
"rolldown": "^1.1.5",
|
|
56
|
+
"tsdown": "^0.22.7",
|
|
57
|
+
"vite": "^8.1.4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@rolldown/plugin-babel": "^0.1.7 || ^0.2.0",
|