@vitejs/plugin-react-swc 3.9.0 → 3.10.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/index.cjs +27 -13
- package/index.mjs +27 -13
- package/package.json +3 -2
package/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ var import_core = require("@swc/core");
|
|
|
8
8
|
// ../common/refresh-utils.ts
|
|
9
9
|
var runtimePublicPath = "/@react-refresh";
|
|
10
10
|
var reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
|
11
|
-
var refreshContentRE = /\$
|
|
11
|
+
var refreshContentRE = /\$RefreshReg\$\(/;
|
|
12
12
|
var preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(
|
|
13
13
|
1
|
|
14
14
|
)}"
|
|
@@ -95,7 +95,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
95
95
|
rollupOptions: {
|
|
96
96
|
onwarn(warning, defaultHandler) {
|
|
97
97
|
var _a, _b;
|
|
98
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
|
|
98
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
@@ -111,6 +111,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
// src/index.ts
|
|
114
|
+
var import_pluginutils = require("@rolldown/pluginutils");
|
|
114
115
|
var import_meta = {};
|
|
115
116
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
116
117
|
var resolve = (0, import_node_module.createRequire)(
|
|
@@ -133,11 +134,20 @@ var react = (_options) => {
|
|
|
133
134
|
apply: "serve",
|
|
134
135
|
enforce: "pre",
|
|
135
136
|
// Run before Vite default resolve to avoid syscalls
|
|
136
|
-
resolveId:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
resolveId: {
|
|
138
|
+
filter: { id: (0, import_pluginutils.exactRegex)(runtimePublicPath) },
|
|
139
|
+
handler: (id) => id === runtimePublicPath ? id : void 0
|
|
140
|
+
},
|
|
141
|
+
load: {
|
|
142
|
+
filter: { id: (0, import_pluginutils.exactRegex)(runtimePublicPath) },
|
|
143
|
+
handler: (id) => id === runtimePublicPath ? (0, import_node_fs.readFileSync)(
|
|
144
|
+
(0, import_node_path.join)(_dirname, "refresh-runtime.js"),
|
|
145
|
+
"utf-8"
|
|
146
|
+
).replace(
|
|
147
|
+
/__README_URL__/g,
|
|
148
|
+
"https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc"
|
|
149
|
+
) : void 0
|
|
150
|
+
}
|
|
141
151
|
},
|
|
142
152
|
{
|
|
143
153
|
name: "vite:react-swc",
|
|
@@ -162,13 +172,17 @@ var react = (_options) => {
|
|
|
162
172
|
);
|
|
163
173
|
}
|
|
164
174
|
},
|
|
165
|
-
transformIndexHtml: (_, config) =>
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
transformIndexHtml: (_, config) => {
|
|
176
|
+
if (!hmrDisabled) {
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
tag: "script",
|
|
180
|
+
attrs: { type: "module" },
|
|
181
|
+
children: getPreambleCode(config.server.config.base)
|
|
182
|
+
}
|
|
183
|
+
];
|
|
170
184
|
}
|
|
171
|
-
|
|
185
|
+
},
|
|
172
186
|
async transform(code, _id, transformOptions) {
|
|
173
187
|
const id = _id.split("?")[0];
|
|
174
188
|
const refresh = !(transformOptions == null ? void 0 : transformOptions.ssr) && !hmrDisabled;
|
package/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
// ../common/refresh-utils.ts
|
|
11
11
|
var runtimePublicPath = "/@react-refresh";
|
|
12
12
|
var reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
|
13
|
-
var refreshContentRE = /\$
|
|
13
|
+
var refreshContentRE = /\$RefreshReg\$\(/;
|
|
14
14
|
var preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(
|
|
15
15
|
1
|
|
16
16
|
)}"
|
|
@@ -97,7 +97,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
97
97
|
rollupOptions: {
|
|
98
98
|
onwarn(warning, defaultHandler) {
|
|
99
99
|
var _a, _b;
|
|
100
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
|
|
100
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
@@ -113,6 +113,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
// src/index.ts
|
|
116
|
+
import { exactRegex } from "@rolldown/pluginutils";
|
|
116
117
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
117
118
|
var resolve = createRequire(
|
|
118
119
|
typeof __filename !== "undefined" ? __filename : import.meta.url
|
|
@@ -134,11 +135,20 @@ var react = (_options) => {
|
|
|
134
135
|
apply: "serve",
|
|
135
136
|
enforce: "pre",
|
|
136
137
|
// Run before Vite default resolve to avoid syscalls
|
|
137
|
-
resolveId:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
resolveId: {
|
|
139
|
+
filter: { id: exactRegex(runtimePublicPath) },
|
|
140
|
+
handler: (id) => id === runtimePublicPath ? id : void 0
|
|
141
|
+
},
|
|
142
|
+
load: {
|
|
143
|
+
filter: { id: exactRegex(runtimePublicPath) },
|
|
144
|
+
handler: (id) => id === runtimePublicPath ? readFileSync(
|
|
145
|
+
join(_dirname, "refresh-runtime.js"),
|
|
146
|
+
"utf-8"
|
|
147
|
+
).replace(
|
|
148
|
+
/__README_URL__/g,
|
|
149
|
+
"https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc"
|
|
150
|
+
) : void 0
|
|
151
|
+
}
|
|
142
152
|
},
|
|
143
153
|
{
|
|
144
154
|
name: "vite:react-swc",
|
|
@@ -163,13 +173,17 @@ var react = (_options) => {
|
|
|
163
173
|
);
|
|
164
174
|
}
|
|
165
175
|
},
|
|
166
|
-
transformIndexHtml: (_, config) =>
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
transformIndexHtml: (_, config) => {
|
|
177
|
+
if (!hmrDisabled) {
|
|
178
|
+
return [
|
|
179
|
+
{
|
|
180
|
+
tag: "script",
|
|
181
|
+
attrs: { type: "module" },
|
|
182
|
+
children: getPreambleCode(config.server.config.base)
|
|
183
|
+
}
|
|
184
|
+
];
|
|
171
185
|
}
|
|
172
|
-
|
|
186
|
+
},
|
|
173
187
|
async transform(code, _id, transformOptions) {
|
|
174
188
|
const id = _id.split("?")[0];
|
|
175
189
|
const refresh = !(transformOptions == null ? void 0 : transformOptions.ssr) && !hmrDisabled;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react-swc",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
|
|
6
6
|
"description": "Speed up your Vite dev server with SWC",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@
|
|
26
|
+
"@rolldown/pluginutils": "1.0.0-beta.9",
|
|
27
|
+
"@swc/core": "^1.11.22"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"vite": "^4 || ^5 || ^6"
|