@rsbuild/core 0.5.3 → 0.5.5
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/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr/createSocketUrl.d.ts +2 -1
- package/dist/client/hmr/overlay.d.ts +2 -0
- package/dist/client/hmr.mjs +248 -5
- package/dist/index.js +1 -1
- package/dist/plugins/moduleFederation.js +12 -0
- package/dist/plugins/splitChunks.js +1 -4
- package/dist/provider/build.js +17 -5
- package/dist/provider/createCompiler.js +7 -5
- package/dist/provider/createContext.js +1 -1
- package/dist/provider/provider.js +5 -1
- package/dist/provider/shared.d.ts +4 -1
- package/dist/provider/shared.js +28 -2
- package/dist/server/compilerDevMiddleware.js +5 -6
- package/dist/server/helper.d.ts +1 -0
- package/dist/server/socketServer.js +10 -6
- package/package.json +3 -3
package/dist/cli/commands.js
CHANGED
|
@@ -39,7 +39,7 @@ const applyServerOptions = (command) => {
|
|
|
39
39
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
40
40
|
};
|
|
41
41
|
function runCli() {
|
|
42
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.5.
|
|
42
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.5.5");
|
|
43
43
|
const devCommand = import_commander.program.command("dev");
|
|
44
44
|
const buildCommand = import_commander.program.command("build");
|
|
45
45
|
const previewCommand = import_commander.program.command("preview");
|
package/dist/cli/prepare.js
CHANGED
|
@@ -34,7 +34,7 @@ function prepareCli() {
|
|
|
34
34
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
35
35
|
console.log();
|
|
36
36
|
}
|
|
37
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"0.5.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.5.5"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* hmr socket connect path
|
|
3
3
|
*/
|
|
4
4
|
export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function parseParams(resourceQuery: string): Record<string, string>;
|
|
6
|
+
export declare function createSocketUrl(options?: Record<string, string>): string;
|
|
6
7
|
export declare function formatURL({ port, protocol, hostname, pathname, }: {
|
|
7
8
|
port: string;
|
|
8
9
|
protocol: string;
|
package/dist/client/hmr.mjs
CHANGED
|
@@ -7,6 +7,12 @@ function _array_like_to_array(arr, len) {
|
|
|
7
7
|
function _array_with_holes(arr) {
|
|
8
8
|
if (Array.isArray(arr)) return arr;
|
|
9
9
|
}
|
|
10
|
+
function _assert_this_initialized(self1) {
|
|
11
|
+
if (self1 === void 0) {
|
|
12
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
}
|
|
14
|
+
return self1;
|
|
15
|
+
}
|
|
10
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
17
|
try {
|
|
12
18
|
var info = gen[key](arg);
|
|
@@ -36,6 +42,64 @@ function _async_to_generator(fn) {
|
|
|
36
42
|
});
|
|
37
43
|
};
|
|
38
44
|
}
|
|
45
|
+
function _class_call_check(instance, Constructor) {
|
|
46
|
+
if (!(instance instanceof Constructor)) {
|
|
47
|
+
throw new TypeError("Cannot call a class as a function");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function _construct(Parent, args, Class) {
|
|
51
|
+
if (_is_native_reflect_construct()) {
|
|
52
|
+
_construct = Reflect.construct;
|
|
53
|
+
} else {
|
|
54
|
+
_construct = function construct(Parent, args, Class) {
|
|
55
|
+
var a = [
|
|
56
|
+
null
|
|
57
|
+
];
|
|
58
|
+
a.push.apply(a, args);
|
|
59
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
60
|
+
var instance = new Constructor();
|
|
61
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
62
|
+
return instance;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return _construct.apply(null, arguments);
|
|
66
|
+
}
|
|
67
|
+
function _defineProperties(target, props) {
|
|
68
|
+
for(var i = 0; i < props.length; i++){
|
|
69
|
+
var descriptor = props[i];
|
|
70
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
71
|
+
descriptor.configurable = true;
|
|
72
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
73
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
77
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
78
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
79
|
+
return Constructor;
|
|
80
|
+
}
|
|
81
|
+
function _get_prototype_of(o) {
|
|
82
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
83
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
84
|
+
};
|
|
85
|
+
return _get_prototype_of(o);
|
|
86
|
+
}
|
|
87
|
+
function _inherits(subClass, superClass) {
|
|
88
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
89
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
90
|
+
}
|
|
91
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
92
|
+
constructor: {
|
|
93
|
+
value: subClass,
|
|
94
|
+
writable: true,
|
|
95
|
+
configurable: true
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
99
|
+
}
|
|
100
|
+
function _is_native_function(fn) {
|
|
101
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
102
|
+
}
|
|
39
103
|
function _iterable_to_array_limit(arr, i) {
|
|
40
104
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
41
105
|
if (_i == null) return;
|
|
@@ -63,9 +127,26 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
63
127
|
function _non_iterable_rest() {
|
|
64
128
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
129
|
}
|
|
130
|
+
function _possible_constructor_return(self1, call) {
|
|
131
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
132
|
+
return call;
|
|
133
|
+
}
|
|
134
|
+
return _assert_this_initialized(self1);
|
|
135
|
+
}
|
|
136
|
+
function _set_prototype_of(o, p) {
|
|
137
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
138
|
+
o.__proto__ = p;
|
|
139
|
+
return o;
|
|
140
|
+
};
|
|
141
|
+
return _set_prototype_of(o, p);
|
|
142
|
+
}
|
|
66
143
|
function _sliced_to_array(arr, i) {
|
|
67
144
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
68
145
|
}
|
|
146
|
+
function _type_of(obj) {
|
|
147
|
+
"@swc/helpers - typeof";
|
|
148
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
149
|
+
}
|
|
69
150
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
70
151
|
if (!o) return;
|
|
71
152
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -74,6 +155,56 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
74
155
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
75
156
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
76
157
|
}
|
|
158
|
+
function _wrap_native_super(Class) {
|
|
159
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
160
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
161
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
162
|
+
if (typeof Class !== "function") {
|
|
163
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
164
|
+
}
|
|
165
|
+
if (typeof _cache !== "undefined") {
|
|
166
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
167
|
+
_cache.set(Class, Wrapper);
|
|
168
|
+
}
|
|
169
|
+
function Wrapper() {
|
|
170
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
171
|
+
}
|
|
172
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
173
|
+
constructor: {
|
|
174
|
+
value: Wrapper,
|
|
175
|
+
enumerable: false,
|
|
176
|
+
writable: true,
|
|
177
|
+
configurable: true
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return _set_prototype_of(Wrapper, Class);
|
|
181
|
+
};
|
|
182
|
+
return _wrap_native_super(Class);
|
|
183
|
+
}
|
|
184
|
+
function _is_native_reflect_construct() {
|
|
185
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
186
|
+
if (Reflect.construct.sham) return false;
|
|
187
|
+
if (typeof Proxy === "function") return true;
|
|
188
|
+
try {
|
|
189
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
190
|
+
return true;
|
|
191
|
+
} catch (e) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function _create_super(Derived) {
|
|
196
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
197
|
+
return function _createSuperInternal() {
|
|
198
|
+
var Super = _get_prototype_of(Derived), result;
|
|
199
|
+
if (hasNativeReflectConstruct) {
|
|
200
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
201
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
202
|
+
} else {
|
|
203
|
+
result = Super.apply(this, arguments);
|
|
204
|
+
}
|
|
205
|
+
return _possible_constructor_return(this, result);
|
|
206
|
+
};
|
|
207
|
+
}
|
|
77
208
|
function _ts_generator(thisArg, body) {
|
|
78
209
|
var f, y, t, g, _ = {
|
|
79
210
|
label: 0,
|
|
@@ -229,15 +360,15 @@ function formatStatsMessages(json) {
|
|
|
229
360
|
}
|
|
230
361
|
// src/client/hmr/createSocketUrl.ts
|
|
231
362
|
var HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
232
|
-
function
|
|
363
|
+
function parseParams(resourceQuery) {
|
|
233
364
|
var searchParams = resourceQuery.substr(1).split("&");
|
|
234
|
-
var
|
|
365
|
+
var options2 = {};
|
|
235
366
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
236
367
|
try {
|
|
237
368
|
for(var _iterator = searchParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
238
369
|
var pair = _step.value;
|
|
239
370
|
var ary = pair.split("=");
|
|
240
|
-
|
|
371
|
+
options2[ary[0]] = decodeURIComponent(ary[1]);
|
|
241
372
|
}
|
|
242
373
|
} catch (err) {
|
|
243
374
|
_didIteratorError = true;
|
|
@@ -253,8 +384,12 @@ function createSocketUrl(resourceQuery) {
|
|
|
253
384
|
}
|
|
254
385
|
}
|
|
255
386
|
}
|
|
387
|
+
return options2;
|
|
388
|
+
}
|
|
389
|
+
function createSocketUrl() {
|
|
390
|
+
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
256
391
|
var currentLocation = self.location;
|
|
257
|
-
return getSocketUrl(
|
|
392
|
+
return getSocketUrl(options2, currentLocation);
|
|
258
393
|
}
|
|
259
394
|
function formatURL(param) {
|
|
260
395
|
var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
|
|
@@ -278,8 +413,109 @@ function getSocketUrl(urlParts, location) {
|
|
|
278
413
|
pathname: path || HMR_SOCK_PATH
|
|
279
414
|
});
|
|
280
415
|
}
|
|
416
|
+
// src/client/hmr/overlay.ts
|
|
417
|
+
function stripAnsi(content) {
|
|
418
|
+
var pattern = [
|
|
419
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
420
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
421
|
+
].join("|");
|
|
422
|
+
var regex = new RegExp(pattern, "g");
|
|
423
|
+
return content.replace(regex, "");
|
|
424
|
+
}
|
|
425
|
+
function linkedText(root, selector, text) {
|
|
426
|
+
var _loop = function() {
|
|
427
|
+
var file = match[0], index = match.index;
|
|
428
|
+
if (index != null) {
|
|
429
|
+
var frag2 = text.slice(curIndex, index);
|
|
430
|
+
el.appendChild(document.createTextNode(frag2));
|
|
431
|
+
var link = document.createElement("a");
|
|
432
|
+
link.textContent = file;
|
|
433
|
+
link.className = "file-link";
|
|
434
|
+
link.onclick = function() {
|
|
435
|
+
fetch("/__open-in-editor?file=".concat(encodeURIComponent(file)));
|
|
436
|
+
};
|
|
437
|
+
el.appendChild(link);
|
|
438
|
+
curIndex += frag2.length + file.length;
|
|
439
|
+
}
|
|
440
|
+
match = fileRegex.exec(text);
|
|
441
|
+
};
|
|
442
|
+
var el = root.querySelector(selector);
|
|
443
|
+
var fileRegex = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
|
444
|
+
var curIndex = 0;
|
|
445
|
+
var match = fileRegex.exec(text);
|
|
446
|
+
while(match !== null)_loop();
|
|
447
|
+
var frag = text.slice(curIndex);
|
|
448
|
+
el.appendChild(document.createTextNode(frag));
|
|
449
|
+
}
|
|
450
|
+
var overlayTemplate = '\n<style>\n.root {\n position: fixed;\n z-index: 9999;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow-y: scroll;\n margin: 0;\n background: rgba(0, 0, 0, 0.66);\n cursor: pointer;\n}\n\n.container {\n font-family: Menlo, Consolas, monospace;\n line-height: 1.6;\n width: 800px;\n max-width: 85%;\n color: #d8d8d8;\n margin: 32px auto;\n padding: 32px 40px 42px;\n position: relative;\n background: #181818;\n border-radius: 24px;\n box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);\n overflow: hidden;\n direction: ltr;\n text-align: left;\n box-sizing: border-box;\n cursor: default;\n}\n\n.title {\n margin: 0 0 20px;\n padding-bottom: 12px;\n font-size: 17px;\n font-weight: 600;\n color: #fc5e5e;\n border-bottom: 2px solid rgba(252, 94, 94, 0.7);\n}\n\n.content {\n margin: 0;\n font-size: 14px;\n font-family: inherit;\n overflow-x: scroll;\n scrollbar-width: none;\n color: #b8b8b8;\n}\n.content::-webkit-scrollbar {\n display: none;\n}\n\n.file-link {\n cursor: pointer;\n color: #27caca;\n text-decoration: underline;\n\n &:hover {\n opacity: 0.8;\n }\n &:active {\n opacity: 0.6;\n }\n}\n\n.close {\n position: absolute;\n top: 27px;\n right: 32px;\n width: 32px;\n height: 32px;\n cursor: pointer;\n}\n.close:hover {\n opacity: 0.8;\n}\n.close:active {\n opacity: 0.6;\n}\n.close:before,\n.close:after {\n position: absolute;\n left: 16px;\n top: 8px;\n content: \' \';\n height: 18px;\n width: 2px;\n border-radius: 4px;\n background-color: #b8b8b8;\n}\n.close:before {\n transform: rotate(45deg);\n}\n.close:after {\n transform: rotate(-45deg);\n}\n</style>\n\n<div class="root">\n <div class="container">\n <div class="close"></div>\n <p class="title">Compilation failed</p>\n <pre class="content"></pre>\n </div>\n</div>\n';
|
|
451
|
+
var _globalThis_HTMLElement = globalThis.HTMLElement, HTMLElement = _globalThis_HTMLElement === void 0 ? function HTMLElement() {
|
|
452
|
+
"use strict";
|
|
453
|
+
_class_call_check(this, HTMLElement);
|
|
454
|
+
} : _globalThis_HTMLElement, customElements = globalThis.customElements;
|
|
455
|
+
var ErrorOverlay = /*#__PURE__*/ function(HTMLElement) {
|
|
456
|
+
"use strict";
|
|
457
|
+
_inherits(ErrorOverlay, HTMLElement);
|
|
458
|
+
var _super = _create_super(ErrorOverlay);
|
|
459
|
+
function ErrorOverlay(message) {
|
|
460
|
+
_class_call_check(this, ErrorOverlay);
|
|
461
|
+
var _this;
|
|
462
|
+
_this = _super.call(this);
|
|
463
|
+
if (!_this.attachShadow) {
|
|
464
|
+
console.warn("The current browser version does not support displaying rsbuild overlay");
|
|
465
|
+
return _possible_constructor_return(_this);
|
|
466
|
+
}
|
|
467
|
+
var root = _this.attachShadow({
|
|
468
|
+
mode: "open"
|
|
469
|
+
});
|
|
470
|
+
root.innerHTML = overlayTemplate;
|
|
471
|
+
linkedText(root, ".content", stripAnsi(message.join("/n")).trim());
|
|
472
|
+
root.querySelector(".close").addEventListener("click", function() {
|
|
473
|
+
_this.close();
|
|
474
|
+
});
|
|
475
|
+
_this.addEventListener("click", function() {
|
|
476
|
+
_this.close();
|
|
477
|
+
});
|
|
478
|
+
root.querySelector(".container").addEventListener("click", function(e) {
|
|
479
|
+
e.stopPropagation();
|
|
480
|
+
});
|
|
481
|
+
return _this;
|
|
482
|
+
}
|
|
483
|
+
_create_class(ErrorOverlay, [
|
|
484
|
+
{
|
|
485
|
+
key: "close",
|
|
486
|
+
value: function close() {
|
|
487
|
+
var _this_parentNode;
|
|
488
|
+
(_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.removeChild(this);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
]);
|
|
492
|
+
return ErrorOverlay;
|
|
493
|
+
}(_wrap_native_super(HTMLElement));
|
|
494
|
+
var overlayId = "rsbuild-error-overlay";
|
|
495
|
+
if (customElements && !customElements.get(overlayId)) {
|
|
496
|
+
customElements.define(overlayId, ErrorOverlay);
|
|
497
|
+
}
|
|
498
|
+
var documentAvailable = typeof document !== "undefined";
|
|
499
|
+
function createOverlay(err) {
|
|
500
|
+
if (!documentAvailable) {
|
|
501
|
+
console.info("Failed to display Rsbuild overlay since document is not available, considering turning off the `dev.client.overlay` option.");
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
clearOverlay();
|
|
505
|
+
document.body.appendChild(new ErrorOverlay(err));
|
|
506
|
+
}
|
|
507
|
+
function clearOverlay() {
|
|
508
|
+
if (!documentAvailable) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
document.querySelectorAll(overlayId).forEach(function(n) {
|
|
512
|
+
return n.close();
|
|
513
|
+
});
|
|
514
|
+
}
|
|
281
515
|
// src/client/hmr/index.ts
|
|
282
|
-
var
|
|
516
|
+
var options = parseParams(__resourceQuery);
|
|
517
|
+
var socketUrl = createSocketUrl(options);
|
|
518
|
+
var enableOverlay = options.overlay === "true";
|
|
283
519
|
var isFirstCompilation = true;
|
|
284
520
|
var mostRecentCompilationHash = null;
|
|
285
521
|
var hasCompileErrors = false;
|
|
@@ -354,6 +590,9 @@ function handleErrors(errors) {
|
|
|
354
590
|
}
|
|
355
591
|
}
|
|
356
592
|
}
|
|
593
|
+
if (enableOverlay) {
|
|
594
|
+
createOverlay(formatted.errors);
|
|
595
|
+
}
|
|
357
596
|
}
|
|
358
597
|
function handleAvailableHash(hash) {
|
|
359
598
|
mostRecentCompilationHash = hash;
|
|
@@ -403,12 +642,16 @@ function onMessage(e) {
|
|
|
403
642
|
var message = JSON.parse(e.data);
|
|
404
643
|
switch(message.type){
|
|
405
644
|
case "hash":
|
|
645
|
+
if (enableOverlay) {
|
|
646
|
+
clearOverlay();
|
|
647
|
+
}
|
|
406
648
|
handleAvailableHash(message.data);
|
|
407
649
|
break;
|
|
408
650
|
case "still-ok":
|
|
409
651
|
case "ok":
|
|
410
652
|
handleSuccess();
|
|
411
653
|
break;
|
|
654
|
+
case "static-changed":
|
|
412
655
|
case "content-changed":
|
|
413
656
|
window.location.reload();
|
|
414
657
|
break;
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_config = require("./config");
|
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_mergeConfig = require("./mergeConfig");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.5.
|
|
41
|
+
const version = "0.5.5";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_CSS_NAME,
|
|
@@ -98,6 +98,18 @@ function pluginModuleFederation() {
|
|
|
98
98
|
return {
|
|
99
99
|
name: "rsbuild:module-federation",
|
|
100
100
|
setup(api) {
|
|
101
|
+
api.modifyRsbuildConfig({
|
|
102
|
+
order: "post",
|
|
103
|
+
handler: (config) => {
|
|
104
|
+
if (config.moduleFederation?.options && config.performance?.chunkSplit?.strategy === "split-by-experience") {
|
|
105
|
+
config.performance.chunkSplit = {
|
|
106
|
+
...config.performance.chunkSplit,
|
|
107
|
+
strategy: "custom"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
101
113
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
102
114
|
const config = api.getNormalizedConfig();
|
|
103
115
|
if (!config.moduleFederation?.options || target !== "web") {
|
|
@@ -211,10 +211,7 @@ const pluginSplitChunks = () => ({
|
|
|
211
211
|
chunkSplit.forceSplitting
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
|
-
const override = chunkSplit.strategy === "custom" ?
|
|
215
|
-
// `chunkSplit.splitChunks` compat for Eden
|
|
216
|
-
chunkSplit.splitChunks ?? chunkSplit.override
|
|
217
|
-
) : chunkSplit.override;
|
|
214
|
+
const override = chunkSplit.strategy === "custom" ? chunkSplit.splitChunks ?? chunkSplit.override : chunkSplit.override;
|
|
218
215
|
const splitChunksOptions = await SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy || "split-by-experience"]({
|
|
219
216
|
defaultConfig,
|
|
220
217
|
override: override || {},
|
package/dist/provider/build.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var build_exports = {};
|
|
20
30
|
__export(build_exports, {
|
|
@@ -50,11 +60,13 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
|
|
|
50
60
|
isFirstCompile = false;
|
|
51
61
|
await p;
|
|
52
62
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
const { MultiStats: MultiStatsStor } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
64
|
+
(0, import_shared.onCompileDone)(
|
|
65
|
+
compiler,
|
|
66
|
+
onDone,
|
|
67
|
+
// @ts-expect-error type mismatch
|
|
68
|
+
MultiStatsStor
|
|
69
|
+
);
|
|
58
70
|
if (watch) {
|
|
59
71
|
compiler.watch({}, (err) => {
|
|
60
72
|
if (err) {
|
|
@@ -109,11 +109,13 @@ async function createCompiler({
|
|
|
109
109
|
isCompiling = false;
|
|
110
110
|
isFirstCompile = false;
|
|
111
111
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
const { MultiStats: MultiStatsStor } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
113
|
+
(0, import_shared.onCompileDone)(
|
|
114
|
+
compiler,
|
|
115
|
+
done,
|
|
116
|
+
// @ts-expect-error type mismatch
|
|
117
|
+
MultiStatsStor
|
|
118
|
+
);
|
|
117
119
|
await context.hooks.onAfterCreateCompiler.call({ compiler });
|
|
118
120
|
(0, import_shared.debug)("create compiler done");
|
|
119
121
|
return compiler;
|
|
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
44
44
|
const context = {
|
|
45
45
|
entry: (0, import_entry.getEntryObject)(config, "web"),
|
|
46
46
|
targets: config.output?.targets || [],
|
|
47
|
-
version: "0.5.
|
|
47
|
+
version: "0.5.5",
|
|
48
48
|
rootPath,
|
|
49
49
|
distPath,
|
|
50
50
|
cachePath,
|
|
@@ -79,7 +79,11 @@ const rspackProvider = async ({
|
|
|
79
79
|
const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
|
|
80
80
|
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
|
|
81
81
|
await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
|
|
82
|
-
const server = await createDevServer(
|
|
82
|
+
const server = await createDevServer(
|
|
83
|
+
{ context, pluginManager, rsbuildOptions },
|
|
84
|
+
createDevMiddleware,
|
|
85
|
+
options
|
|
86
|
+
);
|
|
83
87
|
return server.listen();
|
|
84
88
|
},
|
|
85
89
|
async preview(options) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { type Stats, type MultiStats } from '@rsbuild/shared';
|
|
1
|
+
import { type Stats, type MultiStats, type StatsError } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildPlugin } from '../types';
|
|
3
3
|
import { type Plugins } from '@rsbuild/shared';
|
|
4
|
+
import type { StatsCompilation } from '@rspack/core';
|
|
4
5
|
export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
|
|
5
6
|
export declare const rspackMinVersion = "0.5.0";
|
|
6
7
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
|
7
8
|
export declare const getCompiledPath: (packageName: string) => string;
|
|
8
9
|
export declare const BUILTIN_LOADER = "builtin:";
|
|
10
|
+
export declare const getAllStatsErrors: (statsData: StatsCompilation) => StatsError[] | undefined;
|
|
11
|
+
export declare const getAllStatsWarnings: (statsData: StatsCompilation) => StatsError[] | undefined;
|
|
9
12
|
export declare function formatStats(stats: Stats | MultiStats): {
|
|
10
13
|
message: string;
|
|
11
14
|
level: string;
|
package/dist/provider/shared.js
CHANGED
|
@@ -31,6 +31,8 @@ __export(shared_exports, {
|
|
|
31
31
|
BUILTIN_LOADER: () => BUILTIN_LOADER,
|
|
32
32
|
applyDefaultPlugins: () => applyDefaultPlugins,
|
|
33
33
|
formatStats: () => formatStats,
|
|
34
|
+
getAllStatsErrors: () => getAllStatsErrors,
|
|
35
|
+
getAllStatsWarnings: () => getAllStatsWarnings,
|
|
34
36
|
getCompiledPath: () => getCompiledPath,
|
|
35
37
|
isSatisfyRspackVersion: () => isSatisfyRspackVersion,
|
|
36
38
|
rspackMinVersion: () => rspackMinVersion
|
|
@@ -187,11 +189,33 @@ function formatErrorMessage(errors) {
|
|
|
187
189
|
${tip}
|
|
188
190
|
${text}`;
|
|
189
191
|
}
|
|
192
|
+
const getAllStatsErrors = (statsData) => {
|
|
193
|
+
if (statsData.errorsCount && statsData.errors?.length === 0) {
|
|
194
|
+
return statsData.children?.reduce(
|
|
195
|
+
(errors, curr) => errors.concat(curr.errors || []),
|
|
196
|
+
[]
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return statsData.errors;
|
|
200
|
+
};
|
|
201
|
+
const getAllStatsWarnings = (statsData) => {
|
|
202
|
+
if (statsData.warningsCount && statsData.warnings?.length === 0) {
|
|
203
|
+
return statsData.children?.reduce(
|
|
204
|
+
(warnings, curr) => warnings.concat(curr.warnings || []),
|
|
205
|
+
[]
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return statsData.warnings;
|
|
209
|
+
};
|
|
190
210
|
function formatStats(stats) {
|
|
191
211
|
const statsData = stats.toJson({
|
|
192
|
-
preset: "errors-warnings"
|
|
212
|
+
preset: "errors-warnings",
|
|
213
|
+
children: true
|
|
214
|
+
});
|
|
215
|
+
const { errors, warnings } = (0, import_formatStats.formatStatsMessages)({
|
|
216
|
+
errors: getAllStatsErrors(statsData),
|
|
217
|
+
warnings: getAllStatsWarnings(statsData)
|
|
193
218
|
});
|
|
194
|
-
const { errors, warnings } = (0, import_formatStats.formatStatsMessages)(statsData);
|
|
195
219
|
if (errors.length) {
|
|
196
220
|
return {
|
|
197
221
|
message: formatErrorMessage(errors),
|
|
@@ -213,6 +237,8 @@ function formatStats(stats) {
|
|
|
213
237
|
BUILTIN_LOADER,
|
|
214
238
|
applyDefaultPlugins,
|
|
215
239
|
formatStats,
|
|
240
|
+
getAllStatsErrors,
|
|
241
|
+
getAllStatsWarnings,
|
|
216
242
|
getCompiledPath,
|
|
217
243
|
isSatisfyRspackVersion,
|
|
218
244
|
rspackMinVersion
|
|
@@ -39,12 +39,11 @@ module.exports = __toCommonJS(compilerDevMiddleware_exports);
|
|
|
39
39
|
var import_socketServer = require("./socketServer");
|
|
40
40
|
const noop = () => {
|
|
41
41
|
};
|
|
42
|
-
function getHMRClientPath(client) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const clientEntry = `${require.resolve("@rsbuild/core/client/hmr")}?${host}${path}${port}${protocol}`;
|
|
42
|
+
function getHMRClientPath(client = {}) {
|
|
43
|
+
const params = Object.entries(client).reduce((query, [key, value]) => {
|
|
44
|
+
return value ? `${query}&${key}=${value}` : `${query}`;
|
|
45
|
+
}, "");
|
|
46
|
+
const clientEntry = `${require.resolve("@rsbuild/core/client/hmr")}?${params}`;
|
|
48
47
|
return clientEntry;
|
|
49
48
|
}
|
|
50
49
|
class CompilerDevMiddleware {
|
package/dist/server/helper.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
|
|
|
58
58
|
port?: string | undefined;
|
|
59
59
|
host?: string | undefined;
|
|
60
60
|
protocol?: "ws" | "wss" | undefined;
|
|
61
|
+
overlay?: boolean | undefined;
|
|
61
62
|
} | undefined;
|
|
62
63
|
setupMiddlewares?: ((middlewares: {
|
|
63
64
|
unshift: (...handlers: import("@rsbuild/shared").RequestHandler[]) => void;
|
|
@@ -38,6 +38,7 @@ __export(socketServer_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(socketServer_exports);
|
|
39
39
|
var import_ws = __toESM(require("../../compiled/ws"));
|
|
40
40
|
var import_shared = require("@rsbuild/shared");
|
|
41
|
+
var import_shared2 = require("../provider/shared");
|
|
41
42
|
class SocketServer {
|
|
42
43
|
constructor(options) {
|
|
43
44
|
__publicField(this, "wsServer");
|
|
@@ -136,8 +137,11 @@ class SocketServer {
|
|
|
136
137
|
hash: true,
|
|
137
138
|
assets: true,
|
|
138
139
|
warnings: true,
|
|
140
|
+
warningsCount: true,
|
|
139
141
|
errors: true,
|
|
140
|
-
|
|
142
|
+
errorsCount: true,
|
|
143
|
+
errorDetails: false,
|
|
144
|
+
children: true
|
|
141
145
|
};
|
|
142
146
|
return curStats.toJson(defaultStats);
|
|
143
147
|
}
|
|
@@ -147,16 +151,16 @@ class SocketServer {
|
|
|
147
151
|
if (!stats) {
|
|
148
152
|
return null;
|
|
149
153
|
}
|
|
150
|
-
const shouldEmit = !force && stats &&
|
|
154
|
+
const shouldEmit = !force && stats && !stats.errorsCount && stats.assets && stats.assets.every((asset) => !asset.emitted);
|
|
151
155
|
if (shouldEmit) {
|
|
152
156
|
return this.sockWrite("still-ok");
|
|
153
157
|
}
|
|
154
158
|
this.sockWrite("hash", stats.hash);
|
|
155
|
-
if (stats.
|
|
156
|
-
return this.sockWrite("errors",
|
|
159
|
+
if (stats.errorsCount) {
|
|
160
|
+
return this.sockWrite("errors", (0, import_shared2.getAllStatsErrors)(stats));
|
|
157
161
|
}
|
|
158
|
-
if (stats.
|
|
159
|
-
return this.sockWrite("warnings",
|
|
162
|
+
if (stats.warningsCount) {
|
|
163
|
+
return this.sockWrite("warnings", (0, import_shared2.getAllStatsWarnings)(stats));
|
|
160
164
|
}
|
|
161
165
|
return this.sockWrite("ok");
|
|
162
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"types.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@rspack/core": "0.5.
|
|
55
|
+
"@rspack/core": "0.5.9-canary-8778e17-20240328104834",
|
|
56
56
|
"@swc/helpers": "0.5.3",
|
|
57
57
|
"core-js": "~3.36.0",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
|
|
59
59
|
"postcss": "^8.4.38",
|
|
60
|
-
"@rsbuild/shared": "0.5.
|
|
60
|
+
"@rsbuild/shared": "0.5.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|