@vitejs/plugin-react 4.0.0-beta.0 → 4.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/README.md +1 -1
- package/dist/index.cjs +3 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -4
- package/package.json +1 -1
package/README.md
CHANGED
@@ -40,7 +40,7 @@ export default defineConfig({
|
|
40
40
|
|
41
41
|
### jsxImportSource
|
42
42
|
|
43
|
-
Control where the JSX factory is imported from.
|
43
|
+
Control where the JSX factory is imported from. Default to `'react'`
|
44
44
|
|
45
45
|
```js
|
46
46
|
react({ jsxImportSource: '@emotion/react' })
|
package/dist/index.cjs
CHANGED
@@ -94,6 +94,7 @@ const tsRE = /\.tsx?$/;
|
|
94
94
|
function viteReact(opts = {}) {
|
95
95
|
let devBase = "/";
|
96
96
|
const filter = vite.createFilter(opts.include ?? defaultIncludeRE, opts.exclude);
|
97
|
+
const devRuntime = `${opts.jsxImportSource ?? "react"}/jsx-dev-runtime`;
|
97
98
|
let needHiresSourcemap = false;
|
98
99
|
let isProduction = true;
|
99
100
|
let projectRoot = process.cwd();
|
@@ -163,9 +164,7 @@ function viteReact(opts = {}) {
|
|
163
164
|
})();
|
164
165
|
const plugins = [...babelOptions.plugins];
|
165
166
|
const isJSX = filepath.endsWith("x");
|
166
|
-
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? code.includes(
|
167
|
-
`${opts.jsxImportSource ?? "react"}/jsx-dev-runtime`
|
168
|
-
) : importReactRE.test(code)));
|
167
|
+
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? code.includes(devRuntime) : importReactRE.test(code)));
|
169
168
|
if (useFastRefresh) {
|
170
169
|
plugins.push([
|
171
170
|
await loadPlugin("react-refresh/babel"),
|
@@ -243,7 +242,7 @@ function viteReact(opts = {}) {
|
|
243
242
|
// We can't add `react-dom` because the dependency is `react-dom/client`
|
244
243
|
// for React 18 while it's `react-dom` for React 17. We'd need to detect
|
245
244
|
// what React version the user has installed.
|
246
|
-
include: ["react"]
|
245
|
+
include: ["react", devRuntime]
|
247
246
|
},
|
248
247
|
resolve: {
|
249
248
|
dedupe: ["react", "react-dom"]
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
@@ -73,6 +73,7 @@ const tsRE = /\.tsx?$/;
|
|
73
73
|
function viteReact(opts = {}) {
|
74
74
|
let devBase = "/";
|
75
75
|
const filter = createFilter(opts.include ?? defaultIncludeRE, opts.exclude);
|
76
|
+
const devRuntime = `${opts.jsxImportSource ?? "react"}/jsx-dev-runtime`;
|
76
77
|
let needHiresSourcemap = false;
|
77
78
|
let isProduction = true;
|
78
79
|
let projectRoot = process.cwd();
|
@@ -142,9 +143,7 @@ function viteReact(opts = {}) {
|
|
142
143
|
})();
|
143
144
|
const plugins = [...babelOptions.plugins];
|
144
145
|
const isJSX = filepath.endsWith("x");
|
145
|
-
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? code.includes(
|
146
|
-
`${opts.jsxImportSource ?? "react"}/jsx-dev-runtime`
|
147
|
-
) : importReactRE.test(code)));
|
146
|
+
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? code.includes(devRuntime) : importReactRE.test(code)));
|
148
147
|
if (useFastRefresh) {
|
149
148
|
plugins.push([
|
150
149
|
await loadPlugin("react-refresh/babel"),
|
@@ -222,7 +221,7 @@ function viteReact(opts = {}) {
|
|
222
221
|
// We can't add `react-dom` because the dependency is `react-dom/client`
|
223
222
|
// for React 18 while it's `react-dom` for React 17. We'd need to detect
|
224
223
|
// what React version the user has installed.
|
225
|
-
include: ["react"]
|
224
|
+
include: ["react", devRuntime]
|
226
225
|
},
|
227
226
|
resolve: {
|
228
227
|
dedupe: ["react", "react-dom"]
|