@vitejs/plugin-react 2.0.0-beta.0 → 2.0.0-beta.1

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
@@ -232,10 +232,10 @@ function viteReact(opts = {}) {
232
232
  runPluginOverrides = (babelOptions, context) => {
233
233
  const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(Boolean);
234
234
  if (hooks.length > 0) {
235
- return (runPluginOverrides = (babelOptions2) => {
236
- hooks.forEach((hook) => hook(babelOptions2, context, config));
235
+ return (runPluginOverrides = (babelOptions2, context2) => {
236
+ hooks.forEach((hook) => hook(babelOptions2, context2, config));
237
237
  return true;
238
- })(babelOptions);
238
+ })(babelOptions, context);
239
239
  }
240
240
  runPluginOverrides = () => false;
241
241
  return false;
@@ -301,7 +301,9 @@ function viteReact(opts = {}) {
301
301
  }
302
302
  const shouldSkip = !plugins.length && !babelOptions.configFile && !(isProjectFile && babelOptions.babelrc);
303
303
  if (shouldSkip) {
304
- return;
304
+ return {
305
+ code
306
+ };
305
307
  }
306
308
  const parserPlugins = [
307
309
  ...babelOptions.parserOpts.plugins,
package/dist/index.mjs CHANGED
@@ -212,10 +212,10 @@ function viteReact(opts = {}) {
212
212
  runPluginOverrides = (babelOptions, context) => {
213
213
  const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(Boolean);
214
214
  if (hooks.length > 0) {
215
- return (runPluginOverrides = (babelOptions2) => {
216
- hooks.forEach((hook) => hook(babelOptions2, context, config));
215
+ return (runPluginOverrides = (babelOptions2, context2) => {
216
+ hooks.forEach((hook) => hook(babelOptions2, context2, config));
217
217
  return true;
218
- })(babelOptions);
218
+ })(babelOptions, context);
219
219
  }
220
220
  runPluginOverrides = () => false;
221
221
  return false;
@@ -281,7 +281,9 @@ function viteReact(opts = {}) {
281
281
  }
282
282
  const shouldSkip = !plugins.length && !babelOptions.configFile && !(isProjectFile && babelOptions.babelrc);
283
283
  if (shouldSkip) {
284
- return;
284
+ return {
285
+ code
286
+ };
285
287
  }
286
288
  const parserPlugins = [
287
289
  ...babelOptions.parserOpts.plugins,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "contributors": [
@@ -23,7 +23,7 @@
23
23
  "scripts": {
24
24
  "dev": "unbuild --stub",
25
25
  "build": "unbuild && pnpm run patch-cjs",
26
- "patch-cjs": "esno ../../scripts/patchCJS.ts",
26
+ "patch-cjs": "tsx ../../scripts/patchCJS.ts",
27
27
  "prepublishOnly": "npm run build"
28
28
  },
29
29
  "engines": {
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
41
41
  "dependencies": {
42
- "@babel/core": "^7.18.5",
43
- "@babel/plugin-transform-react-jsx": "^7.17.12",
44
- "@babel/plugin-transform-react-jsx-development": "^7.16.7",
45
- "@babel/plugin-transform-react-jsx-self": "^7.17.12",
46
- "@babel/plugin-transform-react-jsx-source": "^7.16.7",
42
+ "@babel/core": "^7.18.6",
43
+ "@babel/plugin-transform-react-jsx": "^7.18.6",
44
+ "@babel/plugin-transform-react-jsx-development": "^7.18.6",
45
+ "@babel/plugin-transform-react-jsx-self": "^7.18.6",
46
+ "@babel/plugin-transform-react-jsx-source": "^7.18.6",
47
47
  "react-refresh": "^0.14.0"
48
48
  },
49
49
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -165,10 +165,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
165
165
  .filter(Boolean) as ReactBabelHook[]
166
166
 
167
167
  if (hooks.length > 0) {
168
- return (runPluginOverrides = (babelOptions) => {
168
+ return (runPluginOverrides = (babelOptions, context) => {
169
169
  hooks.forEach((hook) => hook(babelOptions, context, config))
170
170
  return true
171
- })(babelOptions)
171
+ })(babelOptions, context)
172
172
  }
173
173
  runPluginOverrides = () => false
174
174
  return false
@@ -276,7 +276,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
276
276
  !(isProjectFile && babelOptions.babelrc)
277
277
 
278
278
  if (shouldSkip) {
279
- return // Avoid parsing if no plugins exist.
279
+ // Avoid parsing if no plugins exist.
280
+ return {
281
+ code
282
+ }
280
283
  }
281
284
 
282
285
  const parserPlugins: typeof babelOptions.parserOpts.plugins = [