@vitejs/plugin-react 4.5.2 → 4.6.0

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.cjs CHANGED
@@ -141,9 +141,10 @@ function viteReact(opts = {}) {
141
141
  const jsxImportSource = opts.jsxImportSource ?? "react";
142
142
  const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
143
143
  const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
144
+ let runningInVite = false;
144
145
  let isProduction = true;
145
146
  let projectRoot = process.cwd();
146
- let skipFastRefresh = false;
147
+ let skipFastRefresh = true;
147
148
  let runPluginOverrides;
148
149
  let staticBabelOptions;
149
150
  const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
@@ -182,6 +183,7 @@ function viteReact(opts = {}) {
182
183
  }
183
184
  },
184
185
  configResolved(config) {
186
+ runningInVite = true;
185
187
  projectRoot = config.root;
186
188
  isProduction = config.isProduction;
187
189
  skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
@@ -207,6 +209,15 @@ function viteReact(opts = {}) {
207
209
  }
208
210
  }
209
211
  },
212
+ options(options) {
213
+ if (!runningInVite) {
214
+ options.jsx = {
215
+ mode: opts.jsxRuntime,
216
+ importSource: opts.jsxImportSource
217
+ };
218
+ return options;
219
+ }
220
+ },
210
221
  transform: {
211
222
  filter: {
212
223
  id: {
package/dist/index.mjs CHANGED
@@ -125,9 +125,10 @@ function viteReact(opts = {}) {
125
125
  const jsxImportSource = opts.jsxImportSource ?? "react";
126
126
  const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
127
127
  const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
128
+ let runningInVite = false;
128
129
  let isProduction = true;
129
130
  let projectRoot = process.cwd();
130
- let skipFastRefresh = false;
131
+ let skipFastRefresh = true;
131
132
  let runPluginOverrides;
132
133
  let staticBabelOptions;
133
134
  const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
@@ -166,6 +167,7 @@ function viteReact(opts = {}) {
166
167
  }
167
168
  },
168
169
  configResolved(config) {
170
+ runningInVite = true;
169
171
  projectRoot = config.root;
170
172
  isProduction = config.isProduction;
171
173
  skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
@@ -191,6 +193,15 @@ function viteReact(opts = {}) {
191
193
  }
192
194
  }
193
195
  },
196
+ options(options) {
197
+ if (!runningInVite) {
198
+ options.jsx = {
199
+ mode: opts.jsxRuntime,
200
+ importSource: opts.jsxImportSource
201
+ };
202
+ return options;
203
+ }
204
+ },
194
205
  transform: {
195
206
  filter: {
196
207
  id: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "4.5.2",
3
+ "version": "4.6.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "The default Vite plugin for React projects",
@@ -33,7 +33,8 @@
33
33
  "dev": "unbuild --stub",
34
34
  "build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshRuntime.ts",
35
35
  "patch-cjs": "tsx ../../scripts/patchCJS.ts",
36
- "prepublishOnly": "npm run build"
36
+ "prepublishOnly": "npm run build",
37
+ "test-unit": "vitest run"
37
38
  },
38
39
  "engines": {
39
40
  "node": "^14.18.0 || >=16.0.0"
@@ -51,7 +52,7 @@
51
52
  "@babel/core": "^7.27.4",
52
53
  "@babel/plugin-transform-react-jsx-self": "^7.27.1",
53
54
  "@babel/plugin-transform-react-jsx-source": "^7.27.1",
54
- "@rolldown/pluginutils": "1.0.0-beta.11",
55
+ "@rolldown/pluginutils": "1.0.0-beta.19",
55
56
  "@types/babel__core": "^7.20.5",
56
57
  "react-refresh": "^0.17.0"
57
58
  },
@@ -60,6 +61,11 @@
60
61
  },
61
62
  "devDependencies": {
62
63
  "@vitejs/react-common": "workspace:*",
63
- "unbuild": "^3.5.0"
64
+ "babel-plugin-react-compiler": "19.1.0-rc.2",
65
+ "react": "^19.1.0",
66
+ "react-dom": "^19.1.0",
67
+ "rolldown": "1.0.0-beta.19",
68
+ "unbuild": "^3.5.0",
69
+ "vitest": "^3.2.4"
64
70
  }
65
71
  }