@vitejs/plugin-react 4.1.0 → 4.2.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
@@ -94,7 +94,7 @@ function viteReact(opts = {}) {
94
94
  let skipFastRefresh = false;
95
95
  let runPluginOverrides;
96
96
  let staticBabelOptions;
97
- const importReactRE = /(?:^|\s)import\s+(?:\*\s+as\s+)?React(?:,|\s+)/;
97
+ const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
98
98
  const viteBabel = {
99
99
  name: "vite:react-babel",
100
100
  enforce: "pre",
@@ -110,7 +110,8 @@ function viteReact(opts = {}) {
110
110
  esbuild: {
111
111
  jsx: "automatic",
112
112
  jsxImportSource: opts.jsxImportSource
113
- }
113
+ },
114
+ optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
114
115
  };
115
116
  }
116
117
  },
@@ -182,6 +183,8 @@ function viteReact(opts = {}) {
182
183
  root: projectRoot,
183
184
  filename: id,
184
185
  sourceFileName: filepath,
186
+ // Required for esbuild.jsxDev to provide correct line numbers
187
+ retainLines: !isProduction && isJSX && opts.jsxRuntime !== "classic",
185
188
  parserOpts: {
186
189
  ...babelOptions.parserOpts,
187
190
  sourceType: "module",
package/dist/index.mjs CHANGED
@@ -86,7 +86,7 @@ function viteReact(opts = {}) {
86
86
  let skipFastRefresh = false;
87
87
  let runPluginOverrides;
88
88
  let staticBabelOptions;
89
- const importReactRE = /(?:^|\s)import\s+(?:\*\s+as\s+)?React(?:,|\s+)/;
89
+ const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
90
90
  const viteBabel = {
91
91
  name: "vite:react-babel",
92
92
  enforce: "pre",
@@ -102,7 +102,8 @@ function viteReact(opts = {}) {
102
102
  esbuild: {
103
103
  jsx: "automatic",
104
104
  jsxImportSource: opts.jsxImportSource
105
- }
105
+ },
106
+ optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
106
107
  };
107
108
  }
108
109
  },
@@ -174,6 +175,8 @@ function viteReact(opts = {}) {
174
175
  root: projectRoot,
175
176
  filename: id,
176
177
  sourceFileName: filepath,
178
+ // Required for esbuild.jsxDev to provide correct line numbers
179
+ retainLines: !isProduction && isJSX && opts.jsxRuntime !== "classic",
177
180
  parserOpts: {
178
181
  ...babelOptions.parserOpts,
179
182
  sourceType: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "contributors": [
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
40
40
  "dependencies": {
41
- "@babel/core": "^7.22.20",
42
- "@babel/plugin-transform-react-jsx-self": "^7.22.5",
43
- "@babel/plugin-transform-react-jsx-source": "^7.22.5",
44
- "@types/babel__core": "^7.20.2",
41
+ "@babel/core": "^7.23.3",
42
+ "@babel/plugin-transform-react-jsx-self": "^7.23.3",
43
+ "@babel/plugin-transform-react-jsx-source": "^7.23.3",
44
+ "@types/babel__core": "^7.20.4",
45
45
  "react-refresh": "^0.14.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "vite": "^4.2.0"
48
+ "vite": "^4.2.0 || ^5.0.0"
49
49
  }
50
50
  }