@rsbuild/core 0.0.21 → 0.0.22
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/compiled/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +1 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +1 -0
- package/compiled/open/license +9 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -0
- package/dist/client/hmr.js +418 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/startUrl.js +1 -1
- package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
- package/dist/rspack-provider/core/createCompiler.js +3 -3
- package/dist/rspack-provider/plugins/css.js +3 -10
- package/dist/rspack-provider/plugins/swc.js +1 -1
- package/dist/rspack-provider/provider.js +2 -2
- package/dist/rspack-provider/shared/plugin.js +1 -4
- package/dist/server/dev-middleware/index.d.ts +1 -0
- package/dist/server/dev-middleware/index.js +5 -4
- package/dist/server/devServer.d.ts +2 -2
- package/dist/server/devServer.js +14 -15
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +2 -2
- package/package.json +7 -11
- package/dist/plugins/rem.d.ts +0 -2
- package/dist/plugins/rem.js +0 -103
- package/dist/rspack-provider/plugins/fallback.d.ts +0 -2
- package/dist/rspack-provider/plugins/fallback.js +0 -52
- package/dist/server/dev-middleware/hmr-client/createSocketUrl.js +0 -68
- package/dist/server/dev-middleware/hmr-client/index.js +0 -141
- /package/dist/{server/dev-middleware/hmr-client → client/hmr}/createSocketUrl.d.ts +0 -0
- /package/dist/{server/dev-middleware/hmr-client → client/hmr}/index.d.ts +0 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
43
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
44
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
45
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
46
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
|
+
}
|
|
48
|
+
var createSocketUrl = function createSocketUrl(resourceQuery) {
|
|
49
|
+
var searchParams = resourceQuery.substr(1).split("&");
|
|
50
|
+
var options = {};
|
|
51
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
52
|
+
try {
|
|
53
|
+
for(var _iterator = searchParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
54
|
+
var pair = _step.value;
|
|
55
|
+
var ary = pair.split("=");
|
|
56
|
+
options[ary[0]] = decodeURIComponent(ary[1]);
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_didIteratorError = true;
|
|
60
|
+
_iteratorError = err;
|
|
61
|
+
} finally{
|
|
62
|
+
try {
|
|
63
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
64
|
+
_iterator.return();
|
|
65
|
+
}
|
|
66
|
+
} finally{
|
|
67
|
+
if (_didIteratorError) {
|
|
68
|
+
throw _iteratorError;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
var currentLocation = self.location;
|
|
73
|
+
return getSocketUrl(options, currentLocation);
|
|
74
|
+
};
|
|
75
|
+
var formatURL = function formatURL(param) {
|
|
76
|
+
var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
|
|
77
|
+
if (window.URL) {
|
|
78
|
+
var url = new URL("http://localhost");
|
|
79
|
+
url.port = port;
|
|
80
|
+
url.hostname = hostname;
|
|
81
|
+
url.protocol = protocol;
|
|
82
|
+
url.pathname = pathname;
|
|
83
|
+
return url.toString();
|
|
84
|
+
}
|
|
85
|
+
var colon = protocol.indexOf(":") === -1 ? ":" : "";
|
|
86
|
+
return "".concat(protocol).concat(colon, "//").concat(hostname, ":").concat(port).concat(pathname);
|
|
87
|
+
};
|
|
88
|
+
var getSocketUrl = function getSocketUrl(urlParts, location) {
|
|
89
|
+
var host = urlParts.host, port = urlParts.port, path = urlParts.path, protocol = urlParts.protocol;
|
|
90
|
+
return formatURL({
|
|
91
|
+
protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
|
|
92
|
+
hostname: host || location.hostname,
|
|
93
|
+
port: port || location.port,
|
|
94
|
+
pathname: path || HMR_SOCK_PATH
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var clearOutdatedErrors = function clearOutdatedErrors() {
|
|
98
|
+
if (typeof console !== "undefined" && typeof console.clear === "function") {
|
|
99
|
+
if (hasCompileErrors) {
|
|
100
|
+
console.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var handleSuccess = function handleSuccess() {
|
|
105
|
+
clearOutdatedErrors();
|
|
106
|
+
var isHotUpdate = !isFirstCompilation;
|
|
107
|
+
isFirstCompilation = false;
|
|
108
|
+
hasCompileErrors = false;
|
|
109
|
+
if (isHotUpdate) {
|
|
110
|
+
tryApplyUpdates();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var handleWarnings = function handleWarnings(warnings) {
|
|
114
|
+
clearOutdatedErrors();
|
|
115
|
+
var isHotUpdate = !isFirstCompilation;
|
|
116
|
+
isFirstCompilation = false;
|
|
117
|
+
hasCompileErrors = false;
|
|
118
|
+
function printWarnings() {
|
|
119
|
+
var formatted = (0, import_format_stats.formatStatsMessages)({
|
|
120
|
+
warnings: warnings,
|
|
121
|
+
errors: []
|
|
122
|
+
});
|
|
123
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
124
|
+
for(var i = 0; i < formatted.warnings.length; i++){
|
|
125
|
+
if (i === 5) {
|
|
126
|
+
console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
console.warn(formatted.warnings[i]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
printWarnings();
|
|
134
|
+
if (isHotUpdate) {
|
|
135
|
+
tryApplyUpdates();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var handleErrors = function handleErrors(errors) {
|
|
139
|
+
clearOutdatedErrors();
|
|
140
|
+
isFirstCompilation = false;
|
|
141
|
+
hasCompileErrors = true;
|
|
142
|
+
var formatted = (0, import_format_stats.formatStatsMessages)({
|
|
143
|
+
errors: errors,
|
|
144
|
+
warnings: []
|
|
145
|
+
});
|
|
146
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
147
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
148
|
+
try {
|
|
149
|
+
for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
150
|
+
var error = _step.value;
|
|
151
|
+
console.error(error);
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
_didIteratorError = true;
|
|
155
|
+
_iteratorError = err;
|
|
156
|
+
} finally{
|
|
157
|
+
try {
|
|
158
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
159
|
+
_iterator.return();
|
|
160
|
+
}
|
|
161
|
+
} finally{
|
|
162
|
+
if (_didIteratorError) {
|
|
163
|
+
throw _iteratorError;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var handleAvailableHash = function handleAvailableHash(hash) {
|
|
170
|
+
mostRecentCompilationHash = hash;
|
|
171
|
+
};
|
|
172
|
+
var isUpdateAvailable = function isUpdateAvailable() {
|
|
173
|
+
return mostRecentCompilationHash !== __webpack_hash__;
|
|
174
|
+
};
|
|
175
|
+
var canApplyUpdates = function canApplyUpdates() {
|
|
176
|
+
return module.hot.status() === "idle";
|
|
177
|
+
};
|
|
178
|
+
var __create = Object.create;
|
|
179
|
+
var __defProp = Object.defineProperty;
|
|
180
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
181
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
182
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
183
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
184
|
+
var __commonJS = function(cb, mod) {
|
|
185
|
+
return function __require() {
|
|
186
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
187
|
+
exports: {}
|
|
188
|
+
}).exports, mod), mod.exports;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
var __copyProps = function(to, from, except, desc) {
|
|
192
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
193
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
194
|
+
try {
|
|
195
|
+
var _loop = function() {
|
|
196
|
+
var key = _step.value;
|
|
197
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
198
|
+
get: function() {
|
|
199
|
+
return from[key];
|
|
200
|
+
},
|
|
201
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
205
|
+
} catch (err) {
|
|
206
|
+
_didIteratorError = true;
|
|
207
|
+
_iteratorError = err;
|
|
208
|
+
} finally{
|
|
209
|
+
try {
|
|
210
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
211
|
+
_iterator.return();
|
|
212
|
+
}
|
|
213
|
+
} finally{
|
|
214
|
+
if (_didIteratorError) {
|
|
215
|
+
throw _iteratorError;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return to;
|
|
221
|
+
};
|
|
222
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
223
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
224
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
225
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
226
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
227
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
228
|
+
value: mod,
|
|
229
|
+
enumerable: true
|
|
230
|
+
}) : target, mod);
|
|
231
|
+
};
|
|
232
|
+
// ../shared/dist/formatStats.js
|
|
233
|
+
var require_formatStats = __commonJS({
|
|
234
|
+
"../shared/dist/formatStats.js": function(exports2, module2) {
|
|
235
|
+
"use strict";
|
|
236
|
+
var isLikelyASyntaxError = function isLikelyASyntaxError(message) {
|
|
237
|
+
return message.includes(friendlySyntaxErrorLabel);
|
|
238
|
+
};
|
|
239
|
+
var formatMessage = function formatMessage(stats) {
|
|
240
|
+
var lines = [];
|
|
241
|
+
var message;
|
|
242
|
+
if (typeof stats === "object") {
|
|
243
|
+
var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
|
|
244
|
+
var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
|
245
|
+
var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
|
|
246
|
+
var stack = stats.stack ? "\n".concat(stats.stack) : "";
|
|
247
|
+
message = "".concat(fileName).concat(mainMessage).concat(details).concat(stack);
|
|
248
|
+
} else {
|
|
249
|
+
message = stats;
|
|
250
|
+
}
|
|
251
|
+
lines = message.split("\n");
|
|
252
|
+
lines = lines.map(function(line) {
|
|
253
|
+
var parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
|
|
254
|
+
if (!parsingError) {
|
|
255
|
+
return line;
|
|
256
|
+
}
|
|
257
|
+
var _parsingError = _sliced_to_array(parsingError, 4), errorLine = _parsingError[1], errorColumn = _parsingError[2], errorMessage = _parsingError[3];
|
|
258
|
+
return "".concat(friendlySyntaxErrorLabel, " ").concat(errorMessage, " (").concat(errorLine, ":").concat(errorColumn, ")");
|
|
259
|
+
});
|
|
260
|
+
message = lines.join("\n");
|
|
261
|
+
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "".concat(friendlySyntaxErrorLabel, " $3 ($1:$2)\n"));
|
|
262
|
+
lines = message.split("\n");
|
|
263
|
+
if (lines.length > 2 && lines[1].trim() === "") {
|
|
264
|
+
lines.splice(1, 1);
|
|
265
|
+
}
|
|
266
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
|
267
|
+
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
|
268
|
+
lines[1] = lines[1].replace("Error: ", "");
|
|
269
|
+
}
|
|
270
|
+
lines = lines.filter(function(line, index, arr) {
|
|
271
|
+
return index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim();
|
|
272
|
+
});
|
|
273
|
+
message = lines.join("\n");
|
|
274
|
+
return message.trim();
|
|
275
|
+
};
|
|
276
|
+
var formatStatsMessages2 = function formatStatsMessages2(json) {
|
|
277
|
+
var _a, _b, _c;
|
|
278
|
+
var formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
|
|
279
|
+
var formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
|
|
280
|
+
var result = {
|
|
281
|
+
errors: formattedErrors || [],
|
|
282
|
+
warnings: formattedWarnings || [],
|
|
283
|
+
errorTips: []
|
|
284
|
+
};
|
|
285
|
+
if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
|
|
286
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
287
|
+
}
|
|
288
|
+
if (result.errors.length > 1) {
|
|
289
|
+
result.errors.length = 1;
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
};
|
|
293
|
+
var __defProp2 = Object.defineProperty;
|
|
294
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
295
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
296
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
297
|
+
var __export = function(target, all) {
|
|
298
|
+
for(var name in all)__defProp2(target, name, {
|
|
299
|
+
get: all[name],
|
|
300
|
+
enumerable: true
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
var __copyProps2 = function(to, from, except, desc) {
|
|
304
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
305
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
306
|
+
try {
|
|
307
|
+
var _loop = function() {
|
|
308
|
+
var key = _step.value;
|
|
309
|
+
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
310
|
+
get: function() {
|
|
311
|
+
return from[key];
|
|
312
|
+
},
|
|
313
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
for(var _iterator = __getOwnPropNames2(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
317
|
+
} catch (err) {
|
|
318
|
+
_didIteratorError = true;
|
|
319
|
+
_iteratorError = err;
|
|
320
|
+
} finally{
|
|
321
|
+
try {
|
|
322
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
323
|
+
_iterator.return();
|
|
324
|
+
}
|
|
325
|
+
} finally{
|
|
326
|
+
if (_didIteratorError) {
|
|
327
|
+
throw _iteratorError;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return to;
|
|
333
|
+
};
|
|
334
|
+
var __toCommonJS = function(mod) {
|
|
335
|
+
return __copyProps2(__defProp2({}, "__esModule", {
|
|
336
|
+
value: true
|
|
337
|
+
}), mod);
|
|
338
|
+
};
|
|
339
|
+
var formatStats_exports = {};
|
|
340
|
+
__export(formatStats_exports, {
|
|
341
|
+
formatStatsMessages: function() {
|
|
342
|
+
return formatStatsMessages2;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
module2.exports = __toCommonJS(formatStats_exports);
|
|
346
|
+
var friendlySyntaxErrorLabel = "SyntaxError:";
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
// src/client/hmr/index.ts
|
|
350
|
+
var import_format_stats = __toESM(require_formatStats());
|
|
351
|
+
// src/client/hmr/createSocketUrl.ts
|
|
352
|
+
var HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
353
|
+
// src/client/hmr/index.ts
|
|
354
|
+
var hadRuntimeError = false;
|
|
355
|
+
var socketUrl = createSocketUrl(__resourceQuery);
|
|
356
|
+
var connection = new WebSocket(socketUrl);
|
|
357
|
+
connection.onopen = function() {
|
|
358
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
359
|
+
console.info("[HMR] connected.");
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
connection.onclose = function() {
|
|
363
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
364
|
+
console.info("[HMR] disconnected. Refresh the page if necessary.");
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var isFirstCompilation = true;
|
|
368
|
+
var mostRecentCompilationHash = null;
|
|
369
|
+
var hasCompileErrors = false;
|
|
370
|
+
connection.onmessage = function(e) {
|
|
371
|
+
var message = JSON.parse(e.data);
|
|
372
|
+
switch(message.type){
|
|
373
|
+
case "hash":
|
|
374
|
+
handleAvailableHash(message.data);
|
|
375
|
+
break;
|
|
376
|
+
case "still-ok":
|
|
377
|
+
case "ok":
|
|
378
|
+
handleSuccess();
|
|
379
|
+
break;
|
|
380
|
+
case "content-changed":
|
|
381
|
+
window.location.reload();
|
|
382
|
+
break;
|
|
383
|
+
case "warnings":
|
|
384
|
+
handleWarnings(message.data);
|
|
385
|
+
break;
|
|
386
|
+
case "errors":
|
|
387
|
+
handleErrors(message.data);
|
|
388
|
+
break;
|
|
389
|
+
default:
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
function tryApplyUpdates() {
|
|
393
|
+
if (!module.hot) {
|
|
394
|
+
window.location.reload();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
function handleApplyUpdates(err, updatedModules) {
|
|
401
|
+
var wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
402
|
+
if (wantsForcedReload) {
|
|
403
|
+
window.location.reload();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (isUpdateAvailable()) {
|
|
407
|
+
tryApplyUpdates();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
|
|
411
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
412
|
+
result.then(function(updatedModules) {
|
|
413
|
+
handleApplyUpdates(null, updatedModules);
|
|
414
|
+
}, function(err) {
|
|
415
|
+
handleApplyUpdates(err, null);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createRsbuild, getCreateRsbuildDefaultOptions } from './createRsbuild';
|
|
2
2
|
export { mergeRsbuildConfig } from '@rsbuild/shared';
|
|
3
3
|
export { defineConfig } from './cli';
|
|
4
|
-
export type { RsbuildPluginAPI, RsbuildConfig } from './rspack-provider';
|
|
4
|
+
export type { RsbuildPluginAPI, RsbuildConfig, Rspack } from './rspack-provider';
|
|
5
5
|
export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildPlugin, Context, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn } from '@rsbuild/shared';
|
package/dist/plugins/index.js
CHANGED
|
@@ -46,7 +46,6 @@ const plugins = {
|
|
|
46
46
|
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
|
|
47
47
|
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
|
|
48
48
|
asset: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset()),
|
|
49
|
-
rem: () => Promise.resolve().then(() => __toESM(require("./rem"))).then((m) => m.pluginRem()),
|
|
50
49
|
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
|
|
51
50
|
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
|
|
52
51
|
nodeAddons: () => Promise.resolve().then(() => __toESM(require("./nodeAddons"))).then((m) => m.pluginNodeAddons()),
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -80,7 +80,7 @@ async function openBrowser(url) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
|
-
const { default: open } = await Promise.resolve().then(() => __toESM(require("open")));
|
|
83
|
+
const { default: open } = await Promise.resolve().then(() => __toESM(require("../../compiled/open")));
|
|
84
84
|
await open(url);
|
|
85
85
|
return true;
|
|
86
86
|
} catch (err) {
|
|
@@ -9,4 +9,4 @@ export declare function createCompiler({
|
|
|
9
9
|
context: Context;
|
|
10
10
|
rspackConfigs: RspackConfig[];
|
|
11
11
|
}): Promise<import("@rspack/core").MultiCompiler>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<import("@rsbuild/shared").DevMiddleware>;
|
|
@@ -29,7 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var createCompiler_exports = {};
|
|
30
30
|
__export(createCompiler_exports, {
|
|
31
31
|
createCompiler: () => createCompiler,
|
|
32
|
-
|
|
32
|
+
createDevMiddleware: () => createDevMiddleware
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(createCompiler_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
@@ -82,7 +82,7 @@ async function createCompiler({
|
|
|
82
82
|
(0, import_shared.debug)("create compiler done");
|
|
83
83
|
return compiler;
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
85
|
+
async function createDevMiddleware(options, customCompiler) {
|
|
86
86
|
let compiler;
|
|
87
87
|
if (customCompiler) {
|
|
88
88
|
compiler = customCompiler;
|
|
@@ -98,5 +98,5 @@ async function startDevCompile(options, customCompiler) {
|
|
|
98
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
99
|
0 && (module.exports = {
|
|
100
100
|
createCompiler,
|
|
101
|
-
|
|
101
|
+
createDevMiddleware
|
|
102
102
|
});
|
|
@@ -90,11 +90,7 @@ async function applyBaseCSSRule({
|
|
|
90
90
|
rule.use(CHAIN_ID.USE.CSS).loader((0, import_shared2.getCompiledPath)("css-loader")).options(cssLoaderOptions).end();
|
|
91
91
|
} else {
|
|
92
92
|
if (!isServer && !isWebWorker && enableCSSModuleTS) {
|
|
93
|
-
const { cssModules
|
|
94
|
-
const cssModulesAuto = (0, import_shared.getCssModulesAutoRule)(
|
|
95
|
-
cssModules,
|
|
96
|
-
disableCssModuleExtension
|
|
97
|
-
);
|
|
93
|
+
const { cssModules } = config.output;
|
|
98
94
|
rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
|
|
99
95
|
import_path.default.resolve(
|
|
100
96
|
__dirname,
|
|
@@ -103,7 +99,7 @@ async function applyBaseCSSRule({
|
|
|
103
99
|
).options({
|
|
104
100
|
modules: {
|
|
105
101
|
exportLocalsConvention: cssModules.exportLocalsConvention,
|
|
106
|
-
auto:
|
|
102
|
+
auto: cssModules.auto
|
|
107
103
|
}
|
|
108
104
|
}).end();
|
|
109
105
|
}
|
|
@@ -129,10 +125,7 @@ const applyCSSModuleRule = (rules, ruleTest, config) => {
|
|
|
129
125
|
if (ruleIndex === -1) {
|
|
130
126
|
return;
|
|
131
127
|
}
|
|
132
|
-
const cssModulesAuto =
|
|
133
|
-
config.output.cssModules,
|
|
134
|
-
config.output.disableCssModuleExtension
|
|
135
|
-
);
|
|
128
|
+
const cssModulesAuto = config.output.cssModules.auto;
|
|
136
129
|
if (!cssModulesAuto) {
|
|
137
130
|
return;
|
|
138
131
|
}
|
|
@@ -71,7 +71,7 @@ const pluginSwc = () => ({
|
|
|
71
71
|
isServer,
|
|
72
72
|
isServiceWorker
|
|
73
73
|
});
|
|
74
|
-
const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(
|
|
74
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
|
|
75
75
|
(0, import_shared.applyScriptCondition)({
|
|
76
76
|
rule,
|
|
77
77
|
config,
|
|
@@ -73,10 +73,10 @@ function rspackProvider({
|
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
75
|
async startDevServer(options) {
|
|
76
|
-
const {
|
|
76
|
+
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
|
|
77
77
|
return (0, import_server.startDevServer)(
|
|
78
78
|
{ context, pluginStore, rsbuildOptions },
|
|
79
|
-
|
|
79
|
+
createDevMiddleware,
|
|
80
80
|
options
|
|
81
81
|
);
|
|
82
82
|
},
|
|
@@ -54,7 +54,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
|
|
|
54
54
|
Promise.resolve().then(() => __toESM(require("../plugins/less"))).then((m) => m.pluginLess()),
|
|
55
55
|
Promise.resolve().then(() => __toESM(require("../plugins/sass"))).then((m) => m.pluginSass()),
|
|
56
56
|
Promise.resolve().then(() => __toESM(require("../plugins/minimize"))).then((m) => m.pluginMinimize()),
|
|
57
|
-
plugins.rem(),
|
|
58
57
|
Promise.resolve().then(() => __toESM(require("../plugins/hmr"))).then((m) => m.pluginHMR()),
|
|
59
58
|
Promise.resolve().then(() => __toESM(require("../plugins/progress"))).then((m) => m.pluginProgress()),
|
|
60
59
|
Promise.resolve().then(() => __toESM(require("../plugins/swc"))).then((m) => m.pluginSwc()),
|
|
@@ -68,9 +67,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
|
|
|
68
67
|
plugins.networkPerformance(),
|
|
69
68
|
plugins.preloadOrPrefetch(),
|
|
70
69
|
plugins.performance(),
|
|
71
|
-
Promise.resolve().then(() => __toESM(require("../plugins/rspack-profile"))).then((m) => m.pluginRspackProfile())
|
|
72
|
-
Promise.resolve().then(() => __toESM(require("../plugins/fallback"))).then((m) => m.pluginFallback())
|
|
73
|
-
// fallback should be the last plugin
|
|
70
|
+
Promise.resolve().then(() => __toESM(require("../plugins/rspack-profile"))).then((m) => m.pluginRspackProfile())
|
|
74
71
|
]);
|
|
75
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
73
|
0 && (module.exports = {
|
|
@@ -40,7 +40,7 @@ function getHMRClientPath(client) {
|
|
|
40
40
|
const host = (client == null ? void 0 : client.host) ? `&host=${client.host}` : "";
|
|
41
41
|
const path = (client == null ? void 0 : client.path) ? `&path=${client.path}` : "";
|
|
42
42
|
const port = (client == null ? void 0 : client.port) ? `&port=${client.port}` : "";
|
|
43
|
-
const clientEntry = `${require.resolve("@rsbuild/core/hmr
|
|
43
|
+
const clientEntry = `${require.resolve("@rsbuild/core/client/hmr")}?${host}${path}${port}${protocol}`;
|
|
44
44
|
return clientEntry;
|
|
45
45
|
}
|
|
46
46
|
class DevMiddleware extends import_events.EventEmitter {
|
|
@@ -48,11 +48,12 @@ class DevMiddleware extends import_events.EventEmitter {
|
|
|
48
48
|
super();
|
|
49
49
|
this.devOptions = dev;
|
|
50
50
|
this.socketServer = new import_socketServer.default(dev);
|
|
51
|
-
|
|
52
|
-
this.middleware = this.setupDevMiddleware(devMiddleware);
|
|
53
|
-
}
|
|
51
|
+
this.devMiddleware = devMiddleware;
|
|
54
52
|
}
|
|
55
53
|
init(app) {
|
|
54
|
+
if (this.devMiddleware) {
|
|
55
|
+
this.middleware = this.setupDevMiddleware(this.devMiddleware);
|
|
56
|
+
}
|
|
56
57
|
app.on("listening", () => {
|
|
57
58
|
this.socketServer.prepare(app);
|
|
58
59
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Server } from 'http';
|
|
5
5
|
import type { ListenOptions } from 'net';
|
|
6
6
|
import { RsbuildDevServerOptions, CreateDevServerOptions, DevServerContext, StartDevServerOptions, StartServerResult } from '@rsbuild/shared';
|
|
7
|
-
import connect from 'connect';
|
|
7
|
+
import connect from '@rsbuild/shared/connect';
|
|
8
8
|
export declare class RsbuildDevServer {
|
|
9
9
|
private readonly dev;
|
|
10
10
|
private readonly devMiddleware;
|
|
@@ -22,7 +22,7 @@ export declare class RsbuildDevServer {
|
|
|
22
22
|
}
|
|
23
23
|
export declare function startDevServer<Options extends {
|
|
24
24
|
context: DevServerContext;
|
|
25
|
-
}>(options: Options,
|
|
25
|
+
}>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevServerOptions['devMiddleware']>, {
|
|
26
26
|
open,
|
|
27
27
|
compiler,
|
|
28
28
|
printURLs,
|