@vitejs/plugin-react 6.0.3 → 6.0.5

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/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,9 +41,9 @@ 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
+ const defaultCodeFilter = /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/;
45
45
  const reactCompilerPreset = (options = {}) => ({
46
- preset: () => ({ plugins: [["babel-plugin-react-compiler", options]] }),
46
+ preset: () => ({ plugins: [[fileURLToPath(import.meta.resolve("babel-plugin-react-compiler")), options]] }),
47
47
  rolldown: {
48
48
  filter: { code: options.compilationMode === "annotation" ? /['"]use memo['"]/ : defaultCodeFilter },
49
49
  applyToEnvironmentHook: (env) => env.config.consumer === "client",
@@ -62,10 +62,12 @@ function viteReact(opts = {}) {
62
62
  const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
63
63
  const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
64
64
  let runningInVite = false;
65
- let isProduction = true;
66
65
  let skipFastRefresh = true;
67
66
  let base;
68
67
  let isBundledDev = false;
68
+ function calculateSkipFastRefresh(isProduction, command, hmr) {
69
+ return isProduction || command === "build" || hmr === false;
70
+ }
69
71
  const viteBabel = {
70
72
  name: "vite:react-babel",
71
73
  enforce: "pre",
@@ -95,8 +97,7 @@ function viteReact(opts = {}) {
95
97
  runningInVite = true;
96
98
  base = config.base;
97
99
  if (config.experimental.bundledDev) isBundledDev = true;
98
- isProduction = config.isProduction;
99
- 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.`);
100
101
  },
101
102
  options(options) {
102
103
  if (!runningInVite) {
@@ -126,8 +127,9 @@ function viteReact(opts = {}) {
126
127
  const viteConfigPost = {
127
128
  name: "vite:react:config-post",
128
129
  enforce: "post",
129
- config(userConfig) {
130
- if (userConfig.server?.hmr === false) return { oxc: { jsx: { refresh: false } } };
130
+ config(userConfig, { command }) {
131
+ skipFastRefresh = calculateSkipFastRefresh(process.env.NODE_ENV === "production", command, userConfig.server?.hmr);
132
+ if (skipFastRefresh) return { oxc: { jsx: { refresh: false } } };
131
133
  }
132
134
  };
133
135
  const viteReactRefreshBundledDevMode = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "The default Vite plugin for React projects",
5
5
  "keywords": [
6
6
  "fast refresh",
@@ -46,15 +46,15 @@
46
46
  "@rolldown/pluginutils": "^1.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/core": "8.0.0-rc.6",
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.7",
54
- "react-dom": "^19.2.7",
55
- "rolldown": "^1.1.1",
56
- "tsdown": "^0.22.2",
57
- "vite": "^8.0.16"
53
+ "react": "^19.2.8",
54
+ "react-dom": "^19.2.8",
55
+ "rolldown": "^1.2.0",
56
+ "tsdown": "^0.22.14",
57
+ "vite": "^8.1.5"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0",