@rsbuild/core 1.2.4 → 1.2.6
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/css-loader/index.js +20 -18
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/style-loader/index.js +10 -10
- package/dist/index.cjs +83 -52
- package/dist/index.js +83 -52
- package/dist-types/cli/commands.d.ts +3 -0
- package/dist-types/config.d.ts +9 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/types/config.d.ts +11 -13
- package/package.json +3 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
9605: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const loader = __nccwpck_require__(
|
|
5
|
+
const loader = __nccwpck_require__(7999);
|
|
6
6
|
module.exports = loader.default;
|
|
7
7
|
module.exports.defaultGetLocalIdent =
|
|
8
|
-
__nccwpck_require__(
|
|
8
|
+
__nccwpck_require__(2666).defaultGetLocalIdent;
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
7999: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
11
11
|
"use strict";
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports["default"] = loader;
|
|
14
14
|
var _postcss = _interopRequireDefault(__nccwpck_require__(9409));
|
|
15
|
-
var _plugins = __nccwpck_require__(
|
|
16
|
-
var _utils = __nccwpck_require__(
|
|
15
|
+
var _plugins = __nccwpck_require__(3604);
|
|
16
|
+
var _utils = __nccwpck_require__(2666);
|
|
17
17
|
function _interopRequireDefault(obj) {
|
|
18
18
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
19
19
|
}
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
callback(null, `${importCode}${moduleCode}${exportCode}`);
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
|
-
|
|
239
|
+
3604: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
240
240
|
"use strict";
|
|
241
241
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
242
242
|
Object.defineProperty(exports, "icssParser", {
|
|
@@ -258,20 +258,22 @@
|
|
|
258
258
|
},
|
|
259
259
|
});
|
|
260
260
|
var _postcssImportParser = _interopRequireDefault(
|
|
261
|
-
__nccwpck_require__(
|
|
261
|
+
__nccwpck_require__(1663),
|
|
262
262
|
);
|
|
263
|
-
var _postcssIcssParser = _interopRequireDefault(
|
|
264
|
-
|
|
263
|
+
var _postcssIcssParser = _interopRequireDefault(
|
|
264
|
+
__nccwpck_require__(6178),
|
|
265
|
+
);
|
|
266
|
+
var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(7973));
|
|
265
267
|
function _interopRequireDefault(obj) {
|
|
266
268
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
267
269
|
}
|
|
268
270
|
},
|
|
269
|
-
|
|
271
|
+
6178: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
270
272
|
"use strict";
|
|
271
273
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
272
274
|
exports["default"] = void 0;
|
|
273
275
|
var _icssUtils = __nccwpck_require__(7937);
|
|
274
|
-
var _utils = __nccwpck_require__(
|
|
276
|
+
var _utils = __nccwpck_require__(2666);
|
|
275
277
|
const plugin = (options = {}) => ({
|
|
276
278
|
postcssPlugin: "postcss-icss-parser",
|
|
277
279
|
async OnceExit(root) {
|
|
@@ -370,14 +372,14 @@
|
|
|
370
372
|
plugin.postcss = true;
|
|
371
373
|
var _default = (exports["default"] = plugin);
|
|
372
374
|
},
|
|
373
|
-
|
|
375
|
+
1663: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
374
376
|
"use strict";
|
|
375
377
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
376
378
|
exports["default"] = void 0;
|
|
377
379
|
var _postcssValueParser = _interopRequireDefault(
|
|
378
380
|
__nccwpck_require__(2948),
|
|
379
381
|
);
|
|
380
|
-
var _utils = __nccwpck_require__(
|
|
382
|
+
var _utils = __nccwpck_require__(2666);
|
|
381
383
|
function _interopRequireDefault(obj) {
|
|
382
384
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
383
385
|
}
|
|
@@ -682,14 +684,14 @@
|
|
|
682
684
|
plugin.postcss = true;
|
|
683
685
|
var _default = (exports["default"] = plugin);
|
|
684
686
|
},
|
|
685
|
-
|
|
687
|
+
7973: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
686
688
|
"use strict";
|
|
687
689
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
688
690
|
exports["default"] = void 0;
|
|
689
691
|
var _postcssValueParser = _interopRequireDefault(
|
|
690
692
|
__nccwpck_require__(2948),
|
|
691
693
|
);
|
|
692
|
-
var _utils = __nccwpck_require__(
|
|
694
|
+
var _utils = __nccwpck_require__(2666);
|
|
693
695
|
function _interopRequireDefault(obj) {
|
|
694
696
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
695
697
|
}
|
|
@@ -1032,7 +1034,7 @@
|
|
|
1032
1034
|
plugin.postcss = true;
|
|
1033
1035
|
var _default = (exports["default"] = plugin);
|
|
1034
1036
|
},
|
|
1035
|
-
|
|
1037
|
+
2666: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1036
1038
|
"use strict";
|
|
1037
1039
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1038
1040
|
exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
|
|
@@ -7982,6 +7984,6 @@
|
|
|
7982
7984
|
}
|
|
7983
7985
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
7984
7986
|
__nccwpck_require__.ab = __dirname + "/";
|
|
7985
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
7987
|
+
var __webpack_exports__ = __nccwpck_require__(9605);
|
|
7986
7988
|
module.exports = __webpack_exports__;
|
|
7987
7989
|
})();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = __nccwpck_require__(
|
|
4
|
+
15: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
module.exports = __nccwpck_require__(49)["default"];
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
49: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8
8
|
var __webpack_unused_export__;
|
|
9
9
|
__webpack_unused_export__ = { value: true };
|
|
10
10
|
exports["default"] = loader;
|
|
11
11
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(628);
|
|
13
13
|
function _interopRequireDefault(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
15
15
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
callback(null, result.css, map, { ast });
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
|
|
182
|
+
628: (module, exports, __nccwpck_require__) => {
|
|
183
183
|
module = __nccwpck_require__.nmd(module);
|
|
184
184
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
185
|
exports.exec = exec;
|
|
@@ -716,6 +716,6 @@
|
|
|
716
716
|
})();
|
|
717
717
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
718
718
|
__nccwpck_require__.ab = __dirname + "/";
|
|
719
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
719
|
+
var __webpack_exports__ = __nccwpck_require__(15);
|
|
720
720
|
module.exports = __webpack_exports__;
|
|
721
721
|
})();
|
|
@@ -4449,14 +4449,14 @@
|
|
|
4449
4449
|
return a.start - b.start;
|
|
4450
4450
|
}
|
|
4451
4451
|
},
|
|
4452
|
-
|
|
4452
|
+
2461: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4453
4453
|
"use strict";
|
|
4454
|
-
const middleware = __nccwpck_require__(
|
|
4455
|
-
const getFilenameFromUrl = __nccwpck_require__(
|
|
4456
|
-
const setupHooks = __nccwpck_require__(
|
|
4457
|
-
const setupWriteToDisk = __nccwpck_require__(
|
|
4458
|
-
const setupOutputFileSystem = __nccwpck_require__(
|
|
4459
|
-
const ready = __nccwpck_require__(
|
|
4454
|
+
const middleware = __nccwpck_require__(5121);
|
|
4455
|
+
const getFilenameFromUrl = __nccwpck_require__(8537);
|
|
4456
|
+
const setupHooks = __nccwpck_require__(3972);
|
|
4457
|
+
const setupWriteToDisk = __nccwpck_require__(527);
|
|
4458
|
+
const setupOutputFileSystem = __nccwpck_require__(7380);
|
|
4459
|
+
const ready = __nccwpck_require__(9296);
|
|
4460
4460
|
const noop = () => {};
|
|
4461
4461
|
function wdm(compiler, options = {}) {
|
|
4462
4462
|
const context = {
|
|
@@ -4511,14 +4511,14 @@
|
|
|
4511
4511
|
}
|
|
4512
4512
|
module.exports = wdm;
|
|
4513
4513
|
},
|
|
4514
|
-
|
|
4514
|
+
5121: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4515
4515
|
"use strict";
|
|
4516
4516
|
const mrmime = __nccwpck_require__(8311);
|
|
4517
4517
|
const onFinishedStream = __nccwpck_require__(21);
|
|
4518
|
-
const getFilenameFromUrl = __nccwpck_require__(
|
|
4519
|
-
const ready = __nccwpck_require__(
|
|
4520
|
-
const parseTokenList = __nccwpck_require__(
|
|
4521
|
-
const memorize = __nccwpck_require__(
|
|
4518
|
+
const getFilenameFromUrl = __nccwpck_require__(8537);
|
|
4519
|
+
const ready = __nccwpck_require__(9296);
|
|
4520
|
+
const parseTokenList = __nccwpck_require__(5919);
|
|
4521
|
+
const memorize = __nccwpck_require__(2297);
|
|
4522
4522
|
async function getEtag(stat) {
|
|
4523
4523
|
const mtime = stat.mtime.getTime().toString(16);
|
|
4524
4524
|
const size = stat.size.toString(16);
|
|
@@ -4610,7 +4610,7 @@
|
|
|
4610
4610
|
return;
|
|
4611
4611
|
}
|
|
4612
4612
|
function sendError(status, options) {
|
|
4613
|
-
const escapeHtml = __nccwpck_require__(
|
|
4613
|
+
const escapeHtml = __nccwpck_require__(3557);
|
|
4614
4614
|
const content = statuses[status] || String(status);
|
|
4615
4615
|
const document = Buffer.from(
|
|
4616
4616
|
`<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>Error</title>\n</head>\n<body>\n<pre>${escapeHtml(content)}</pre>\n</body>\n</html>`,
|
|
@@ -4915,7 +4915,7 @@
|
|
|
4915
4915
|
}
|
|
4916
4916
|
module.exports = wrapper;
|
|
4917
4917
|
},
|
|
4918
|
-
|
|
4918
|
+
3557: (module) => {
|
|
4919
4919
|
"use strict";
|
|
4920
4920
|
const matchHtmlRegExp = /["'&<>]/;
|
|
4921
4921
|
function escapeHtml(string) {
|
|
@@ -4960,13 +4960,13 @@
|
|
|
4960
4960
|
}
|
|
4961
4961
|
module.exports = escapeHtml;
|
|
4962
4962
|
},
|
|
4963
|
-
|
|
4963
|
+
8537: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4964
4964
|
"use strict";
|
|
4965
4965
|
const path = __nccwpck_require__(6928);
|
|
4966
4966
|
const { parse } = __nccwpck_require__(7016);
|
|
4967
4967
|
const querystring = __nccwpck_require__(3480);
|
|
4968
|
-
const getPaths = __nccwpck_require__(
|
|
4969
|
-
const memorize = __nccwpck_require__(
|
|
4968
|
+
const getPaths = __nccwpck_require__(9411);
|
|
4969
|
+
const memorize = __nccwpck_require__(2297);
|
|
4970
4970
|
const memoizedParse = memorize(parse, undefined, (value) => {
|
|
4971
4971
|
if (value.pathname) {
|
|
4972
4972
|
value.pathname = decode(value.pathname);
|
|
@@ -5049,7 +5049,7 @@
|
|
|
5049
5049
|
}
|
|
5050
5050
|
module.exports = getFilenameFromUrl;
|
|
5051
5051
|
},
|
|
5052
|
-
|
|
5052
|
+
9411: (module) => {
|
|
5053
5053
|
"use strict";
|
|
5054
5054
|
function getPaths(context) {
|
|
5055
5055
|
const { stats, options } = context;
|
|
@@ -5070,7 +5070,7 @@
|
|
|
5070
5070
|
}
|
|
5071
5071
|
module.exports = getPaths;
|
|
5072
5072
|
},
|
|
5073
|
-
|
|
5073
|
+
2297: (module) => {
|
|
5074
5074
|
"use strict";
|
|
5075
5075
|
const cacheStore = new WeakMap();
|
|
5076
5076
|
function memorize(fn, { cache = new Map() } = {}, callback) {
|
|
@@ -5092,7 +5092,7 @@
|
|
|
5092
5092
|
}
|
|
5093
5093
|
module.exports = memorize;
|
|
5094
5094
|
},
|
|
5095
|
-
|
|
5095
|
+
5919: (module) => {
|
|
5096
5096
|
"use strict";
|
|
5097
5097
|
function parseTokenList(str) {
|
|
5098
5098
|
let end = 0;
|
|
@@ -5125,7 +5125,7 @@
|
|
|
5125
5125
|
}
|
|
5126
5126
|
module.exports = parseTokenList;
|
|
5127
5127
|
},
|
|
5128
|
-
|
|
5128
|
+
9296: (module) => {
|
|
5129
5129
|
"use strict";
|
|
5130
5130
|
function ready(context, callback, req) {
|
|
5131
5131
|
if (context.state) {
|
|
@@ -5140,7 +5140,7 @@
|
|
|
5140
5140
|
}
|
|
5141
5141
|
module.exports = ready;
|
|
5142
5142
|
},
|
|
5143
|
-
|
|
5143
|
+
3972: (module) => {
|
|
5144
5144
|
"use strict";
|
|
5145
5145
|
function setupHooks(context) {
|
|
5146
5146
|
function invalid() {
|
|
@@ -5172,7 +5172,7 @@
|
|
|
5172
5172
|
}
|
|
5173
5173
|
module.exports = setupHooks;
|
|
5174
5174
|
},
|
|
5175
|
-
|
|
5175
|
+
7380: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5176
5176
|
"use strict";
|
|
5177
5177
|
const memfs = __nccwpck_require__(5590);
|
|
5178
5178
|
function setupOutputFileSystem(context) {
|
|
@@ -5199,7 +5199,7 @@
|
|
|
5199
5199
|
}
|
|
5200
5200
|
module.exports = setupOutputFileSystem;
|
|
5201
5201
|
},
|
|
5202
|
-
|
|
5202
|
+
527: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5203
5203
|
"use strict";
|
|
5204
5204
|
const fs = __nccwpck_require__(9896);
|
|
5205
5205
|
const path = __nccwpck_require__(6928);
|
|
@@ -6185,6 +6185,6 @@
|
|
|
6185
6185
|
}
|
|
6186
6186
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
6187
6187
|
__nccwpck_require__.ab = __dirname + "/";
|
|
6188
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
6188
|
+
var __webpack_exports__ = __nccwpck_require__(2461);
|
|
6189
6189
|
module.exports = __webpack_exports__;
|
|
6190
6190
|
})();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
const loader = __nccwpck_require__(
|
|
4
|
+
620: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
const loader = __nccwpck_require__(314);
|
|
6
6
|
module.exports = loader.default;
|
|
7
7
|
},
|
|
8
|
-
|
|
8
|
+
314: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
13
|
-
var _options = _interopRequireDefault(__nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(555);
|
|
13
|
+
var _options = _interopRequireDefault(__nccwpck_require__(199));
|
|
14
14
|
function _interopRequireDefault(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
16
16
|
}
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
};
|
|
105
105
|
var _default = (exports["default"] = loader);
|
|
106
106
|
},
|
|
107
|
-
|
|
107
|
+
589: (module) => {
|
|
108
108
|
function isEqualLocals(a, b, isNamedExport) {
|
|
109
109
|
if ((!a && b) || (a && !b)) {
|
|
110
110
|
return false;
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
module.exports = isEqualLocals;
|
|
132
132
|
},
|
|
133
|
-
|
|
133
|
+
555: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
134
134
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
135
|
exports.getExportLazyStyleCode = getExportLazyStyleCode;
|
|
136
136
|
exports.getExportStyleCode = getExportStyleCode;
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
exports.getdomAPI = getdomAPI;
|
|
152
152
|
exports.stringifyRequest = stringifyRequest;
|
|
153
153
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
154
|
-
var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(
|
|
154
|
+
var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(589));
|
|
155
155
|
function _interopRequireDefault(obj) {
|
|
156
156
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
157
157
|
}
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
928: (module) => {
|
|
395
395
|
module.exports = require("path");
|
|
396
396
|
},
|
|
397
|
-
|
|
397
|
+
199: (module) => {
|
|
398
398
|
module.exports = JSON.parse(
|
|
399
399
|
'{"title":"Style Loader options","type":"object","properties":{"injectType":{"description":"Allows to setup how styles will be injected into DOM.","link":"https://github.com/webpack-contrib/style-loader#injecttype","enum":["styleTag","singletonStyleTag","autoStyleTag","lazyStyleTag","lazySingletonStyleTag","lazyAutoStyleTag","linkTag"]},"attributes":{"description":"Adds custom attributes to tag.","link":"https://github.com/webpack-contrib/style-loader#attributes","type":"object"},"insert":{"description":"Inserts `<style>`/`<link>` at the given position.","link":"https://github.com/webpack-contrib/style-loader#insert","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"base":{"description":"Sets module ID base for DLLPlugin.","link":"https://github.com/webpack-contrib/style-loader#base","type":"number"},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"styleTagTransform":{"description":"Transform tag and css when insert \'style\' tag into the DOM","link":"https://github.com/webpack-contrib/style-loader#styleTagTransform","anyOf":[{"type":"string"},{"instanceof":"Function"}]}},"additionalProperties":false}',
|
|
400
400
|
);
|
|
@@ -422,6 +422,6 @@
|
|
|
422
422
|
}
|
|
423
423
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
424
424
|
__nccwpck_require__.ab = __dirname + "/";
|
|
425
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
425
|
+
var __webpack_exports__ = __nccwpck_require__(620);
|
|
426
426
|
module.exports = __webpack_exports__;
|
|
427
427
|
})();
|
package/dist/index.cjs
CHANGED
|
@@ -918,36 +918,42 @@ var __webpack_exports__ = {};
|
|
|
918
918
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
919
919
|
cliOptions && (commonOpts = cliOptions);
|
|
920
920
|
try {
|
|
921
|
-
var _config_server, _config_dev
|
|
921
|
+
var _config_server, _config_dev;
|
|
922
922
|
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
|
|
923
923
|
cwd: getEnvDir(root, commonOpts.envDir),
|
|
924
924
|
mode: commonOpts.envMode
|
|
925
925
|
}), { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
926
926
|
cwd: root,
|
|
927
927
|
path: commonOpts.config,
|
|
928
|
-
envMode: commonOpts.envMode
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
let files = [
|
|
932
|
-
...envs.filePaths
|
|
933
|
-
];
|
|
934
|
-
if (configFilePath && files.push(configFilePath), null === (_config_dev1 = config.dev) || void 0 === _config_dev1 ? void 0 : _config_dev1.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
935
|
-
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
936
|
-
let paths = castArray(watchFilesConfig.paths);
|
|
937
|
-
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
938
|
-
}
|
|
939
|
-
watchFilesForRestart(files, root, isBuildWatch);
|
|
940
|
-
}
|
|
928
|
+
envMode: commonOpts.envMode,
|
|
929
|
+
loader: commonOpts.configLoader
|
|
930
|
+
});
|
|
941
931
|
config.source ||= {}, config.source.define = {
|
|
942
932
|
...envs.publicVars,
|
|
943
933
|
...config.source.define
|
|
944
|
-
}, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
934
|
+
}, commonOpts.base && (config.server ||= {}, config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
945
935
|
let rsbuild = await createRsbuild({
|
|
946
936
|
cwd: root,
|
|
947
937
|
rsbuildConfig: config,
|
|
948
938
|
environment: commonOpts.environment
|
|
949
939
|
});
|
|
950
|
-
return rsbuild.
|
|
940
|
+
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
941
|
+
let command = process.argv[2];
|
|
942
|
+
if ('dev' === command || isBuildWatch) {
|
|
943
|
+
var _config_dev;
|
|
944
|
+
let files = [
|
|
945
|
+
...envs.filePaths
|
|
946
|
+
];
|
|
947
|
+
configFilePath && files.push(configFilePath);
|
|
948
|
+
let config = rsbuild.getNormalizedConfig();
|
|
949
|
+
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
950
|
+
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
951
|
+
let paths = castArray(watchFilesConfig.paths);
|
|
952
|
+
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
953
|
+
}
|
|
954
|
+
watchFilesForRestart(files, root, isBuildWatch);
|
|
955
|
+
}
|
|
956
|
+
}), rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup), rsbuild;
|
|
951
957
|
} catch (err) {
|
|
952
958
|
if (isRestart) rslog_index_js_namespaceObject.logger.error(err);
|
|
953
959
|
else throw err;
|
|
@@ -1103,7 +1109,6 @@ var __webpack_exports__ = {};
|
|
|
1103
1109
|
}
|
|
1104
1110
|
}), getDefaultPerformanceConfig = ()=>({
|
|
1105
1111
|
profile: !1,
|
|
1106
|
-
buildCache: !0,
|
|
1107
1112
|
printFileSize: !0,
|
|
1108
1113
|
removeConsole: !1,
|
|
1109
1114
|
removeMomentLocale: !1,
|
|
@@ -1236,7 +1241,7 @@ var __webpack_exports__ = {};
|
|
|
1236
1241
|
});
|
|
1237
1242
|
watcher.on('add', callback), watcher.on('change', callback), watcher.on('unlink', callback);
|
|
1238
1243
|
}
|
|
1239
|
-
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } = {}) {
|
|
1244
|
+
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1240
1245
|
let configExport;
|
|
1241
1246
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1242
1247
|
if (!configFilePath) return {
|
|
@@ -1246,10 +1251,11 @@ var __webpack_exports__ = {};
|
|
|
1246
1251
|
let applyMetaInfo = (config)=>(config._privateMeta = {
|
|
1247
1252
|
configFilePath
|
|
1248
1253
|
}, config);
|
|
1249
|
-
if (/\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1250
|
-
let exportModule = await import(`${
|
|
1254
|
+
if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1255
|
+
let configFileURL = (0, external_node_url_namespaceObject.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
1251
1256
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1252
1257
|
} catch (err) {
|
|
1258
|
+
if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
|
|
1253
1259
|
rslog_index_js_namespaceObject.logger.debug(`Failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
|
|
1254
1260
|
}
|
|
1255
1261
|
try {
|
|
@@ -1702,7 +1708,7 @@ var __webpack_exports__ = {};
|
|
|
1702
1708
|
async function createContext(options, userConfig, bundlerType) {
|
|
1703
1709
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1704
1710
|
return {
|
|
1705
|
-
version: "1.2.
|
|
1711
|
+
version: "1.2.6",
|
|
1706
1712
|
rootPath,
|
|
1707
1713
|
distPath: '',
|
|
1708
1714
|
cachePath,
|
|
@@ -2011,10 +2017,16 @@ var __webpack_exports__ = {};
|
|
|
2011
2017
|
return process.env.BUNDLE_ANALYZE || (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.bundleAnalyze);
|
|
2012
2018
|
}, external_node_crypto_namespaceObject = require("node:crypto");
|
|
2013
2019
|
var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
2014
|
-
async function
|
|
2020
|
+
async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
2015
2021
|
let configFile = (0, external_node_path_namespaceObject.join)(cacheDirectory, 'buildDependencies.json');
|
|
2016
2022
|
if (await isFileExists(configFile)) {
|
|
2017
|
-
|
|
2023
|
+
let rawConfigFile = await external_node_fs_default().promises.readFile(configFile, 'utf-8'), prevBuildDependencies = null;
|
|
2024
|
+
try {
|
|
2025
|
+
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
2026
|
+
} catch (e) {
|
|
2027
|
+
rslog_index_js_namespaceObject.logger.debug('Failed to parse the previous buildDependencies.json', e);
|
|
2028
|
+
}
|
|
2029
|
+
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
2018
2030
|
await external_node_fs_default().promises.rm(cacheDirectory, {
|
|
2019
2031
|
force: !0,
|
|
2020
2032
|
recursive: !0
|
|
@@ -2051,24 +2063,33 @@ var __webpack_exports__ = {};
|
|
|
2051
2063
|
let pluginCache = ()=>({
|
|
2052
2064
|
name: 'rsbuild:cache',
|
|
2053
2065
|
setup (api) {
|
|
2054
|
-
|
|
2066
|
+
let cacheEnabled = !1;
|
|
2067
|
+
api.modifyBundlerChain(async (chain, { environment, env })=>{
|
|
2055
2068
|
var digest;
|
|
2056
|
-
let { config } = environment, {
|
|
2057
|
-
if (!1 === buildCache)
|
|
2058
|
-
|
|
2059
|
-
return;
|
|
2060
|
-
}
|
|
2069
|
+
let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
|
|
2070
|
+
if (!1 === buildCache) return;
|
|
2071
|
+
cacheEnabled = !0;
|
|
2061
2072
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
2062
2073
|
return cacheDirectory ? (0, external_node_path_namespaceObject.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_namespaceObject.join)(context.rootPath, cacheDirectory) : (0, external_node_path_namespaceObject.join)(context.cachePath, context.bundlerType);
|
|
2063
2074
|
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment);
|
|
2064
|
-
await
|
|
2065
|
-
let
|
|
2066
|
-
chain.cache({
|
|
2067
|
-
|
|
2075
|
+
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
2076
|
+
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, external_node_crypto_default().createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
|
|
2077
|
+
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
2078
|
+
...chain.get('experiments'),
|
|
2079
|
+
cache: {
|
|
2080
|
+
type: 'persistent',
|
|
2081
|
+
version: cacheVersion,
|
|
2082
|
+
directory: cacheDirectory,
|
|
2083
|
+
buildDependencies: Object.values(buildDependencies).flat()
|
|
2084
|
+
}
|
|
2085
|
+
})) : chain.cache({
|
|
2086
|
+
name: cacheVersion,
|
|
2068
2087
|
type: 'filesystem',
|
|
2069
2088
|
cacheDirectory,
|
|
2070
2089
|
buildDependencies
|
|
2071
2090
|
});
|
|
2091
|
+
}), api.onAfterCreateCompiler(()=>{
|
|
2092
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && rslog_index_js_namespaceObject.logger.info(`Rspack persistent cache enabled ${index_js_default().dim('(experimental)')}`);
|
|
2072
2093
|
});
|
|
2073
2094
|
}
|
|
2074
2095
|
}), addTrailingSep = (dir)=>dir.endsWith(external_node_path_namespaceObject.sep) ? dir : dir + external_node_path_namespaceObject.sep, isStrictSubdir = (parent, child)=>{
|
|
@@ -2093,9 +2114,9 @@ var __webpack_exports__ = {};
|
|
|
2093
2114
|
if (!0 === enable || 'auto' === enable && isStrictSubdir(rootPath, targetPath)) return {
|
|
2094
2115
|
path: targetPath
|
|
2095
2116
|
};
|
|
2096
|
-
}, getPathInfo = (environment)=>{
|
|
2117
|
+
}, getPathInfo = (environment, isDev)=>{
|
|
2097
2118
|
let { rootPath } = api.context, { config, distPath } = environment, { enable, keep } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
2098
|
-
return 'auto' === enable ? isStrictSubdir(rootPath, distPath) ? {
|
|
2119
|
+
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
2099
2120
|
path: distPath,
|
|
2100
2121
|
keep
|
|
2101
2122
|
} : (rslog_index_js_namespaceObject.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), rslog_index_js_namespaceObject.logger.warn(`Please set ${index_js_default().yellow('`output.cleanDistPath`')} config manually.`), rslog_index_js_namespaceObject.logger.warn(`Current root path: ${index_js_default().dim(rootPath)}`), void rslog_index_js_namespaceObject.logger.warn(`Current dist path: ${index_js_default().dim(distPath)}`)) : !0 === enable ? {
|
|
@@ -2104,7 +2125,7 @@ var __webpack_exports__ = {};
|
|
|
2104
2125
|
} : void 0;
|
|
2105
2126
|
}, cleanAll = async (params)=>{
|
|
2106
2127
|
for (let pathInfo of [
|
|
2107
|
-
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map(getPathInfo),
|
|
2128
|
+
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map((environment)=>getPathInfo(environment, params.isDev)),
|
|
2108
2129
|
getRsbuildOutputPath()
|
|
2109
2130
|
].filter((pathInfo)=>!!pathInfo))await emptyDir(pathInfo.path, pathInfo.keep);
|
|
2110
2131
|
};
|
|
@@ -2112,7 +2133,12 @@ var __webpack_exports__ = {};
|
|
|
2112
2133
|
isFirstCompile && await cleanAll({
|
|
2113
2134
|
environments
|
|
2114
2135
|
});
|
|
2115
|
-
}), api.onBeforeStartDevServer(
|
|
2136
|
+
}), api.onBeforeStartDevServer(async ({ environments })=>{
|
|
2137
|
+
await cleanAll({
|
|
2138
|
+
environments,
|
|
2139
|
+
isDev: !0
|
|
2140
|
+
});
|
|
2141
|
+
});
|
|
2116
2142
|
}
|
|
2117
2143
|
}), dist_isNil = (o)=>null == o, dist_isFunction = (func)=>'function' == typeof func, dist_isObject = (obj)=>null !== obj && 'object' == typeof obj, dist_isPlainObject = (obj)=>dist_isObject(obj) && '[object Object]' === Object.prototype.toString.call(obj);
|
|
2118
2144
|
function reduceConfigs({ initial, config, mergeFn = Object.assign }) {
|
|
@@ -2342,12 +2368,12 @@ var __webpack_exports__ = {};
|
|
|
2342
2368
|
let excludeAsset = (asset)=>/\.(?:map|LICENSE\.txt)$/.test(asset.name), getAssetColor = (size)=>size > 300000 ? index_js_default().red : size > 100000 ? index_js_default().yellow : index_js_default().green, calcFileSize = (len)=>{
|
|
2343
2369
|
let val = len / 1000;
|
|
2344
2370
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2345
|
-
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName);
|
|
2371
|
+
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
|
|
2346
2372
|
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
2347
2373
|
let logs = [];
|
|
2348
2374
|
if (!1 === options.detail && !1 === options.total) return logs;
|
|
2349
2375
|
let formatAsset = async (asset, distPath, distFolder)=>{
|
|
2350
|
-
let fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = contents.length, gzippedSize = options.compressed ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
2376
|
+
let fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = contents.length, gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
2351
2377
|
return {
|
|
2352
2378
|
size,
|
|
2353
2379
|
folder: external_node_path_default().join(distFolder, external_node_path_default().dirname(fileName)),
|
|
@@ -3013,27 +3039,27 @@ var __webpack_exports__ = {};
|
|
|
3013
3039
|
apply(compiler) {
|
|
3014
3040
|
let { splitChunks } = compiler.options.optimization;
|
|
3015
3041
|
if (!splitChunks) return;
|
|
3016
|
-
let applyPatch = (
|
|
3017
|
-
if ('object' != typeof
|
|
3018
|
-
let { chunks } =
|
|
3042
|
+
let applyPatch = (config)=>{
|
|
3043
|
+
if ('object' != typeof config || (0, types_namespaceObject.isRegExp)(config)) return;
|
|
3044
|
+
let { chunks } = config;
|
|
3019
3045
|
if (chunks && 'async' !== chunks) {
|
|
3020
3046
|
if ('function' == typeof chunks) {
|
|
3021
|
-
|
|
3047
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunks(chunk);
|
|
3022
3048
|
return;
|
|
3023
3049
|
}
|
|
3024
3050
|
if ('all' === chunks) {
|
|
3025
|
-
|
|
3051
|
+
config.chunks = (chunk)=>!chunk.name || chunk.name !== this.name;
|
|
3026
3052
|
return;
|
|
3027
3053
|
}
|
|
3028
3054
|
if ('initial' === chunks) {
|
|
3029
|
-
|
|
3055
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunk.isOnlyInitial();
|
|
3030
3056
|
return;
|
|
3031
3057
|
}
|
|
3032
3058
|
}
|
|
3033
3059
|
};
|
|
3034
3060
|
applyPatch(splitChunks);
|
|
3035
3061
|
let { cacheGroups } = splitChunks;
|
|
3036
|
-
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))applyPatch(cacheGroups[cacheGroupKey]);
|
|
3062
|
+
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))cacheGroups[cacheGroupKey] && applyPatch(cacheGroups[cacheGroupKey]);
|
|
3037
3063
|
}
|
|
3038
3064
|
constructor(name){
|
|
3039
3065
|
!function(obj, key, value) {
|
|
@@ -3683,7 +3709,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3683
3709
|
return;
|
|
3684
3710
|
}
|
|
3685
3711
|
try {
|
|
3686
|
-
|
|
3712
|
+
let moduleURL = 'win32' === process.platform ? (0, external_node_url_namespaceObject.pathToFileURL)(packagePath).href : packagePath;
|
|
3713
|
+
module = await import(moduleURL);
|
|
3687
3714
|
} catch (err) {
|
|
3688
3715
|
rslog_index_js_namespaceObject.logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${index_js_default().bold(index_js_default().yellow(packageName))} module.`);
|
|
3689
3716
|
return;
|
|
@@ -4315,6 +4342,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4315
4342
|
])
|
|
4316
4343
|
})
|
|
4317
4344
|
};
|
|
4345
|
+
}, validateRsbuildConfig = (config)=>{
|
|
4346
|
+
if (config.server.base && !config.server.base.startsWith('/')) throw Error('[rsbuild:config] The "server.base" option should start with a slash, for example: "/base"');
|
|
4318
4347
|
};
|
|
4319
4348
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
4320
4349
|
if (context.normalizedConfig) return context.normalizedConfig;
|
|
@@ -4352,7 +4381,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4352
4381
|
}
|
|
4353
4382
|
return common.join(external_node_path_namespaceObject.sep);
|
|
4354
4383
|
}(distPaths);
|
|
4355
|
-
}(context), context.normalizedConfig;
|
|
4384
|
+
}(context), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4356
4385
|
}
|
|
4357
4386
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
4358
4387
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -6588,7 +6617,9 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6588
6617
|
}
|
|
6589
6618
|
}
|
|
6590
6619
|
let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6591
|
-
cli.option('
|
|
6620
|
+
cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
6621
|
+
default: 'jiti'
|
|
6622
|
+
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
6592
6623
|
type: [
|
|
6593
6624
|
String
|
|
6594
6625
|
],
|
|
@@ -6609,12 +6640,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6609
6640
|
}
|
|
6610
6641
|
}(), process.title = 'rsbuild-node';
|
|
6611
6642
|
let { npm_execpath } = process.env;
|
|
6612
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6643
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.6\n`);
|
|
6613
6644
|
}();
|
|
6614
6645
|
try {
|
|
6615
6646
|
!function() {
|
|
6616
6647
|
let cli = cac_dist('rsbuild');
|
|
6617
|
-
cli.help(), cli.version("1.2.
|
|
6648
|
+
cli.help(), cli.version("1.2.6"), applyCommonOptions(cli);
|
|
6618
6649
|
let devCommand = cli.command('dev', 'starting the dev server'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
6619
6650
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6620
6651
|
try {
|
|
@@ -6665,7 +6696,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6665
6696
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6666
6697
|
}
|
|
6667
6698
|
}
|
|
6668
|
-
let src_rslib_entry_version = "1.2.
|
|
6699
|
+
let src_rslib_entry_version = "1.2.6";
|
|
6669
6700
|
})();
|
|
6670
6701
|
var __webpack_export_target__ = exports;
|
|
6671
6702
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
package/dist/index.js
CHANGED
|
@@ -827,36 +827,42 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
827
827
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
828
828
|
cliOptions && (commonOpts = cliOptions);
|
|
829
829
|
try {
|
|
830
|
-
var _config_server, _config_dev
|
|
830
|
+
var _config_server, _config_dev;
|
|
831
831
|
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
|
|
832
832
|
cwd: getEnvDir(root, commonOpts.envDir),
|
|
833
833
|
mode: commonOpts.envMode
|
|
834
834
|
}), { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
835
835
|
cwd: root,
|
|
836
836
|
path: commonOpts.config,
|
|
837
|
-
envMode: commonOpts.envMode
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
let files = [
|
|
841
|
-
...envs.filePaths
|
|
842
|
-
];
|
|
843
|
-
if (configFilePath && files.push(configFilePath), null === (_config_dev1 = config.dev) || void 0 === _config_dev1 ? void 0 : _config_dev1.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
844
|
-
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
845
|
-
let paths = castArray(watchFilesConfig.paths);
|
|
846
|
-
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
847
|
-
}
|
|
848
|
-
watchFilesForRestart(files, root, isBuildWatch);
|
|
849
|
-
}
|
|
837
|
+
envMode: commonOpts.envMode,
|
|
838
|
+
loader: commonOpts.configLoader
|
|
839
|
+
});
|
|
850
840
|
config.source ||= {}, config.source.define = {
|
|
851
841
|
...envs.publicVars,
|
|
852
842
|
...config.source.define
|
|
853
|
-
}, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
843
|
+
}, commonOpts.base && (config.server ||= {}, config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
854
844
|
let rsbuild = await createRsbuild({
|
|
855
845
|
cwd: root,
|
|
856
846
|
rsbuildConfig: config,
|
|
857
847
|
environment: commonOpts.environment
|
|
858
848
|
});
|
|
859
|
-
return rsbuild.
|
|
849
|
+
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
850
|
+
let command = process.argv[2];
|
|
851
|
+
if ('dev' === command || isBuildWatch) {
|
|
852
|
+
var _config_dev;
|
|
853
|
+
let files = [
|
|
854
|
+
...envs.filePaths
|
|
855
|
+
];
|
|
856
|
+
configFilePath && files.push(configFilePath);
|
|
857
|
+
let config = rsbuild.getNormalizedConfig();
|
|
858
|
+
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
859
|
+
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
860
|
+
let paths = castArray(watchFilesConfig.paths);
|
|
861
|
+
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
862
|
+
}
|
|
863
|
+
watchFilesForRestart(files, root, isBuildWatch);
|
|
864
|
+
}
|
|
865
|
+
}), rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup), rsbuild;
|
|
860
866
|
} catch (err) {
|
|
861
867
|
if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
862
868
|
else throw err;
|
|
@@ -1012,7 +1018,6 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.create
|
|
|
1012
1018
|
}
|
|
1013
1019
|
}), getDefaultPerformanceConfig = ()=>({
|
|
1014
1020
|
profile: !1,
|
|
1015
|
-
buildCache: !0,
|
|
1016
1021
|
printFileSize: !0,
|
|
1017
1022
|
removeConsole: !1,
|
|
1018
1023
|
removeMomentLocale: !1,
|
|
@@ -1145,7 +1150,7 @@ async function watchFilesForRestart(files, root, isBuildWatch, watchOptions) {
|
|
|
1145
1150
|
});
|
|
1146
1151
|
watcher.on('add', callback), watcher.on('change', callback), watcher.on('unlink', callback);
|
|
1147
1152
|
}
|
|
1148
|
-
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } = {}) {
|
|
1153
|
+
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1149
1154
|
let configExport;
|
|
1150
1155
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1151
1156
|
if (!configFilePath) return {
|
|
@@ -1155,10 +1160,11 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } =
|
|
|
1155
1160
|
let applyMetaInfo = (config)=>(config._privateMeta = {
|
|
1156
1161
|
configFilePath
|
|
1157
1162
|
}, config);
|
|
1158
|
-
if (/\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1159
|
-
let exportModule = await import(`${
|
|
1163
|
+
if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1164
|
+
let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
1160
1165
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1161
1166
|
} catch (err) {
|
|
1167
|
+
if ('native' === loader) throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with native loader: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
|
|
1162
1168
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`Failed to load file with dynamic import: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`);
|
|
1163
1169
|
}
|
|
1164
1170
|
try {
|
|
@@ -1611,7 +1617,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
1611
1617
|
async function createContext(options, userConfig, bundlerType) {
|
|
1612
1618
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1613
1619
|
return {
|
|
1614
|
-
version: "1.2.
|
|
1620
|
+
version: "1.2.6",
|
|
1615
1621
|
rootPath,
|
|
1616
1622
|
distPath: '',
|
|
1617
1623
|
cachePath,
|
|
@@ -1919,10 +1925,16 @@ let configChain_CHAIN_ID = {
|
|
|
1919
1925
|
var _config_performance;
|
|
1920
1926
|
return process.env.BUNDLE_ANALYZE || (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.bundleAnalyze);
|
|
1921
1927
|
};
|
|
1922
|
-
async function
|
|
1928
|
+
async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
1923
1929
|
let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cacheDirectory, 'buildDependencies.json');
|
|
1924
1930
|
if (await isFileExists(configFile)) {
|
|
1925
|
-
|
|
1931
|
+
let rawConfigFile = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(configFile, 'utf-8'), prevBuildDependencies = null;
|
|
1932
|
+
try {
|
|
1933
|
+
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
1934
|
+
} catch (e) {
|
|
1935
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('Failed to parse the previous buildDependencies.json', e);
|
|
1936
|
+
}
|
|
1937
|
+
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
1926
1938
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.rm(cacheDirectory, {
|
|
1927
1939
|
force: !0,
|
|
1928
1940
|
recursive: !0
|
|
@@ -1959,24 +1971,33 @@ async function getBuildDependencies(context, config, environmentContext) {
|
|
|
1959
1971
|
let pluginCache = ()=>({
|
|
1960
1972
|
name: 'rsbuild:cache',
|
|
1961
1973
|
setup (api) {
|
|
1962
|
-
|
|
1974
|
+
let cacheEnabled = !1;
|
|
1975
|
+
api.modifyBundlerChain(async (chain, { environment, env })=>{
|
|
1963
1976
|
var digest;
|
|
1964
|
-
let { config } = environment, {
|
|
1965
|
-
if (!1 === buildCache)
|
|
1966
|
-
|
|
1967
|
-
return;
|
|
1968
|
-
}
|
|
1977
|
+
let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
|
|
1978
|
+
if (!1 === buildCache) return;
|
|
1979
|
+
cacheEnabled = !0;
|
|
1969
1980
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
1970
1981
|
return cacheDirectory ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, cacheDirectory) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.cachePath, context.bundlerType);
|
|
1971
1982
|
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment);
|
|
1972
|
-
await
|
|
1973
|
-
let
|
|
1974
|
-
chain.cache({
|
|
1975
|
-
|
|
1983
|
+
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
1984
|
+
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
|
|
1985
|
+
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
1986
|
+
...chain.get('experiments'),
|
|
1987
|
+
cache: {
|
|
1988
|
+
type: 'persistent',
|
|
1989
|
+
version: cacheVersion,
|
|
1990
|
+
directory: cacheDirectory,
|
|
1991
|
+
buildDependencies: Object.values(buildDependencies).flat()
|
|
1992
|
+
}
|
|
1993
|
+
})) : chain.cache({
|
|
1994
|
+
name: cacheVersion,
|
|
1976
1995
|
type: 'filesystem',
|
|
1977
1996
|
cacheDirectory,
|
|
1978
1997
|
buildDependencies
|
|
1979
1998
|
});
|
|
1999
|
+
}), api.onAfterCreateCompiler(()=>{
|
|
2000
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`Rspack persistent cache enabled ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('(experimental)')}`);
|
|
1980
2001
|
});
|
|
1981
2002
|
}
|
|
1982
2003
|
}), addTrailingSep = (dir)=>dir.endsWith(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep) ? dir : dir + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep, isStrictSubdir = (parent, child)=>{
|
|
@@ -2001,9 +2022,9 @@ let pluginCache = ()=>({
|
|
|
2001
2022
|
if (!0 === enable || 'auto' === enable && isStrictSubdir(rootPath, targetPath)) return {
|
|
2002
2023
|
path: targetPath
|
|
2003
2024
|
};
|
|
2004
|
-
}, getPathInfo = (environment)=>{
|
|
2025
|
+
}, getPathInfo = (environment, isDev)=>{
|
|
2005
2026
|
let { rootPath } = api.context, { config, distPath } = environment, { enable, keep } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
2006
|
-
return 'auto' === enable ? isStrictSubdir(rootPath, distPath) ? {
|
|
2027
|
+
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
2007
2028
|
path: distPath,
|
|
2008
2029
|
keep
|
|
2009
2030
|
} : (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`), void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current dist path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(distPath)}`)) : !0 === enable ? {
|
|
@@ -2012,7 +2033,7 @@ let pluginCache = ()=>({
|
|
|
2012
2033
|
} : void 0;
|
|
2013
2034
|
}, cleanAll = async (params)=>{
|
|
2014
2035
|
for (let pathInfo of [
|
|
2015
|
-
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map(getPathInfo),
|
|
2036
|
+
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map((environment)=>getPathInfo(environment, params.isDev)),
|
|
2016
2037
|
getRsbuildOutputPath()
|
|
2017
2038
|
].filter((pathInfo)=>!!pathInfo))await emptyDir(pathInfo.path, pathInfo.keep);
|
|
2018
2039
|
};
|
|
@@ -2020,7 +2041,12 @@ let pluginCache = ()=>({
|
|
|
2020
2041
|
isFirstCompile && await cleanAll({
|
|
2021
2042
|
environments
|
|
2022
2043
|
});
|
|
2023
|
-
}), api.onBeforeStartDevServer(
|
|
2044
|
+
}), api.onBeforeStartDevServer(async ({ environments })=>{
|
|
2045
|
+
await cleanAll({
|
|
2046
|
+
environments,
|
|
2047
|
+
isDev: !0
|
|
2048
|
+
});
|
|
2049
|
+
});
|
|
2024
2050
|
}
|
|
2025
2051
|
}), dist_isNil = (o)=>null == o, dist_isFunction = (func)=>'function' == typeof func, dist_isObject = (obj)=>null !== obj && 'object' == typeof obj, dist_isPlainObject = (obj)=>dist_isObject(obj) && '[object Object]' === Object.prototype.toString.call(obj);
|
|
2026
2052
|
function reduceConfigs({ initial, config, mergeFn = Object.assign }) {
|
|
@@ -2248,12 +2274,12 @@ async function gzipSize(input) {
|
|
|
2248
2274
|
let excludeAsset = (asset)=>/\.(?:map|LICENSE\.txt)$/.test(asset.name), getAssetColor = (size)=>size > 300000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red : size > 100000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green, calcFileSize = (len)=>{
|
|
2249
2275
|
let val = len / 1000;
|
|
2250
2276
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2251
|
-
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName);
|
|
2277
|
+
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
|
|
2252
2278
|
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
2253
2279
|
let logs = [];
|
|
2254
2280
|
if (!1 === options.detail && !1 === options.total) return logs;
|
|
2255
2281
|
let formatAsset = async (asset, distPath, distFolder)=>{
|
|
2256
|
-
let fileName = asset.name.split('?')[0], contents = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(distPath, fileName)), size = contents.length, gzippedSize = options.compressed ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
2282
|
+
let fileName = asset.name.split('?')[0], contents = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(distPath, fileName)), size = contents.length, gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
2257
2283
|
return {
|
|
2258
2284
|
size,
|
|
2259
2285
|
folder: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(distFolder, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname(fileName)),
|
|
@@ -2919,27 +2945,27 @@ class PatchSplitChunksPlugin {
|
|
|
2919
2945
|
apply(compiler) {
|
|
2920
2946
|
let { splitChunks } = compiler.options.optimization;
|
|
2921
2947
|
if (!splitChunks) return;
|
|
2922
|
-
let applyPatch = (
|
|
2923
|
-
if ('object' != typeof
|
|
2924
|
-
let { chunks } =
|
|
2948
|
+
let applyPatch = (config)=>{
|
|
2949
|
+
if ('object' != typeof config || (0, __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__.isRegExp)(config)) return;
|
|
2950
|
+
let { chunks } = config;
|
|
2925
2951
|
if (chunks && 'async' !== chunks) {
|
|
2926
2952
|
if ('function' == typeof chunks) {
|
|
2927
|
-
|
|
2953
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunks(chunk);
|
|
2928
2954
|
return;
|
|
2929
2955
|
}
|
|
2930
2956
|
if ('all' === chunks) {
|
|
2931
|
-
|
|
2957
|
+
config.chunks = (chunk)=>!chunk.name || chunk.name !== this.name;
|
|
2932
2958
|
return;
|
|
2933
2959
|
}
|
|
2934
2960
|
if ('initial' === chunks) {
|
|
2935
|
-
|
|
2961
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunk.isOnlyInitial();
|
|
2936
2962
|
return;
|
|
2937
2963
|
}
|
|
2938
2964
|
}
|
|
2939
2965
|
};
|
|
2940
2966
|
applyPatch(splitChunks);
|
|
2941
2967
|
let { cacheGroups } = splitChunks;
|
|
2942
|
-
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))applyPatch(cacheGroups[cacheGroupKey]);
|
|
2968
|
+
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))cacheGroups[cacheGroupKey] && applyPatch(cacheGroups[cacheGroupKey]);
|
|
2943
2969
|
}
|
|
2944
2970
|
constructor(name){
|
|
2945
2971
|
var key, value;
|
|
@@ -3584,7 +3610,8 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
3584
3610
|
return;
|
|
3585
3611
|
}
|
|
3586
3612
|
try {
|
|
3587
|
-
|
|
3613
|
+
let moduleURL = 'win32' === process.platform ? (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(packagePath).href : packagePath;
|
|
3614
|
+
module = await import(moduleURL);
|
|
3588
3615
|
} catch (err) {
|
|
3589
3616
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(packageName))} module.`);
|
|
3590
3617
|
return;
|
|
@@ -4212,6 +4239,8 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
|
|
|
4212
4239
|
])
|
|
4213
4240
|
})
|
|
4214
4241
|
};
|
|
4242
|
+
}, validateRsbuildConfig = (config)=>{
|
|
4243
|
+
if (config.server.base && !config.server.base.startsWith('/')) throw Error('[rsbuild:config] The "server.base" option should start with a slash, for example: "/base"');
|
|
4215
4244
|
};
|
|
4216
4245
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
4217
4246
|
if (context.normalizedConfig) return context.normalizedConfig;
|
|
@@ -4249,7 +4278,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
4249
4278
|
}
|
|
4250
4279
|
return common.join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
|
|
4251
4280
|
}(distPaths);
|
|
4252
|
-
}(context), context.normalizedConfig;
|
|
4281
|
+
}(context), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4253
4282
|
}
|
|
4254
4283
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
4255
4284
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -6476,7 +6505,9 @@ class CAC extends __WEBPACK_EXTERNAL_MODULE_events__.EventEmitter {
|
|
|
6476
6505
|
}
|
|
6477
6506
|
}
|
|
6478
6507
|
let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6479
|
-
cli.option('
|
|
6508
|
+
cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
6509
|
+
default: 'jiti'
|
|
6510
|
+
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
6480
6511
|
type: [
|
|
6481
6512
|
String
|
|
6482
6513
|
],
|
|
@@ -6497,12 +6528,12 @@ async function runCLI() {
|
|
|
6497
6528
|
}
|
|
6498
6529
|
}(), process.title = 'rsbuild-node';
|
|
6499
6530
|
let { npm_execpath } = process.env;
|
|
6500
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.
|
|
6531
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.6\n`);
|
|
6501
6532
|
}();
|
|
6502
6533
|
try {
|
|
6503
6534
|
!function() {
|
|
6504
6535
|
let cli = cac_dist('rsbuild');
|
|
6505
|
-
cli.help(), cli.version("1.2.
|
|
6536
|
+
cli.help(), cli.version("1.2.6"), applyCommonOptions(cli);
|
|
6506
6537
|
let devCommand = cli.command('dev', 'starting the dev server'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
6507
6538
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6508
6539
|
try {
|
|
@@ -6553,6 +6584,6 @@ async function runCLI() {
|
|
|
6553
6584
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
6554
6585
|
}
|
|
6555
6586
|
}
|
|
6556
|
-
let src_version = "1.2.
|
|
6587
|
+
let src_version = "1.2.6";
|
|
6557
6588
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6558
6589
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ConfigLoader } from '../config';
|
|
1
2
|
import type { RsbuildMode } from '../types';
|
|
2
3
|
export type CommonOptions = {
|
|
4
|
+
base?: string;
|
|
3
5
|
root?: string;
|
|
4
6
|
mode?: RsbuildMode;
|
|
5
7
|
config?: string;
|
|
8
|
+
configLoader?: ConfigLoader;
|
|
6
9
|
envDir?: string;
|
|
7
10
|
envMode?: string;
|
|
8
11
|
open?: boolean | string;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -46,6 +46,13 @@ export type LoadConfigOptions = {
|
|
|
46
46
|
* @default process.env.NODE_ENV
|
|
47
47
|
*/
|
|
48
48
|
envMode?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Specify the config loader, can be `jiti` or `native`.
|
|
51
|
+
* - 'jiti': Use `jiti` as loader, which supports TypeScript and ESM out of the box
|
|
52
|
+
* - 'native': Use native Node.js loader, requires TypeScript support in Node.js >= 22.6
|
|
53
|
+
* @default 'jiti'
|
|
54
|
+
*/
|
|
55
|
+
loader?: ConfigLoader;
|
|
49
56
|
};
|
|
50
57
|
export type LoadConfigResult = {
|
|
51
58
|
/**
|
|
@@ -58,7 +65,8 @@ export type LoadConfigResult = {
|
|
|
58
65
|
*/
|
|
59
66
|
filePath: string | null;
|
|
60
67
|
};
|
|
61
|
-
export
|
|
68
|
+
export type ConfigLoader = 'jiti' | 'native';
|
|
69
|
+
export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
62
70
|
export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
|
|
63
71
|
normalizedConfig: NormalizedConfig;
|
|
64
72
|
inspectOptions: InspectConfigOptions;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export { logger } from './logger';
|
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { ensureAssetPrefix } from './helpers';
|
|
17
17
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
18
|
-
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance,
|
|
18
|
+
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, Charset, ClientConfig, CliShortcut, CleanDistPath, CleanDistPathObject, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentContext, EnvironmentConfig, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlConfig, HtmlRspackPlugin, HtmlBasicTag, HtmlFallback, HtmlTagHandler, HtmlTagDescriptor, HtmlTagContext, InspectConfigOptions, InspectConfigResult, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InternalContext, LegalComments, ManifestData, ManifestConfig, ManifestObjectConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterEnvironmentCompileFn, OnBeforeEnvironmentCompileFn, OnCloseBuildFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PreloadIncludeType, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformFn, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
19
19
|
export type { ChainIdentifier } from './configChain';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
@@ -325,8 +325,16 @@ export interface SecurityConfig {
|
|
|
325
325
|
export type NormalizedSecurityConfig = Required<SecurityConfig>;
|
|
326
326
|
export type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group';
|
|
327
327
|
export type BuildCacheOptions = {
|
|
328
|
-
/**
|
|
328
|
+
/**
|
|
329
|
+
* The output directory of the cache files.
|
|
330
|
+
* @default 'node_modules/.cache'
|
|
331
|
+
*/
|
|
329
332
|
cacheDirectory?: string;
|
|
333
|
+
/**
|
|
334
|
+
* Add additional cache digests, the previous build cache will be invalidated
|
|
335
|
+
* when any value in the array changes.
|
|
336
|
+
* @default undefined
|
|
337
|
+
*/
|
|
330
338
|
cacheDigest?: Array<string | undefined>;
|
|
331
339
|
};
|
|
332
340
|
export type PrintFileSizeAsset = {
|
|
@@ -400,7 +408,8 @@ export interface PerformanceConfig {
|
|
|
400
408
|
*/
|
|
401
409
|
removeMomentLocale?: boolean;
|
|
402
410
|
/**
|
|
403
|
-
*
|
|
411
|
+
* To enable or configure persistent build cache.
|
|
412
|
+
* @experimental This feature is experimental and may be changed in the future.
|
|
404
413
|
*/
|
|
405
414
|
buildCache?: BuildCacheOptions | boolean;
|
|
406
415
|
/**
|
|
@@ -448,7 +457,6 @@ export interface PerformanceConfig {
|
|
|
448
457
|
}
|
|
449
458
|
export interface NormalizedPerformanceConfig extends PerformanceConfig {
|
|
450
459
|
printFileSize: PrintFileSizeOptions | boolean;
|
|
451
|
-
buildCache: BuildCacheOptions | boolean;
|
|
452
460
|
chunkSplit: RsbuildChunkSplit;
|
|
453
461
|
}
|
|
454
462
|
export type SplitChunks = Configuration extends {
|
|
@@ -456,16 +464,6 @@ export type SplitChunks = Configuration extends {
|
|
|
456
464
|
splitChunks?: infer P;
|
|
457
465
|
};
|
|
458
466
|
} ? P : never;
|
|
459
|
-
export type CacheGroups = Configuration extends {
|
|
460
|
-
optimization?: {
|
|
461
|
-
splitChunks?: {
|
|
462
|
-
cacheGroups?: infer P;
|
|
463
|
-
} | false;
|
|
464
|
-
};
|
|
465
|
-
} ? P : never;
|
|
466
|
-
export type CacheGroup = CacheGroups extends {
|
|
467
|
-
[key: string]: infer P;
|
|
468
|
-
} ? P : null;
|
|
469
467
|
export type ForceSplitting = RegExp[] | Record<string, RegExp>;
|
|
470
468
|
export interface BaseSplitRules {
|
|
471
469
|
strategy?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"core-js": "~3.40.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@rslib/core": "0.4.
|
|
55
|
+
"@rslib/core": "0.4.1",
|
|
56
56
|
"@types/connect": "3.4.38",
|
|
57
|
-
"@types/node": "^22.13.
|
|
57
|
+
"@types/node": "^22.13.1",
|
|
58
58
|
"@types/on-finished": "2.3.4",
|
|
59
59
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
60
60
|
"@types/ws": "^8.5.14",
|