@vitejs/plugin-react 1.3.0 → 1.3.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.js +12 -10
- package/package.json +3 -3
- package/src/fast-refresh.ts +7 -2
- package/src/index.ts +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
@@ -151,12 +151,12 @@ function babel_restore_jsx_default({ types: t }) {
|
|
151
151
|
const isPlainObjectExpression = (node) => t.isObjectExpression(node) && node.properties.every((property) => t.isSpreadElement(property) || t.isObjectProperty(property, { computed: false }) && getJSXIdentifier(property.key) != null && getJSXAttributeValue(property.value) != null);
|
152
152
|
return {
|
153
153
|
visitor: {
|
154
|
-
CallExpression(
|
155
|
-
const node = getJSXNode(
|
154
|
+
CallExpression(path2) {
|
155
|
+
const node = getJSXNode(path2.node);
|
156
156
|
if (node == null) {
|
157
157
|
return null;
|
158
158
|
}
|
159
|
-
|
159
|
+
path2.replaceWith(node);
|
160
160
|
}
|
161
161
|
}
|
162
162
|
};
|
@@ -179,8 +179,10 @@ var import_resolve = __toESM(require("resolve"));
|
|
179
179
|
|
180
180
|
// src/fast-refresh.ts
|
181
181
|
var import_fs = __toESM(require("fs"));
|
182
|
+
var import_path = __toESM(require("path"));
|
182
183
|
var runtimePublicPath = "/@react-refresh";
|
183
|
-
var
|
184
|
+
var reactRefreshDir = import_path.default.dirname(require.resolve("react-refresh/package.json"));
|
185
|
+
var runtimeFilePath = import_path.default.join(reactRefreshDir, "cjs/react-refresh-runtime.development.js");
|
184
186
|
var runtimeCode = `
|
185
187
|
const exports = {}
|
186
188
|
${import_fs.default.readFileSync(runtimeFilePath, "utf-8")}
|
@@ -268,10 +270,10 @@ function isComponentLikeName(name) {
|
|
268
270
|
function babelImportToRequire({ types: t }) {
|
269
271
|
return {
|
270
272
|
visitor: {
|
271
|
-
ImportDeclaration(
|
272
|
-
const decl =
|
273
|
+
ImportDeclaration(path2) {
|
274
|
+
const decl = path2.node;
|
273
275
|
const spec = decl.specifiers[0];
|
274
|
-
|
276
|
+
path2.replaceWith(t.variableDeclaration("var", [
|
275
277
|
t.variableDeclarator(spec.local, t.memberExpression(t.callExpression(t.identifier("require"), [decl.source]), spec.imported))
|
276
278
|
]));
|
277
279
|
}
|
@@ -388,7 +390,7 @@ function viteReact(opts = {}) {
|
|
388
390
|
if (isReactModule && filter(id)) {
|
389
391
|
useFastRefresh = true;
|
390
392
|
plugins.push([
|
391
|
-
await loadPlugin("react-refresh/babel
|
393
|
+
await loadPlugin("react-refresh/babel"),
|
392
394
|
{ skipEnvCheck: true }
|
393
395
|
]);
|
394
396
|
}
|
@@ -529,8 +531,8 @@ function viteReact(opts = {}) {
|
|
529
531
|
return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx];
|
530
532
|
}
|
531
533
|
viteReact.preambleCode = preambleCode;
|
532
|
-
function loadPlugin(
|
533
|
-
return Promise.resolve().then(() => __toESM(require(
|
534
|
+
function loadPlugin(path2) {
|
535
|
+
return Promise.resolve().then(() => __toESM(require(path2))).then((module2) => module2.default || module2);
|
534
536
|
}
|
535
537
|
// Annotate the CommonJS export names for ESM import in node:
|
536
538
|
0 && (module.exports = {});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitejs/plugin-react",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Evan You",
|
6
6
|
"contributors": [
|
@@ -33,13 +33,13 @@
|
|
33
33
|
},
|
34
34
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
|
35
35
|
"dependencies": {
|
36
|
-
"@babel/core": "^7.17.
|
36
|
+
"@babel/core": "^7.17.9",
|
37
37
|
"@babel/plugin-transform-react-jsx": "^7.17.3",
|
38
38
|
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
|
39
39
|
"@babel/plugin-transform-react-jsx-self": "^7.16.7",
|
40
40
|
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
|
41
41
|
"@rollup/pluginutils": "^4.2.0",
|
42
|
-
"react-refresh": "^0.
|
42
|
+
"react-refresh": "^0.12.0",
|
43
43
|
"resolve": "^1.22.0"
|
44
44
|
}
|
45
45
|
}
|
package/src/fast-refresh.ts
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
import type { types as t } from '@babel/core'
|
2
2
|
import fs from 'fs'
|
3
|
+
import path from 'path'
|
3
4
|
|
4
5
|
export const runtimePublicPath = '/@react-refresh'
|
5
6
|
|
6
|
-
const
|
7
|
-
'react-refresh/
|
7
|
+
const reactRefreshDir = path.dirname(
|
8
|
+
require.resolve('react-refresh/package.json')
|
9
|
+
)
|
10
|
+
const runtimeFilePath = path.join(
|
11
|
+
reactRefreshDir,
|
12
|
+
'cjs/react-refresh-runtime.development.js'
|
8
13
|
)
|
9
14
|
|
10
15
|
export const runtimeCode = `
|
package/src/index.ts
CHANGED
@@ -176,7 +176,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
176
176
|
if (isReactModule && filter(id)) {
|
177
177
|
useFastRefresh = true
|
178
178
|
plugins.push([
|
179
|
-
await loadPlugin('react-refresh/babel
|
179
|
+
await loadPlugin('react-refresh/babel'),
|
180
180
|
{ skipEnvCheck: true }
|
181
181
|
])
|
182
182
|
}
|