@rsbuild/core 1.3.13 → 1.3.15
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 +19 -19
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +85 -69
- package/dist/index.js +85 -69
- package/dist-types/hooks.d.ts +2 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/plugins/html.d.ts +2 -2
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +4 -4
- package/dist-types/types/hooks.d.ts +21 -11
- package/dist-types/types/plugin.d.ts +19 -8
- package/package.json +5 -5
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
9377: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const loader = __nccwpck_require__(
|
|
5
|
+
const loader = __nccwpck_require__(1667);
|
|
6
6
|
module.exports = loader.default;
|
|
7
7
|
module.exports.defaultGetLocalIdent =
|
|
8
|
-
__nccwpck_require__(
|
|
8
|
+
__nccwpck_require__(9230).defaultGetLocalIdent;
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
1667: (__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__(6800);
|
|
16
|
+
var _utils = __nccwpck_require__(9230);
|
|
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
|
+
6800: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
240
240
|
"use strict";
|
|
241
241
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
242
242
|
Object.defineProperty(exports, "icssParser", {
|
|
@@ -257,21 +257,21 @@
|
|
|
257
257
|
return _postcssUrlParser.default;
|
|
258
258
|
},
|
|
259
259
|
});
|
|
260
|
-
var _postcssImportParser = _interopRequireDefault(
|
|
261
|
-
|
|
262
|
-
__nccwpck_require__(6712),
|
|
260
|
+
var _postcssImportParser = _interopRequireDefault(
|
|
261
|
+
__nccwpck_require__(5715),
|
|
263
262
|
);
|
|
264
|
-
var
|
|
263
|
+
var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(126));
|
|
264
|
+
var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(3737));
|
|
265
265
|
function _interopRequireDefault(obj) {
|
|
266
266
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
|
-
|
|
269
|
+
126: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
270
270
|
"use strict";
|
|
271
271
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
272
272
|
exports["default"] = void 0;
|
|
273
273
|
var _icssUtils = __nccwpck_require__(4531);
|
|
274
|
-
var _utils = __nccwpck_require__(
|
|
274
|
+
var _utils = __nccwpck_require__(9230);
|
|
275
275
|
const plugin = (options = {}) => ({
|
|
276
276
|
postcssPlugin: "postcss-icss-parser",
|
|
277
277
|
async OnceExit(root) {
|
|
@@ -370,14 +370,14 @@
|
|
|
370
370
|
plugin.postcss = true;
|
|
371
371
|
var _default = (exports["default"] = plugin);
|
|
372
372
|
},
|
|
373
|
-
|
|
373
|
+
5715: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
374
374
|
"use strict";
|
|
375
375
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
376
376
|
exports["default"] = void 0;
|
|
377
377
|
var _postcssValueParser = _interopRequireDefault(
|
|
378
378
|
__nccwpck_require__(2948),
|
|
379
379
|
);
|
|
380
|
-
var _utils = __nccwpck_require__(
|
|
380
|
+
var _utils = __nccwpck_require__(9230);
|
|
381
381
|
function _interopRequireDefault(obj) {
|
|
382
382
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
383
383
|
}
|
|
@@ -682,14 +682,14 @@
|
|
|
682
682
|
plugin.postcss = true;
|
|
683
683
|
var _default = (exports["default"] = plugin);
|
|
684
684
|
},
|
|
685
|
-
|
|
685
|
+
3737: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
686
686
|
"use strict";
|
|
687
687
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
688
688
|
exports["default"] = void 0;
|
|
689
689
|
var _postcssValueParser = _interopRequireDefault(
|
|
690
690
|
__nccwpck_require__(2948),
|
|
691
691
|
);
|
|
692
|
-
var _utils = __nccwpck_require__(
|
|
692
|
+
var _utils = __nccwpck_require__(9230);
|
|
693
693
|
function _interopRequireDefault(obj) {
|
|
694
694
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
695
695
|
}
|
|
@@ -1032,7 +1032,7 @@
|
|
|
1032
1032
|
plugin.postcss = true;
|
|
1033
1033
|
var _default = (exports["default"] = plugin);
|
|
1034
1034
|
},
|
|
1035
|
-
|
|
1035
|
+
9230: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1036
1036
|
"use strict";
|
|
1037
1037
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1038
1038
|
exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
|
|
@@ -8096,6 +8096,6 @@
|
|
|
8096
8096
|
}
|
|
8097
8097
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
8098
8098
|
__nccwpck_require__.ab = __dirname + "/";
|
|
8099
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
8099
|
+
var __webpack_exports__ = __nccwpck_require__(9377);
|
|
8100
8100
|
module.exports = __webpack_exports__;
|
|
8101
8101
|
})();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
725: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const { HtmlWebpackChildCompiler } = __nccwpck_require__(
|
|
5
|
+
const { HtmlWebpackChildCompiler } = __nccwpck_require__(318);
|
|
6
6
|
const compilerMap = new WeakMap();
|
|
7
7
|
class CachedChildCompilation {
|
|
8
8
|
constructor(compiler) {
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
}
|
|
305
305
|
module.exports = { CachedChildCompilation };
|
|
306
306
|
},
|
|
307
|
-
|
|
307
|
+
318: (module) => {
|
|
308
308
|
"use strict";
|
|
309
309
|
class HtmlWebpackChildCompiler {
|
|
310
310
|
constructor(templates) {
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
}
|
|
474
474
|
module.exports = { HtmlWebpackChildCompiler };
|
|
475
475
|
},
|
|
476
|
-
|
|
476
|
+
910: (module) => {
|
|
477
477
|
"use strict";
|
|
478
478
|
module.exports = {};
|
|
479
479
|
module.exports.none = (chunks) => chunks;
|
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
};
|
|
493
493
|
module.exports.auto = module.exports.none;
|
|
494
494
|
},
|
|
495
|
-
|
|
495
|
+
185: (module) => {
|
|
496
496
|
"use strict";
|
|
497
497
|
module.exports = function (err) {
|
|
498
498
|
return {
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
};
|
|
514
514
|
};
|
|
515
515
|
},
|
|
516
|
-
|
|
516
|
+
312: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
517
517
|
"use strict";
|
|
518
518
|
const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
|
|
519
519
|
const htmlWebpackPluginHooksMap = new WeakMap();
|
|
@@ -539,7 +539,7 @@
|
|
|
539
539
|
}
|
|
540
540
|
module.exports = { getHtmlRspackPluginHooks };
|
|
541
541
|
},
|
|
542
|
-
|
|
542
|
+
333: (module) => {
|
|
543
543
|
const voidTags = [
|
|
544
544
|
"area",
|
|
545
545
|
"base",
|
|
@@ -607,19 +607,19 @@
|
|
|
607
607
|
htmlTagObjectToString,
|
|
608
608
|
};
|
|
609
609
|
},
|
|
610
|
-
|
|
610
|
+
192: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
611
611
|
"use strict";
|
|
612
612
|
const promisify = __nccwpck_require__(23).promisify;
|
|
613
613
|
const vm = __nccwpck_require__(154);
|
|
614
614
|
const fs = __nccwpck_require__(896);
|
|
615
615
|
const path = __nccwpck_require__(928);
|
|
616
|
-
const { CachedChildCompilation } = __nccwpck_require__(
|
|
616
|
+
const { CachedChildCompilation } = __nccwpck_require__(725);
|
|
617
617
|
const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
|
|
618
|
-
__nccwpck_require__(
|
|
619
|
-
const prettyError = __nccwpck_require__(
|
|
620
|
-
const chunkSorter = __nccwpck_require__(
|
|
618
|
+
__nccwpck_require__(333);
|
|
619
|
+
const prettyError = __nccwpck_require__(185);
|
|
620
|
+
const chunkSorter = __nccwpck_require__(910);
|
|
621
621
|
const getHtmlRspackPluginHooks =
|
|
622
|
-
__nccwpck_require__(
|
|
622
|
+
__nccwpck_require__(312).getHtmlRspackPluginHooks;
|
|
623
623
|
class HtmlRspackPlugin {
|
|
624
624
|
constructor(userOptions = {}) {
|
|
625
625
|
this.version = HtmlRspackPlugin.version;
|
|
@@ -1586,6 +1586,6 @@
|
|
|
1586
1586
|
}
|
|
1587
1587
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
1588
1588
|
__nccwpck_require__.ab = __dirname + "/";
|
|
1589
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
1589
|
+
var __webpack_exports__ = __nccwpck_require__(192);
|
|
1590
1590
|
module.exports = __webpack_exports__;
|
|
1591
1591
|
})();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = __nccwpck_require__(
|
|
4
|
+
631: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
module.exports = __nccwpck_require__(513)["default"];
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
513: (__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__(876);
|
|
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
|
+
876: (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__(631);
|
|
720
720
|
module.exports = __webpack_exports__;
|
|
721
721
|
})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
4
|
+
685: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.transformFiles =
|
|
7
7
|
exports.reduceChunk =
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
.map(standardizeFilePaths);
|
|
121
121
|
exports.transformFiles = transformFiles;
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
440: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
124
124
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
125
|
exports.normalModuleLoaderHook =
|
|
126
126
|
exports.getCompilerHooks =
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
const fs_1 = __nccwpck_require__(896);
|
|
131
131
|
const path_1 = __nccwpck_require__(928);
|
|
132
132
|
const lite_tapable_1 = __nccwpck_require__(408);
|
|
133
|
-
const helpers_1 = __nccwpck_require__(
|
|
133
|
+
const helpers_1 = __nccwpck_require__(685);
|
|
134
134
|
const compilerHookMap = new WeakMap();
|
|
135
135
|
const getCompilerHooks = (compiler) => {
|
|
136
136
|
let hooks = compilerHookMap.get(compiler);
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
exports.getCompilerHooks =
|
|
313
313
|
void 0;
|
|
314
314
|
const path_1 = __nccwpck_require__(928);
|
|
315
|
-
const hooks_1 = __nccwpck_require__(
|
|
315
|
+
const hooks_1 = __nccwpck_require__(440);
|
|
316
316
|
Object.defineProperty(exports, "getCompilerHooks", {
|
|
317
317
|
enumerable: true,
|
|
318
318
|
get: function () {
|
package/dist/index.cjs
CHANGED
|
@@ -2251,14 +2251,14 @@ for(var __webpack_i__ in (()=>{
|
|
|
2251
2251
|
};
|
|
2252
2252
|
context.environments[name] = new Proxy(environmentContext, {
|
|
2253
2253
|
get: (target, prop)=>target[prop],
|
|
2254
|
-
set: (
|
|
2254
|
+
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : rslog_index_js_namespaceObject.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
|
|
2255
2255
|
});
|
|
2256
2256
|
}
|
|
2257
2257
|
}
|
|
2258
2258
|
async function createContext(options, userConfig) {
|
|
2259
2259
|
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;
|
|
2260
2260
|
return {
|
|
2261
|
-
version: "1.3.
|
|
2261
|
+
version: "1.3.15",
|
|
2262
2262
|
rootPath,
|
|
2263
2263
|
distPath: '',
|
|
2264
2264
|
cachePath,
|
|
@@ -2277,6 +2277,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2277
2277
|
onBeforeStartProdServer: createAsyncHook(),
|
|
2278
2278
|
onAfterCreateCompiler: createAsyncHook(),
|
|
2279
2279
|
onBeforeCreateCompiler: createAsyncHook(),
|
|
2280
|
+
modifyHTML: createEnvironmentAsyncHook(),
|
|
2280
2281
|
modifyHTMLTags: createEnvironmentAsyncHook(),
|
|
2281
2282
|
modifyRspackConfig: createEnvironmentAsyncHook(),
|
|
2282
2283
|
modifyBundlerChain: createEnvironmentAsyncHook(),
|
|
@@ -3060,8 +3061,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
3060
3061
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
3061
3062
|
}, 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);
|
|
3062
3063
|
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
3063
|
-
let logs = [];
|
|
3064
|
-
if (!
|
|
3064
|
+
let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
|
|
3065
|
+
if (!showTotal && !showDetail) return logs;
|
|
3065
3066
|
let formatAsset = async (asset, distPath, distFolder)=>{
|
|
3066
3067
|
let fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
3067
3068
|
return {
|
|
@@ -3075,7 +3076,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3075
3076
|
}, getAssets = async ()=>{
|
|
3076
3077
|
let distPath = stats.compilation.outputOptions.path;
|
|
3077
3078
|
if (!distPath) return [];
|
|
3078
|
-
let
|
|
3079
|
+
let filteredAssets = (stats.toJson({
|
|
3079
3080
|
all: !1,
|
|
3080
3081
|
assets: !0,
|
|
3081
3082
|
cachedAssets: !0,
|
|
@@ -3084,7 +3085,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3084
3085
|
groupAssetsByChunk: !1,
|
|
3085
3086
|
groupAssetsByExtension: !1,
|
|
3086
3087
|
groupAssetsByEmitStatus: !1
|
|
3087
|
-
})
|
|
3088
|
+
}).assets || []).filter((asset)=>{
|
|
3088
3089
|
let assetInfo = {
|
|
3089
3090
|
name: asset.name,
|
|
3090
3091
|
size: asset.size
|
|
@@ -3096,11 +3097,11 @@ for(var __webpack_i__ in (()=>{
|
|
|
3096
3097
|
if (0 === assets.length) return logs;
|
|
3097
3098
|
logs.push(''), assets.sort((a, b)=>a.size - b.size);
|
|
3098
3099
|
let totalSize = 0, totalGzipSize = 0;
|
|
3099
|
-
for (let asset of assets)totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
|
|
3100
|
-
let
|
|
3101
|
-
if (
|
|
3102
|
-
let showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
|
|
3103
|
-
logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
3100
|
+
for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
|
|
3101
|
+
let fileHeader = showDetail ? `File (${environmentName})` : '', totalSizeLabel = showTotal ? showDetail ? 'Total:' : `Total size (${environmentName}):` : '', totalSizeStr = showTotal ? calcFileSize(totalSize) : '';
|
|
3102
|
+
if (showDetail) {
|
|
3103
|
+
let maxFileLength = Math.max(...assets.map((a)=>(a.folder + external_node_path_default().sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
|
|
3104
|
+
for (let asset of (logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
3104
3105
|
let lengths = [
|
|
3105
3106
|
maxFileLength,
|
|
3106
3107
|
maxSizeLength
|
|
@@ -3111,29 +3112,29 @@ for(var __webpack_i__ in (()=>{
|
|
|
3111
3112
|
showGzipHeader && rowTypes.push('Gzip');
|
|
3112
3113
|
let headerRow = rowTypes.reduce((prev, cur, index)=>{
|
|
3113
3114
|
let length = lengths[index], curLabel = cur;
|
|
3114
|
-
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel}
|
|
3115
|
-
}, '
|
|
3115
|
+
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
|
|
3116
|
+
}, '');
|
|
3116
3117
|
return index_js_default().blue(headerRow);
|
|
3117
|
-
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader))
|
|
3118
|
-
|
|
3119
|
-
for (let asset of assets){
|
|
3120
|
-
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
|
|
3121
|
-
if (!1 !== options.detail) {
|
|
3118
|
+
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
|
|
3119
|
+
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
|
|
3122
3120
|
sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
|
|
3123
3121
|
let fileNameLabel = index_js_default().dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
|
|
3124
3122
|
fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
|
|
3125
|
-
let log =
|
|
3126
|
-
gzipSizeLabel && (log += `
|
|
3123
|
+
let log = `${fileNameLabel} ${sizeLabel}`;
|
|
3124
|
+
gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
|
|
3127
3125
|
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3126
|
+
if (showTotal) {
|
|
3127
|
+
logs.push('');
|
|
3128
|
+
let log = '';
|
|
3129
|
+
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
|
|
3130
|
+
let colorFn = getAssetColor(totalGzipSize / assets.length);
|
|
3131
|
+
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
|
|
3132
|
+
}
|
|
3133
|
+
logs.push(log);
|
|
3135
3134
|
}
|
|
3136
|
-
|
|
3135
|
+
} else if (showTotal) {
|
|
3136
|
+
let log = `${index_js_default().magenta(totalSizeLabel)} ${totalSizeStr}`;
|
|
3137
|
+
options.compressed && (log += index_js_default().green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
|
|
3137
3138
|
}
|
|
3138
3139
|
return logs.push(''), logs;
|
|
3139
3140
|
}
|
|
@@ -3156,7 +3157,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3156
3157
|
...defaultConfig,
|
|
3157
3158
|
...printFileSize
|
|
3158
3159
|
}, statsLogs = await printFileSizes(mergedConfig, multiStats[index], api.context.rootPath, environment.name);
|
|
3159
|
-
logs.
|
|
3160
|
+
logs.push(...statsLogs);
|
|
3160
3161
|
})).catch((err)=>{
|
|
3161
3162
|
rslog_index_js_namespaceObject.logger.warn('Failed to print file size.'), rslog_index_js_namespaceObject.logger.warn(err);
|
|
3162
3163
|
}), rslog_index_js_namespaceObject.logger.log(logs.join('\n'));
|
|
@@ -3299,7 +3300,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
3299
3300
|
href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
|
|
3300
3301
|
};
|
|
3301
3302
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3302
|
-
getHTMLPlugin().getCompilationHooks(compilation)
|
|
3303
|
+
let hooks = getHTMLPlugin().getCompilationHooks(compilation);
|
|
3304
|
+
hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
|
|
3303
3305
|
var _data_plugin_options, _data_plugin_options1;
|
|
3304
3306
|
let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
|
|
3305
3307
|
if (!entryName) return data;
|
|
@@ -3308,22 +3310,45 @@ for(var __webpack_i__ in (()=>{
|
|
|
3308
3310
|
let tags = {
|
|
3309
3311
|
headTags: headTags.map(formatBasicTag),
|
|
3310
3312
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
3311
|
-
},
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3313
|
+
}, context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTMLTags.callChain({
|
|
3314
|
+
environment: environment.name,
|
|
3315
|
+
args: [
|
|
3316
|
+
tags,
|
|
3317
|
+
{
|
|
3318
|
+
compiler,
|
|
3319
|
+
compilation,
|
|
3320
|
+
assetPrefix: data.publicPath,
|
|
3321
|
+
filename: data.outputName,
|
|
3322
|
+
environment
|
|
3323
|
+
}
|
|
3324
|
+
]
|
|
3325
|
+
});
|
|
3318
3326
|
return Object.assign(data, {
|
|
3319
3327
|
headTags: modified.headTags.map(fromBasicTag),
|
|
3320
3328
|
bodyTags: modified.bodyTags.map(fromBasicTag)
|
|
3321
3329
|
}), tagConfig && applyTagConfig(data, tagConfig, compilation.hash ?? '', entryName), data;
|
|
3330
|
+
}), hooks.beforeEmit.tapPromise(this.name, async (data)=>{
|
|
3331
|
+
let context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTML.callChain({
|
|
3332
|
+
environment: environment.name,
|
|
3333
|
+
args: [
|
|
3334
|
+
data.html,
|
|
3335
|
+
{
|
|
3336
|
+
compiler,
|
|
3337
|
+
compilation,
|
|
3338
|
+
filename: data.outputName,
|
|
3339
|
+
environment
|
|
3340
|
+
}
|
|
3341
|
+
]
|
|
3342
|
+
});
|
|
3343
|
+
return {
|
|
3344
|
+
...data,
|
|
3345
|
+
html: modified
|
|
3346
|
+
};
|
|
3322
3347
|
});
|
|
3323
3348
|
});
|
|
3324
3349
|
}
|
|
3325
|
-
constructor(options, getEnvironment,
|
|
3326
|
-
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "
|
|
3350
|
+
constructor(options, getEnvironment, getContext){
|
|
3351
|
+
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "getContext", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.getEnvironment = getEnvironment, this.getContext = getContext;
|
|
3327
3352
|
}
|
|
3328
3353
|
}
|
|
3329
3354
|
let getDefaultTemplateContent = (mountId)=>`<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`, existTemplatePath = new Set();
|
|
@@ -3358,7 +3383,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3358
3383
|
publicPath: !0,
|
|
3359
3384
|
tags
|
|
3360
3385
|
};
|
|
3361
|
-
}, pluginHtml = (
|
|
3386
|
+
}, pluginHtml = (context)=>({
|
|
3362
3387
|
name: 'rsbuild:html',
|
|
3363
3388
|
setup (api) {
|
|
3364
3389
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID, environment })=>{
|
|
@@ -3458,7 +3483,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3458
3483
|
}), chain.plugin('rsbuild-html-plugin').use(RsbuildHtmlPlugin, [
|
|
3459
3484
|
htmlInfoMap,
|
|
3460
3485
|
()=>environment,
|
|
3461
|
-
|
|
3486
|
+
()=>context
|
|
3462
3487
|
]), config.html) {
|
|
3463
3488
|
let { crossorigin } = config.html;
|
|
3464
3489
|
crossorigin && chain.output.crossOriginLoading(!0 === crossorigin ? 'anonymous' : crossorigin);
|
|
@@ -3585,7 +3610,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3585
3610
|
})(chunkGroup)).filter((name)=>!!name))
|
|
3586
3611
|
];
|
|
3587
3612
|
}
|
|
3588
|
-
let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
3613
|
+
let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)=>{
|
|
3589
3614
|
let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
|
|
3590
3615
|
if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
|
|
3591
3616
|
file,
|
|
@@ -3631,10 +3656,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
3631
3656
|
files,
|
|
3632
3657
|
manifestData
|
|
3633
3658
|
});
|
|
3634
|
-
if (isObject(generatedManifest)) return generatedManifest;
|
|
3659
|
+
if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
|
|
3635
3660
|
throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
|
|
3636
3661
|
}
|
|
3637
|
-
return manifestData;
|
|
3662
|
+
return environment.manifest = manifestData, manifestData;
|
|
3638
3663
|
}, pluginManifest = ()=>({
|
|
3639
3664
|
name: 'rsbuild:manifest',
|
|
3640
3665
|
setup (api) {
|
|
@@ -3658,7 +3683,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3658
3683
|
fileName: manifestOptions.filename,
|
|
3659
3684
|
filter,
|
|
3660
3685
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
3661
|
-
generate: generateManifest(htmlPaths, manifestOptions)
|
|
3686
|
+
generate: generateManifest(htmlPaths, manifestOptions, environment)
|
|
3662
3687
|
}
|
|
3663
3688
|
]);
|
|
3664
3689
|
});
|
|
@@ -3822,13 +3847,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3822
3847
|
if (routes.length <= 1) {
|
|
3823
3848
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
3824
3849
|
return urls.map(({ label, url })=>{
|
|
3825
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix =
|
|
3850
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${index_js_default().dim(label.padEnd(10))}`;
|
|
3826
3851
|
return ` ${prefix}${index_js_default().cyan(normalizedPathname)}\n`;
|
|
3827
3852
|
}).join('');
|
|
3828
3853
|
}
|
|
3829
3854
|
let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
3830
3855
|
return urls.forEach(({ label, url }, index)=>{
|
|
3831
|
-
for (let r of (index > 0 && (message += '\n'), message += `
|
|
3856
|
+
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${index_js_default().dim('-')} ${index_js_default().dim(r.entryName.padEnd(maxNameLength + 4))}${index_js_default().cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
|
|
3832
3857
|
}), message;
|
|
3833
3858
|
}(urls, routes);
|
|
3834
3859
|
return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), rslog_index_js_namespaceObject.logger.log(message), message;
|
|
@@ -4378,7 +4403,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4378
4403
|
if ('webpack' === api.context.bundlerType) return;
|
|
4379
4404
|
let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
|
|
4380
4405
|
if (!RSPACK_PROFILE) return;
|
|
4381
|
-
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'),
|
|
4406
|
+
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), onStart = async ()=>{
|
|
4382
4407
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName), traceFilePath = external_node_path_default().join(profileDir, 'trace.json');
|
|
4383
4408
|
await isFileExists(profileDir) || await external_node_fs_default().promises.mkdir(profileDir, {
|
|
4384
4409
|
recursive: !0
|
|
@@ -4386,17 +4411,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4386
4411
|
};
|
|
4387
4412
|
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
4388
4413
|
isFirstCompile && onStart();
|
|
4389
|
-
}), api.onBeforeStartDevServer(onStart), api.
|
|
4390
|
-
let loggingFilePath = external_node_path_default().join(api.context.distPath, profileDirName, 'logging.json');
|
|
4391
|
-
if (enableLogging && stats) {
|
|
4392
|
-
let logging = stats.toJson({
|
|
4393
|
-
all: !1,
|
|
4394
|
-
logging: 'verbose',
|
|
4395
|
-
loggingTrace: !0
|
|
4396
|
-
});
|
|
4397
|
-
await external_node_fs_default().promises.writeFile(loggingFilePath, JSON.stringify(logging));
|
|
4398
|
-
}
|
|
4399
|
-
}), api.onExit(()=>{
|
|
4414
|
+
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
4400
4415
|
enableProfileTrace && core_default().experiments.globalTrace.cleanup();
|
|
4401
4416
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName);
|
|
4402
4417
|
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`profile files saved to ${index_js_default().cyan(profileDir)}`);
|
|
@@ -5210,7 +5225,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5210
5225
|
}
|
|
5211
5226
|
].filter(Boolean);
|
|
5212
5227
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
|
|
5213
|
-
help && rslog_index_js_namespaceObject.logger.log(`
|
|
5228
|
+
help && rslog_index_js_namespaceObject.logger.log(` \u{279C} ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
|
|
5214
5229
|
let rl = external_node_readline_default().createInterface({
|
|
5215
5230
|
input: process.stdin
|
|
5216
5231
|
});
|
|
@@ -6741,10 +6756,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6741
6756
|
pluginFileSize(),
|
|
6742
6757
|
pluginCleanOutput(),
|
|
6743
6758
|
pluginAsset(),
|
|
6744
|
-
pluginHtml(
|
|
6745
|
-
environment,
|
|
6746
|
-
args
|
|
6747
|
-
}))[0]),
|
|
6759
|
+
pluginHtml(context),
|
|
6748
6760
|
pluginAppIcon(),
|
|
6749
6761
|
pluginWasm(),
|
|
6750
6762
|
pluginMoment(),
|
|
@@ -6995,7 +7007,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6995
7007
|
}
|
|
6996
7008
|
});
|
|
6997
7009
|
});
|
|
6998
|
-
let
|
|
7010
|
+
let getTransformHook = (environment)=>(descriptor, handler)=>{
|
|
6999
7011
|
let id = `rsbuild-transform-${transformId++}`;
|
|
7000
7012
|
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
7001
7013
|
environment,
|
|
@@ -7041,7 +7053,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7041
7053
|
return (environment)=>({
|
|
7042
7054
|
context: publicContext,
|
|
7043
7055
|
expose,
|
|
7044
|
-
transform:
|
|
7056
|
+
transform: getTransformHook(environment),
|
|
7045
7057
|
useExposed,
|
|
7046
7058
|
processAssets: setProcessAssets(environment),
|
|
7047
7059
|
resolve: setResolve(environment),
|
|
@@ -7061,6 +7073,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7061
7073
|
onAfterStartProdServer: hooks.onAfterStartProdServer.tap,
|
|
7062
7074
|
onBeforeStartProdServer: hooks.onBeforeStartProdServer.tap,
|
|
7063
7075
|
modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
|
|
7076
|
+
modifyHTML: (handler)=>hooks.modifyHTML.tapEnvironment({
|
|
7077
|
+
environment,
|
|
7078
|
+
handler
|
|
7079
|
+
}),
|
|
7064
7080
|
modifyHTMLTags: (handler)=>hooks.modifyHTMLTags.tapEnvironment({
|
|
7065
7081
|
environment,
|
|
7066
7082
|
handler
|
|
@@ -7507,11 +7523,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7507
7523
|
}
|
|
7508
7524
|
process.title = 'rsbuild-node';
|
|
7509
7525
|
let { npm_execpath } = process.env;
|
|
7510
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.
|
|
7526
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.15\n`);
|
|
7511
7527
|
try {
|
|
7512
7528
|
!function() {
|
|
7513
7529
|
let cli = cac_dist('rsbuild');
|
|
7514
|
-
cli.help(), cli.version("1.3.
|
|
7530
|
+
cli.help(), cli.version("1.3.15"), applyCommonOptions(cli);
|
|
7515
7531
|
let devCommand = cli.command('', 'starting the dev server').alias('dev'), 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');
|
|
7516
7532
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7517
7533
|
try {
|
|
@@ -7562,7 +7578,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7562
7578
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7563
7579
|
}
|
|
7564
7580
|
}
|
|
7565
|
-
let src_version = "1.3.
|
|
7581
|
+
let src_version = "1.3.15";
|
|
7566
7582
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
7567
7583
|
"PLUGIN_CSS_NAME",
|
|
7568
7584
|
"PLUGIN_SWC_NAME",
|
package/dist/index.js
CHANGED
|
@@ -2110,14 +2110,14 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2110
2110
|
};
|
|
2111
2111
|
context.environments[name] = new Proxy(environmentContext, {
|
|
2112
2112
|
get: (target, prop)=>target[prop],
|
|
2113
|
-
set: (
|
|
2113
|
+
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
|
|
2114
2114
|
});
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
2117
|
async function createContext(options, userConfig) {
|
|
2118
2118
|
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;
|
|
2119
2119
|
return {
|
|
2120
|
-
version: "1.3.
|
|
2120
|
+
version: "1.3.15",
|
|
2121
2121
|
rootPath,
|
|
2122
2122
|
distPath: '',
|
|
2123
2123
|
cachePath,
|
|
@@ -2136,6 +2136,7 @@ async function createContext(options, userConfig) {
|
|
|
2136
2136
|
onBeforeStartProdServer: createAsyncHook(),
|
|
2137
2137
|
onAfterCreateCompiler: createAsyncHook(),
|
|
2138
2138
|
onBeforeCreateCompiler: createAsyncHook(),
|
|
2139
|
+
modifyHTML: createEnvironmentAsyncHook(),
|
|
2139
2140
|
modifyHTMLTags: createEnvironmentAsyncHook(),
|
|
2140
2141
|
modifyRspackConfig: createEnvironmentAsyncHook(),
|
|
2141
2142
|
modifyBundlerChain: createEnvironmentAsyncHook(),
|
|
@@ -2916,8 +2917,8 @@ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset
|
|
|
2916
2917
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2917
2918
|
}, 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);
|
|
2918
2919
|
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
2919
|
-
let logs = [];
|
|
2920
|
-
if (!
|
|
2920
|
+
let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
|
|
2921
|
+
if (!showTotal && !showDetail) return logs;
|
|
2921
2922
|
let formatAsset = async (asset, distPath, distFolder)=>{
|
|
2922
2923
|
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 = Buffer.byteLength(contents), gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
|
|
2923
2924
|
return {
|
|
@@ -2931,7 +2932,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2931
2932
|
}, getAssets = async ()=>{
|
|
2932
2933
|
let distPath = stats.compilation.outputOptions.path;
|
|
2933
2934
|
if (!distPath) return [];
|
|
2934
|
-
let
|
|
2935
|
+
let filteredAssets = (stats.toJson({
|
|
2935
2936
|
all: !1,
|
|
2936
2937
|
assets: !0,
|
|
2937
2938
|
cachedAssets: !0,
|
|
@@ -2940,7 +2941,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2940
2941
|
groupAssetsByChunk: !1,
|
|
2941
2942
|
groupAssetsByExtension: !1,
|
|
2942
2943
|
groupAssetsByEmitStatus: !1
|
|
2943
|
-
})
|
|
2944
|
+
}).assets || []).filter((asset)=>{
|
|
2944
2945
|
let assetInfo = {
|
|
2945
2946
|
name: asset.name,
|
|
2946
2947
|
size: asset.size
|
|
@@ -2952,11 +2953,11 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2952
2953
|
if (0 === assets.length) return logs;
|
|
2953
2954
|
logs.push(''), assets.sort((a, b)=>a.size - b.size);
|
|
2954
2955
|
let totalSize = 0, totalGzipSize = 0;
|
|
2955
|
-
for (let asset of assets)totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
|
|
2956
|
-
let
|
|
2957
|
-
if (
|
|
2958
|
-
let showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
|
|
2959
|
-
logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
2956
|
+
for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
|
|
2957
|
+
let fileHeader = showDetail ? `File (${environmentName})` : '', totalSizeLabel = showTotal ? showDetail ? 'Total:' : `Total size (${environmentName}):` : '', totalSizeStr = showTotal ? calcFileSize(totalSize) : '';
|
|
2958
|
+
if (showDetail) {
|
|
2959
|
+
let maxFileLength = Math.max(...assets.map((a)=>(a.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
|
|
2960
|
+
for (let asset of (logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
2960
2961
|
let lengths = [
|
|
2961
2962
|
maxFileLength,
|
|
2962
2963
|
maxSizeLength
|
|
@@ -2967,29 +2968,29 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2967
2968
|
showGzipHeader && rowTypes.push('Gzip');
|
|
2968
2969
|
let headerRow = rowTypes.reduce((prev, cur, index)=>{
|
|
2969
2970
|
let length = lengths[index], curLabel = cur;
|
|
2970
|
-
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel}
|
|
2971
|
-
}, '
|
|
2971
|
+
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
|
|
2972
|
+
}, '');
|
|
2972
2973
|
return __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.blue(headerRow);
|
|
2973
|
-
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader))
|
|
2974
|
-
|
|
2975
|
-
for (let asset of assets){
|
|
2976
|
-
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
|
|
2977
|
-
if (!1 !== options.detail) {
|
|
2974
|
+
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
|
|
2975
|
+
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
|
|
2978
2976
|
sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
|
|
2979
2977
|
let fileNameLabel = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(asset.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep) + coloringAssetName(asset.name);
|
|
2980
2978
|
fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
|
|
2981
|
-
let log =
|
|
2982
|
-
gzipSizeLabel && (log += `
|
|
2979
|
+
let log = `${fileNameLabel} ${sizeLabel}`;
|
|
2980
|
+
gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
|
|
2983
2981
|
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2982
|
+
if (showTotal) {
|
|
2983
|
+
logs.push('');
|
|
2984
|
+
let log = '';
|
|
2985
|
+
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
|
|
2986
|
+
let colorFn = getAssetColor(totalGzipSize / assets.length);
|
|
2987
|
+
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
|
|
2988
|
+
}
|
|
2989
|
+
logs.push(log);
|
|
2991
2990
|
}
|
|
2992
|
-
|
|
2991
|
+
} else if (showTotal) {
|
|
2992
|
+
let log = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel)} ${totalSizeStr}`;
|
|
2993
|
+
options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
|
|
2993
2994
|
}
|
|
2994
2995
|
return logs.push(''), logs;
|
|
2995
2996
|
}
|
|
@@ -3012,7 +3013,7 @@ let pluginFileSize = ()=>({
|
|
|
3012
3013
|
...defaultConfig,
|
|
3013
3014
|
...printFileSize
|
|
3014
3015
|
}, statsLogs = await printFileSizes(mergedConfig, multiStats[index], api.context.rootPath, environment.name);
|
|
3015
|
-
logs.
|
|
3016
|
+
logs.push(...statsLogs);
|
|
3016
3017
|
})).catch((err)=>{
|
|
3017
3018
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('Failed to print file size.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(err);
|
|
3018
3019
|
}), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(logs.join('\n'));
|
|
@@ -3155,7 +3156,8 @@ class RsbuildHtmlPlugin {
|
|
|
3155
3156
|
href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
|
|
3156
3157
|
};
|
|
3157
3158
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3158
|
-
getHTMLPlugin().getCompilationHooks(compilation)
|
|
3159
|
+
let hooks = getHTMLPlugin().getCompilationHooks(compilation);
|
|
3160
|
+
hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
|
|
3159
3161
|
var _data_plugin_options, _data_plugin_options1;
|
|
3160
3162
|
let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
|
|
3161
3163
|
if (!entryName) return data;
|
|
@@ -3164,22 +3166,45 @@ class RsbuildHtmlPlugin {
|
|
|
3164
3166
|
let tags = {
|
|
3165
3167
|
headTags: headTags.map(formatBasicTag),
|
|
3166
3168
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
3167
|
-
},
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3169
|
+
}, context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTMLTags.callChain({
|
|
3170
|
+
environment: environment.name,
|
|
3171
|
+
args: [
|
|
3172
|
+
tags,
|
|
3173
|
+
{
|
|
3174
|
+
compiler,
|
|
3175
|
+
compilation,
|
|
3176
|
+
assetPrefix: data.publicPath,
|
|
3177
|
+
filename: data.outputName,
|
|
3178
|
+
environment
|
|
3179
|
+
}
|
|
3180
|
+
]
|
|
3181
|
+
});
|
|
3174
3182
|
return Object.assign(data, {
|
|
3175
3183
|
headTags: modified.headTags.map(fromBasicTag),
|
|
3176
3184
|
bodyTags: modified.bodyTags.map(fromBasicTag)
|
|
3177
3185
|
}), tagConfig && applyTagConfig(data, tagConfig, compilation.hash ?? '', entryName), data;
|
|
3186
|
+
}), hooks.beforeEmit.tapPromise(this.name, async (data)=>{
|
|
3187
|
+
let context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTML.callChain({
|
|
3188
|
+
environment: environment.name,
|
|
3189
|
+
args: [
|
|
3190
|
+
data.html,
|
|
3191
|
+
{
|
|
3192
|
+
compiler,
|
|
3193
|
+
compilation,
|
|
3194
|
+
filename: data.outputName,
|
|
3195
|
+
environment
|
|
3196
|
+
}
|
|
3197
|
+
]
|
|
3198
|
+
});
|
|
3199
|
+
return {
|
|
3200
|
+
...data,
|
|
3201
|
+
html: modified
|
|
3202
|
+
};
|
|
3178
3203
|
});
|
|
3179
3204
|
});
|
|
3180
3205
|
}
|
|
3181
|
-
constructor(options, getEnvironment,
|
|
3182
|
-
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "
|
|
3206
|
+
constructor(options, getEnvironment, getContext){
|
|
3207
|
+
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "getContext", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.getEnvironment = getEnvironment, this.getContext = getContext;
|
|
3183
3208
|
}
|
|
3184
3209
|
}
|
|
3185
3210
|
let getDefaultTemplateContent = (mountId)=>`<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`, existTemplatePath = new Set();
|
|
@@ -3214,7 +3239,7 @@ let getTagConfig = (config)=>{
|
|
|
3214
3239
|
publicPath: !0,
|
|
3215
3240
|
tags
|
|
3216
3241
|
};
|
|
3217
|
-
}, pluginHtml = (
|
|
3242
|
+
}, pluginHtml = (context)=>({
|
|
3218
3243
|
name: 'rsbuild:html',
|
|
3219
3244
|
setup (api) {
|
|
3220
3245
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID, environment })=>{
|
|
@@ -3313,7 +3338,7 @@ let getTagConfig = (config)=>{
|
|
|
3313
3338
|
}), chain.plugin('rsbuild-html-plugin').use(RsbuildHtmlPlugin, [
|
|
3314
3339
|
htmlInfoMap,
|
|
3315
3340
|
()=>environment,
|
|
3316
|
-
|
|
3341
|
+
()=>context
|
|
3317
3342
|
]), config.html) {
|
|
3318
3343
|
let { crossorigin } = config.html;
|
|
3319
3344
|
crossorigin && chain.output.crossOriginLoading(!0 === crossorigin ? 'anonymous' : crossorigin);
|
|
@@ -3440,7 +3465,7 @@ function recursiveChunkEntryNames(chunk) {
|
|
|
3440
3465
|
})(chunkGroup)).filter((name)=>!!name))
|
|
3441
3466
|
];
|
|
3442
3467
|
}
|
|
3443
|
-
let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
3468
|
+
let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)=>{
|
|
3444
3469
|
let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
|
|
3445
3470
|
if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
|
|
3446
3471
|
file,
|
|
@@ -3486,10 +3511,10 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
|
3486
3511
|
files,
|
|
3487
3512
|
manifestData
|
|
3488
3513
|
});
|
|
3489
|
-
if (isObject(generatedManifest)) return generatedManifest;
|
|
3514
|
+
if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
|
|
3490
3515
|
throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
|
|
3491
3516
|
}
|
|
3492
|
-
return manifestData;
|
|
3517
|
+
return environment.manifest = manifestData, manifestData;
|
|
3493
3518
|
}, pluginManifest = ()=>({
|
|
3494
3519
|
name: 'rsbuild:manifest',
|
|
3495
3520
|
setup (api) {
|
|
@@ -3513,7 +3538,7 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
|
3513
3538
|
fileName: manifestOptions.filename,
|
|
3514
3539
|
filter,
|
|
3515
3540
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
3516
|
-
generate: generateManifest(htmlPaths, manifestOptions)
|
|
3541
|
+
generate: generateManifest(htmlPaths, manifestOptions, environment)
|
|
3517
3542
|
}
|
|
3518
3543
|
]);
|
|
3519
3544
|
});
|
|
@@ -3674,13 +3699,13 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
|
|
|
3674
3699
|
if (routes.length <= 1) {
|
|
3675
3700
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
3676
3701
|
return urls.map(({ label, url })=>{
|
|
3677
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix =
|
|
3702
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(label.padEnd(10))}`;
|
|
3678
3703
|
return ` ${prefix}${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(normalizedPathname)}\n`;
|
|
3679
3704
|
}).join('');
|
|
3680
3705
|
}
|
|
3681
3706
|
let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
3682
3707
|
return urls.forEach(({ label, url }, index)=>{
|
|
3683
|
-
for (let r of (index > 0 && (message += '\n'), message += `
|
|
3708
|
+
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('-')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(r.entryName.padEnd(maxNameLength + 4))}${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
|
|
3684
3709
|
}), message;
|
|
3685
3710
|
}(urls, routes);
|
|
3686
3711
|
return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(message), message;
|
|
@@ -4228,7 +4253,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4228
4253
|
if ('webpack' === api.context.bundlerType) return;
|
|
4229
4254
|
let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
|
|
4230
4255
|
if (!RSPACK_PROFILE) return;
|
|
4231
|
-
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'),
|
|
4256
|
+
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), onStart = async ()=>{
|
|
4232
4257
|
let profileDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName), traceFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'trace.json');
|
|
4233
4258
|
await isFileExists(profileDir) || await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(profileDir, {
|
|
4234
4259
|
recursive: !0
|
|
@@ -4236,17 +4261,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4236
4261
|
};
|
|
4237
4262
|
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
4238
4263
|
isFirstCompile && onStart();
|
|
4239
|
-
}), api.onBeforeStartDevServer(onStart), api.
|
|
4240
|
-
let loggingFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName, 'logging.json');
|
|
4241
|
-
if (enableLogging && stats) {
|
|
4242
|
-
let logging = stats.toJson({
|
|
4243
|
-
all: !1,
|
|
4244
|
-
logging: 'verbose',
|
|
4245
|
-
loggingTrace: !0
|
|
4246
|
-
});
|
|
4247
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(loggingFilePath, JSON.stringify(logging));
|
|
4248
|
-
}
|
|
4249
|
-
}), api.onExit(()=>{
|
|
4264
|
+
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
4250
4265
|
enableProfileTrace && __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.globalTrace.cleanup();
|
|
4251
4266
|
let profileDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName);
|
|
4252
4267
|
stopProfiler(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'jscpuprofile.json'), profileSession), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`profile files saved to ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(profileDir)}`);
|
|
@@ -5054,7 +5069,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
|
|
|
5054
5069
|
}
|
|
5055
5070
|
].filter(Boolean);
|
|
5056
5071
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
|
|
5057
|
-
help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(`
|
|
5072
|
+
help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(` \u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('press')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold('h + enter')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('to show shortcuts')}\n`);
|
|
5058
5073
|
let rl = __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__.default.createInterface({
|
|
5059
5074
|
input: process.stdin
|
|
5060
5075
|
});
|
|
@@ -6578,10 +6593,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6578
6593
|
pluginFileSize(),
|
|
6579
6594
|
pluginCleanOutput(),
|
|
6580
6595
|
pluginAsset(),
|
|
6581
|
-
pluginHtml(
|
|
6582
|
-
environment,
|
|
6583
|
-
args
|
|
6584
|
-
}))[0]),
|
|
6596
|
+
pluginHtml(context),
|
|
6585
6597
|
pluginAppIcon(),
|
|
6586
6598
|
pluginWasm(),
|
|
6587
6599
|
pluginMoment(),
|
|
@@ -6831,7 +6843,7 @@ async function createRsbuild(options = {}) {
|
|
|
6831
6843
|
}
|
|
6832
6844
|
});
|
|
6833
6845
|
});
|
|
6834
|
-
let
|
|
6846
|
+
let getTransformHook = (environment)=>(descriptor, handler)=>{
|
|
6835
6847
|
let id = `rsbuild-transform-${transformId++}`;
|
|
6836
6848
|
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
6837
6849
|
environment,
|
|
@@ -6877,7 +6889,7 @@ async function createRsbuild(options = {}) {
|
|
|
6877
6889
|
return (environment)=>({
|
|
6878
6890
|
context: publicContext,
|
|
6879
6891
|
expose,
|
|
6880
|
-
transform:
|
|
6892
|
+
transform: getTransformHook(environment),
|
|
6881
6893
|
useExposed,
|
|
6882
6894
|
processAssets: setProcessAssets(environment),
|
|
6883
6895
|
resolve: setResolve(environment),
|
|
@@ -6897,6 +6909,10 @@ async function createRsbuild(options = {}) {
|
|
|
6897
6909
|
onAfterStartProdServer: hooks.onAfterStartProdServer.tap,
|
|
6898
6910
|
onBeforeStartProdServer: hooks.onBeforeStartProdServer.tap,
|
|
6899
6911
|
modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
|
|
6912
|
+
modifyHTML: (handler)=>hooks.modifyHTML.tapEnvironment({
|
|
6913
|
+
environment,
|
|
6914
|
+
handler
|
|
6915
|
+
}),
|
|
6900
6916
|
modifyHTMLTags: (handler)=>hooks.modifyHTMLTags.tapEnvironment({
|
|
6901
6917
|
environment,
|
|
6902
6918
|
handler
|
|
@@ -7342,11 +7358,11 @@ async function runCLI() {
|
|
|
7342
7358
|
}
|
|
7343
7359
|
process.title = 'rsbuild-node';
|
|
7344
7360
|
let { npm_execpath } = process.env;
|
|
7345
|
-
(!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.3.
|
|
7361
|
+
(!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.3.15\n`);
|
|
7346
7362
|
try {
|
|
7347
7363
|
!function() {
|
|
7348
7364
|
let cli = cac_dist('rsbuild');
|
|
7349
|
-
cli.help(), cli.version("1.3.
|
|
7365
|
+
cli.help(), cli.version("1.3.15"), applyCommonOptions(cli);
|
|
7350
7366
|
let devCommand = cli.command('', 'starting the dev server').alias('dev'), 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');
|
|
7351
7367
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7352
7368
|
try {
|
|
@@ -7397,6 +7413,6 @@ async function runCLI() {
|
|
|
7397
7413
|
__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);
|
|
7398
7414
|
}
|
|
7399
7415
|
}
|
|
7400
|
-
let src_version = "1.3.
|
|
7416
|
+
let src_version = "1.3.15";
|
|
7401
7417
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7402
7418
|
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 };
|
package/dist-types/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
|
|
1
|
+
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
|
|
2
2
|
export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
|
|
3
3
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
4
4
|
export declare function initHooks(): {
|
|
@@ -16,6 +16,7 @@ export declare function initHooks(): {
|
|
|
16
16
|
onAfterCreateCompiler: AsyncHook<OnAfterCreateCompilerFn>;
|
|
17
17
|
onBeforeCreateCompiler: AsyncHook<OnBeforeCreateCompilerFn>;
|
|
18
18
|
/** The following hooks are related to the environment */
|
|
19
|
+
modifyHTML: EnvironmentAsyncHook<ModifyHTMLFn>;
|
|
19
20
|
modifyHTMLTags: EnvironmentAsyncHook<ModifyHTMLTagsFn>;
|
|
20
21
|
modifyRspackConfig: EnvironmentAsyncHook<ModifyRspackConfigFn>;
|
|
21
22
|
modifyBundlerChain: EnvironmentAsyncHook<ModifyBundlerChainFn>;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ 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, 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, 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, ResourceHintsIncludeType, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig,
|
|
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, ModifyHTMLContext, ModifyHTMLFn, 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, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProcessAssetsDescriptor, ProcessAssetsHook, ProcessAssetsHandler, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolveHook, ResolveHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ResourceHintsIncludeType, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformHook, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
19
19
|
export type { ChainIdentifier } from './configChain';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
21
21
|
export type { StartServerResult } from './server/helper';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InternalContext, NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
2
2
|
export declare function getTemplate(entryName: string, config: NormalizedEnvironmentConfig, rootPath: string): Promise<{
|
|
3
3
|
templatePath: string;
|
|
4
4
|
templateContent?: string;
|
|
@@ -6,4 +6,4 @@ export declare function getTemplate(entryName: string, config: NormalizedEnviron
|
|
|
6
6
|
templatePath: undefined;
|
|
7
7
|
templateContent: string;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const pluginHtml: (
|
|
9
|
+
export declare const pluginHtml: (context: InternalContext) => RsbuildPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type { HtmlRspackPlugin } from '../types';
|
|
3
|
-
import type { EnvironmentContext, HtmlTag, HtmlTagDescriptor
|
|
2
|
+
import type { HtmlRspackPlugin, InternalContext } from '../types';
|
|
3
|
+
import type { EnvironmentContext, HtmlTag, HtmlTagDescriptor } from '../types';
|
|
4
4
|
type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject;
|
|
5
5
|
export type TagConfig = {
|
|
6
6
|
tags?: HtmlTagDescriptor[];
|
|
@@ -30,8 +30,8 @@ export declare class RsbuildHtmlPlugin {
|
|
|
30
30
|
readonly name: string;
|
|
31
31
|
readonly getEnvironment: () => EnvironmentContext;
|
|
32
32
|
readonly options: RsbuildHtmlPluginOptions;
|
|
33
|
-
readonly
|
|
34
|
-
constructor(options: RsbuildHtmlPluginOptions, getEnvironment: () => EnvironmentContext,
|
|
33
|
+
readonly getContext: () => InternalContext;
|
|
34
|
+
constructor(options: RsbuildHtmlPluginOptions, getEnvironment: () => EnvironmentContext, getContext: () => InternalContext);
|
|
35
35
|
apply(compiler: Compiler): void;
|
|
36
36
|
}
|
|
37
37
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { rspack } from '@rspack/core';
|
|
2
|
-
import type { ChainIdentifier } from '..';
|
|
2
|
+
import type { ChainIdentifier, ManifestData } from '..';
|
|
3
3
|
import type RspackChain from '../../compiled/rspack-chain';
|
|
4
4
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
5
5
|
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
@@ -70,11 +70,7 @@ export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCom
|
|
|
70
70
|
export type OnExitFn = (context: {
|
|
71
71
|
exitCode: number;
|
|
72
72
|
}) => void;
|
|
73
|
-
type
|
|
74
|
-
headTags: HtmlBasicTag[];
|
|
75
|
-
bodyTags: HtmlBasicTag[];
|
|
76
|
-
};
|
|
77
|
-
export type ModifyHTMLTagsContext = {
|
|
73
|
+
export type ModifyHTMLContext = {
|
|
78
74
|
/**
|
|
79
75
|
* The Compilation object of Rspack.
|
|
80
76
|
*/
|
|
@@ -83,11 +79,6 @@ export type ModifyHTMLTagsContext = {
|
|
|
83
79
|
* The Compiler object of Rspack.
|
|
84
80
|
*/
|
|
85
81
|
compiler: Rspack.Compiler;
|
|
86
|
-
/**
|
|
87
|
-
* URL prefix of assets.
|
|
88
|
-
* @example 'https://example.com/'
|
|
89
|
-
*/
|
|
90
|
-
assetPrefix: string;
|
|
91
82
|
/**
|
|
92
83
|
* The name of the HTML file, relative to the dist directory.
|
|
93
84
|
* @example 'index.html'
|
|
@@ -98,6 +89,18 @@ export type ModifyHTMLTagsContext = {
|
|
|
98
89
|
*/
|
|
99
90
|
environment: EnvironmentContext;
|
|
100
91
|
};
|
|
92
|
+
export type ModifyHTMLFn = (html: string, context: ModifyHTMLContext) => MaybePromise<string>;
|
|
93
|
+
type HTMLTags = {
|
|
94
|
+
headTags: HtmlBasicTag[];
|
|
95
|
+
bodyTags: HtmlBasicTag[];
|
|
96
|
+
};
|
|
97
|
+
export type ModifyHTMLTagsContext = Pick<ModifyHTMLContext, 'compilation' | 'compiler' | 'filename' | 'environment'> & {
|
|
98
|
+
/**
|
|
99
|
+
* URL prefix of assets.
|
|
100
|
+
* @example 'https://example.com/'
|
|
101
|
+
*/
|
|
102
|
+
assetPrefix: string;
|
|
103
|
+
};
|
|
101
104
|
export type ModifyHTMLTagsFn = (tags: HTMLTags, context: ModifyHTMLTagsContext) => MaybePromise<HTMLTags>;
|
|
102
105
|
export type ModifyRsbuildConfigUtils = {
|
|
103
106
|
/** Merge multiple Rsbuild config objects into one. */
|
|
@@ -147,6 +150,13 @@ export type EnvironmentContext = {
|
|
|
147
150
|
* The normalized Rsbuild config for the current environment.
|
|
148
151
|
*/
|
|
149
152
|
config: NormalizedEnvironmentConfig;
|
|
153
|
+
/**
|
|
154
|
+
* Manifest data. Only available when:
|
|
155
|
+
* - The `output.manifest` config is enabled
|
|
156
|
+
* - The build has completed, accessible in hooks like `onAfterBuild`,
|
|
157
|
+
* `onDevCompileDone` and `onAfterEnvironmentCompile`
|
|
158
|
+
*/
|
|
159
|
+
manifest?: Record<string, unknown> | ManifestData;
|
|
150
160
|
};
|
|
151
161
|
export type ModifyChainUtils = {
|
|
152
162
|
/**
|
|
@@ -4,7 +4,7 @@ import type RspackChain from '../../compiled/rspack-chain';
|
|
|
4
4
|
import type { ChainIdentifier } from '../configChain';
|
|
5
5
|
import type { ModifyRspackConfigUtils, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig, WebpackMerge } from './config';
|
|
6
6
|
import type { RsbuildContext } from './context';
|
|
7
|
-
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from './hooks';
|
|
7
|
+
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from './hooks';
|
|
8
8
|
import type { RsbuildInstance, RsbuildTarget } from './rsbuild';
|
|
9
9
|
import type { Rspack } from './rspack';
|
|
10
10
|
import type { HtmlRspackPlugin } from './thirdParty';
|
|
@@ -285,7 +285,7 @@ export type TransformDescriptor = {
|
|
|
285
285
|
*/
|
|
286
286
|
with?: Record<string, Rspack.RuleSetCondition>;
|
|
287
287
|
};
|
|
288
|
-
export type
|
|
288
|
+
export type TransformHook = (descriptor: TransformDescriptor, handler: TransformHandler) => void;
|
|
289
289
|
export type ProcessAssetsStage = 'additional' | 'pre-process' | 'derived' | 'additions' | 'none' | 'optimize' | 'optimize-count' | 'optimize-compatibility' | 'optimize-size' | 'dev-tooling' | 'optimize-inline' | 'summarize' | 'optimize-hash' | 'optimize-transfer' | 'analyse' | 'report';
|
|
290
290
|
export type ProcessAssetsDescriptor = {
|
|
291
291
|
/**
|
|
@@ -325,8 +325,8 @@ export type ResolveHandler = (context: {
|
|
|
325
325
|
compiler: Rspack.Compiler;
|
|
326
326
|
compilation: Rspack.Compilation;
|
|
327
327
|
}) => Promise<void> | void;
|
|
328
|
-
export type
|
|
329
|
-
export type
|
|
328
|
+
export type ResolveHook = (handler: ResolveHandler) => void;
|
|
329
|
+
export type ProcessAssetsHook = (descriptor: ProcessAssetsDescriptor, handler: ProcessAssetsHandler) => void;
|
|
330
330
|
declare function getNormalizedConfig(): NormalizedConfig;
|
|
331
331
|
declare function getNormalizedConfig(options: {
|
|
332
332
|
environment: string;
|
|
@@ -374,8 +374,16 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
374
374
|
* Modify the Rsbuild configuration of a specific environment.
|
|
375
375
|
*/
|
|
376
376
|
modifyEnvironmentConfig: PluginHook<ModifyEnvironmentConfigFn>;
|
|
377
|
+
/**
|
|
378
|
+
* Modify the final HTML content. The hook receives a HTML string
|
|
379
|
+
* and a context object, and you can return a new HTML string to
|
|
380
|
+
* replace the original one. This hook is triggered after the
|
|
381
|
+
* `modifyHTMLTags` hook.
|
|
382
|
+
*/
|
|
383
|
+
modifyHTML: PluginHook<ModifyHTMLFn>;
|
|
377
384
|
/**
|
|
378
385
|
* Modify the tags that are injected into the HTML.
|
|
386
|
+
* This hook is triggered before the `modifyHTML` hook.
|
|
379
387
|
*/
|
|
380
388
|
modifyHTMLTags: PluginHook<ModifyHTMLTagsFn>;
|
|
381
389
|
/**
|
|
@@ -473,16 +481,19 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
473
481
|
* Modify assets before emitting, the same as Rspack's
|
|
474
482
|
* [compilation.hooks.processAssets](https://rspack.dev/api/plugin-api/compilation-hooks#processassets) hook.
|
|
475
483
|
*/
|
|
476
|
-
processAssets:
|
|
484
|
+
processAssets: ProcessAssetsHook;
|
|
477
485
|
/**
|
|
478
486
|
* Intercept and modify module request information before module resolution begins.
|
|
479
487
|
* The same as Rspack's [normalModuleFactory.hooks.resolve](https://rspack.dev/api/plugin-api/normal-module-factory-hooks#resolve) hook.
|
|
480
488
|
*/
|
|
481
|
-
resolve:
|
|
489
|
+
resolve: ResolveHook;
|
|
482
490
|
/**
|
|
483
|
-
*
|
|
491
|
+
* A simplified wrapper around Rspack loaders, `api.transform` lets you
|
|
492
|
+
* easily transform the code of specific modules during the build process.
|
|
493
|
+
* You can match files by module path, query, or other conditions, and
|
|
494
|
+
* apply custom transformations to their contents.
|
|
484
495
|
*/
|
|
485
|
-
transform:
|
|
496
|
+
transform: TransformHook;
|
|
486
497
|
/**
|
|
487
498
|
* Get the properties or methods exposed by other plugins.
|
|
488
499
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.15",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.3.
|
|
49
|
+
"@rspack/core": "1.3.8",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
|
-
"core-js": "~3.
|
|
52
|
+
"core-js": "~3.42.0",
|
|
53
53
|
"jiti": "^2.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.6.
|
|
56
|
+
"@rslib/core": "0.6.8",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.17",
|
|
59
|
-
"@types/node": "^22.15.
|
|
59
|
+
"@types/node": "^22.15.3",
|
|
60
60
|
"@types/on-finished": "2.3.4",
|
|
61
61
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|