@rsbuild/core 1.2.7 → 1.2.9
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/README.md +10 -2
- package/compiled/css-loader/index.js +41 -41
- package/compiled/postcss/index.js +107 -105
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- 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 +149 -106
- package/dist/index.js +149 -106
- package/dist-types/createRsbuild.d.ts +3 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +3 -3
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +2 -2
- package/dist-types/server/devServer.d.ts +11 -6
- package/dist-types/server/getDevMiddlewares.d.ts +7 -2
- package/dist-types/server/runner/basic.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +6 -4
- package/dist-types/server/runner/type.d.ts +7 -1
- package/dist-types/server/watchFiles.d.ts +3 -2
- package/dist-types/types/config.d.ts +11 -3
- package/dist-types/types/hooks.d.ts +9 -1
- package/dist-types/types/plugin.d.ts +201 -74
- package/dist-types/types/rsbuild.d.ts +96 -29
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -519,38 +519,39 @@ function formatMessage(stats, verbose) {
|
|
|
519
519
|
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (message = hintNodePolyfill(message = function(message) {
|
|
520
520
|
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
521
521
|
if (-1 === message.indexOf(hint)) return message;
|
|
522
|
+
let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`@rsbuild/plugin-${packageName}`)}" ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(`(https://www.npmjs.com/package/@rsbuild/plugin-${packageName})`)}.`;
|
|
522
523
|
for (let plugin of [
|
|
523
524
|
{
|
|
524
525
|
test: /File: .+\.s(c|a)ss/,
|
|
525
|
-
hint:
|
|
526
|
+
hint: createPluginHint('sass', 'Sass')
|
|
526
527
|
},
|
|
527
528
|
{
|
|
528
529
|
test: /File: .+\.less/,
|
|
529
|
-
hint:
|
|
530
|
+
hint: createPluginHint('less', 'Less')
|
|
530
531
|
},
|
|
531
532
|
{
|
|
532
533
|
test: /File: .+\.styl(us)?/,
|
|
533
|
-
hint:
|
|
534
|
+
hint: createPluginHint('stylus', 'Stylus')
|
|
534
535
|
},
|
|
535
536
|
{
|
|
536
537
|
test: /File: .+\.vue?/,
|
|
537
|
-
hint:
|
|
538
|
+
hint: createPluginHint('vue', 'Vue')
|
|
538
539
|
},
|
|
539
540
|
{
|
|
540
541
|
test: /File: .+\.svelte?/,
|
|
541
|
-
hint:
|
|
542
|
+
hint: createPluginHint('svelte', 'Svelte')
|
|
542
543
|
},
|
|
543
544
|
{
|
|
544
545
|
test: /File: .+\.mdx/,
|
|
545
|
-
hint:
|
|
546
|
+
hint: createPluginHint('mdx', 'MDX')
|
|
546
547
|
},
|
|
547
548
|
{
|
|
548
549
|
test: /File: .+\.toml/,
|
|
549
|
-
hint:
|
|
550
|
+
hint: createPluginHint('toml', 'TOML')
|
|
550
551
|
},
|
|
551
552
|
{
|
|
552
553
|
test: /File: .+\.yaml/,
|
|
553
|
-
hint:
|
|
554
|
+
hint: createPluginHint('yaml', 'YAML')
|
|
554
555
|
}
|
|
555
556
|
])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
|
|
556
557
|
return message;
|
|
@@ -1343,7 +1344,7 @@ function createEnvironmentAsyncHook() {
|
|
|
1343
1344
|
tap: (handler)=>tapEnvironment({
|
|
1344
1345
|
handler
|
|
1345
1346
|
}),
|
|
1346
|
-
|
|
1347
|
+
callChain: async ({ environment, args: params })=>{
|
|
1347
1348
|
for (let callback of [
|
|
1348
1349
|
...preGroup,
|
|
1349
1350
|
...defaultGroup,
|
|
@@ -1354,6 +1355,19 @@ function createEnvironmentAsyncHook() {
|
|
|
1354
1355
|
void 0 !== result && (params[0] = result);
|
|
1355
1356
|
}
|
|
1356
1357
|
return params;
|
|
1358
|
+
},
|
|
1359
|
+
callBatch: async ({ environment, args: params })=>{
|
|
1360
|
+
let results = [];
|
|
1361
|
+
for (let callback of [
|
|
1362
|
+
...preGroup,
|
|
1363
|
+
...defaultGroup,
|
|
1364
|
+
...postGroup
|
|
1365
|
+
]){
|
|
1366
|
+
if (callback.environment && environment && !isPluginMatchEnvironment(callback.environment, environment)) continue;
|
|
1367
|
+
let result = await callback.handler(...params);
|
|
1368
|
+
results.push(result);
|
|
1369
|
+
}
|
|
1370
|
+
return results;
|
|
1357
1371
|
}
|
|
1358
1372
|
};
|
|
1359
1373
|
}
|
|
@@ -1363,7 +1377,7 @@ function createAsyncHook() {
|
|
|
1363
1377
|
tap: (cb)=>{
|
|
1364
1378
|
isFunction(cb) ? defaultGroup.push(cb) : 'pre' === cb.order ? preGroup.push(cb.handler) : 'post' === cb.order ? postGroup.push(cb.handler) : defaultGroup.push(cb.handler);
|
|
1365
1379
|
},
|
|
1366
|
-
|
|
1380
|
+
callChain: async (...params)=>{
|
|
1367
1381
|
for (let callback of [
|
|
1368
1382
|
...preGroup,
|
|
1369
1383
|
...defaultGroup,
|
|
@@ -1373,6 +1387,18 @@ function createAsyncHook() {
|
|
|
1373
1387
|
void 0 !== result && (params[0] = result);
|
|
1374
1388
|
}
|
|
1375
1389
|
return params;
|
|
1390
|
+
},
|
|
1391
|
+
callBatch: async (...params)=>{
|
|
1392
|
+
let results = [];
|
|
1393
|
+
for (let callback of [
|
|
1394
|
+
...preGroup,
|
|
1395
|
+
...defaultGroup,
|
|
1396
|
+
...postGroup
|
|
1397
|
+
]){
|
|
1398
|
+
let result = await callback(...params);
|
|
1399
|
+
results.push(result);
|
|
1400
|
+
}
|
|
1401
|
+
return results;
|
|
1376
1402
|
}
|
|
1377
1403
|
};
|
|
1378
1404
|
}
|
|
@@ -1410,7 +1436,7 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
|
|
|
1410
1436
|
});
|
|
1411
1437
|
}, registerBuildHook = ({ context, isWatch, compiler, bundlerConfigs, MultiStatsCtor })=>{
|
|
1412
1438
|
let isFirstCompile = !0, environmentList = Object.values(context.environments).reduce((prev, curr)=>(prev[curr.index] = curr, prev), []), onDone = async (stats)=>{
|
|
1413
|
-
let p = context.hooks.onAfterBuild.
|
|
1439
|
+
let p = context.hooks.onAfterBuild.callBatch({
|
|
1414
1440
|
isFirstCompile,
|
|
1415
1441
|
stats,
|
|
1416
1442
|
environments: context.environments,
|
|
@@ -1418,7 +1444,7 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
|
|
|
1418
1444
|
});
|
|
1419
1445
|
isFirstCompile = !1, await p;
|
|
1420
1446
|
}, onEnvironmentDone = async (buildIndex, stats)=>{
|
|
1421
|
-
await context.hooks.onAfterEnvironmentCompile.
|
|
1447
|
+
await context.hooks.onAfterEnvironmentCompile.callBatch({
|
|
1422
1448
|
environment: environmentList[buildIndex].name,
|
|
1423
1449
|
args: [
|
|
1424
1450
|
{
|
|
@@ -1432,13 +1458,13 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
|
|
|
1432
1458
|
};
|
|
1433
1459
|
onBeforeCompile({
|
|
1434
1460
|
compiler,
|
|
1435
|
-
beforeCompile: async ()=>await context.hooks.onBeforeBuild.
|
|
1461
|
+
beforeCompile: async ()=>await context.hooks.onBeforeBuild.callBatch({
|
|
1436
1462
|
bundlerConfigs,
|
|
1437
1463
|
environments: context.environments,
|
|
1438
1464
|
isWatch,
|
|
1439
1465
|
isFirstCompile
|
|
1440
1466
|
}),
|
|
1441
|
-
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.
|
|
1467
|
+
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
1442
1468
|
environment: environmentList[buildIndex].name,
|
|
1443
1469
|
args: [
|
|
1444
1470
|
{
|
|
@@ -1458,14 +1484,14 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
|
|
|
1458
1484
|
});
|
|
1459
1485
|
}, registerDevHook = ({ context, compiler, bundlerConfigs, MultiStatsCtor })=>{
|
|
1460
1486
|
let isFirstCompile = !0, environmentList = Object.values(context.environments).reduce((prev, curr)=>(prev[curr.index] = curr, prev), []), onDone = async (stats)=>{
|
|
1461
|
-
let p = context.hooks.onDevCompileDone.
|
|
1487
|
+
let p = context.hooks.onDevCompileDone.callBatch({
|
|
1462
1488
|
isFirstCompile,
|
|
1463
1489
|
stats,
|
|
1464
1490
|
environments: context.environments
|
|
1465
1491
|
});
|
|
1466
1492
|
isFirstCompile = !1, await p;
|
|
1467
1493
|
}, onEnvironmentDone = async (buildIndex, stats)=>{
|
|
1468
|
-
await context.hooks.onAfterEnvironmentCompile.
|
|
1494
|
+
await context.hooks.onAfterEnvironmentCompile.callBatch({
|
|
1469
1495
|
environment: environmentList[buildIndex].name,
|
|
1470
1496
|
args: [
|
|
1471
1497
|
{
|
|
@@ -1479,7 +1505,7 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
|
|
|
1479
1505
|
};
|
|
1480
1506
|
onBeforeCompile({
|
|
1481
1507
|
compiler,
|
|
1482
|
-
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.
|
|
1508
|
+
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
1483
1509
|
environment: environmentList[buildIndex].name,
|
|
1484
1510
|
args: [
|
|
1485
1511
|
{
|
|
@@ -1617,7 +1643,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
1617
1643
|
async function createContext(options, userConfig, bundlerType) {
|
|
1618
1644
|
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;
|
|
1619
1645
|
return {
|
|
1620
|
-
version: "1.2.
|
|
1646
|
+
version: "1.2.9",
|
|
1621
1647
|
rootPath,
|
|
1622
1648
|
distPath: '',
|
|
1623
1649
|
cachePath,
|
|
@@ -1750,7 +1776,7 @@ let pluginAppIcon = ()=>({
|
|
|
1750
1776
|
async function modifyBundlerChain(context, utils) {
|
|
1751
1777
|
var _utils_environment_config_tools;
|
|
1752
1778
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify bundler chain');
|
|
1753
|
-
let bundlerChain = new __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.
|
|
1779
|
+
let bundlerChain = new __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
|
|
1754
1780
|
environment: utils.environment.name,
|
|
1755
1781
|
args: [
|
|
1756
1782
|
bundlerChain,
|
|
@@ -1944,7 +1970,7 @@ async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
|
1944
1970
|
recursive: !0
|
|
1945
1971
|
}), await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(configFile, JSON.stringify(buildDependencies));
|
|
1946
1972
|
}
|
|
1947
|
-
async function getBuildDependencies(context, config, environmentContext) {
|
|
1973
|
+
async function getBuildDependencies(context, config, environmentContext, userBuildDependencies) {
|
|
1948
1974
|
var _config__privateMeta;
|
|
1949
1975
|
let rootPackageJson = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, 'package.json'), browserslistConfig = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
|
|
1950
1976
|
await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
|
|
@@ -1966,7 +1992,10 @@ async function getBuildDependencies(context, config, environmentContext) {
|
|
|
1966
1992
|
].map((ext)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, `tailwind.config.${ext}`)));
|
|
1967
1993
|
return tailwindConfig && (buildDependencies.tailwindcss = [
|
|
1968
1994
|
tailwindConfig
|
|
1969
|
-
]),
|
|
1995
|
+
]), {
|
|
1996
|
+
...buildDependencies,
|
|
1997
|
+
...userBuildDependencies
|
|
1998
|
+
};
|
|
1970
1999
|
}
|
|
1971
2000
|
let pluginCache = ()=>({
|
|
1972
2001
|
name: 'rsbuild:cache',
|
|
@@ -1979,7 +2008,9 @@ let pluginCache = ()=>({
|
|
|
1979
2008
|
cacheEnabled = !0;
|
|
1980
2009
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
1981
2010
|
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);
|
|
1982
|
-
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment
|
|
2011
|
+
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment, cacheConfig.buildDependencies ? {
|
|
2012
|
+
userBuildDependencies: cacheConfig.buildDependencies
|
|
2013
|
+
} : {});
|
|
1983
2014
|
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
1984
2015
|
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
2016
|
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
@@ -2271,7 +2302,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2271
2302
|
async function gzipSize(input) {
|
|
2272
2303
|
return (await fileSize_gzip(input)).length;
|
|
2273
2304
|
}
|
|
2274
|
-
let
|
|
2305
|
+
let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.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)=>{
|
|
2275
2306
|
let val = len / 1000;
|
|
2276
2307
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2277
2308
|
}, 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);
|
|
@@ -2330,7 +2361,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2330
2361
|
let totalSize = 0, totalGzipSize = 0;
|
|
2331
2362
|
for (let asset of assets){
|
|
2332
2363
|
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
|
|
2333
|
-
if (totalSize += asset.size,
|
|
2364
|
+
if (totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size), !1 !== options.detail) {
|
|
2334
2365
|
sizeLength < longestLabelLength && (sizeLabel += ' '.repeat(longestLabelLength - sizeLength));
|
|
2335
2366
|
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);
|
|
2336
2367
|
fileNameLength < longestFileLength && (fileNameLabel += ' '.repeat(longestFileLength - fileNameLength));
|
|
@@ -3277,7 +3308,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
|
|
|
3277
3308
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, isProd, isServer, environment })=>{
|
|
3278
3309
|
let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
|
|
3279
3310
|
var _context_devServer, _context_devServer1, _context_devServer2;
|
|
3280
|
-
let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX, port = (null === (_context_devServer = context.devServer) || void 0 === _context_devServer ? void 0 : _context_devServer.port) || 3000;
|
|
3311
|
+
let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX, port = (null === (_context_devServer = context.devServer) || void 0 === _context_devServer ? void 0 : _context_devServer.port) || server.port || 3000;
|
|
3281
3312
|
if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
|
|
3282
3313
|
else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
|
|
3283
3314
|
else if (!0 === dev.assetPrefix) {
|
|
@@ -3450,7 +3481,8 @@ function HtmlPreloadOrPrefetchPlugin_define_property(obj, key, value) {
|
|
|
3450
3481
|
}) : obj[key] = value, obj;
|
|
3451
3482
|
}
|
|
3452
3483
|
let HtmlPreloadOrPrefetchPlugin_defaultOptions = {
|
|
3453
|
-
type: 'async-chunks'
|
|
3484
|
+
type: 'async-chunks',
|
|
3485
|
+
dedupe: !0
|
|
3454
3486
|
};
|
|
3455
3487
|
class HtmlPreloadOrPrefetchPlugin {
|
|
3456
3488
|
apply(compiler) {
|
|
@@ -3527,7 +3559,7 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
3527
3559
|
if (this.resourceHints) {
|
|
3528
3560
|
var resourceHints, scripts;
|
|
3529
3561
|
htmlPluginData.assetTags.styles = [
|
|
3530
|
-
...(resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))),
|
|
3562
|
+
...this.options.dedupe ? (resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))) : this.resourceHints,
|
|
3531
3563
|
...htmlPluginData.assetTags.styles
|
|
3532
3564
|
];
|
|
3533
3565
|
}
|
|
@@ -4088,7 +4120,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
|
|
|
4088
4120
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
4089
4121
|
var _utils_environment_config_tools;
|
|
4090
4122
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rspack config');
|
|
4091
|
-
let [modifiedConfig] = await context.hooks.modifyRspackConfig.
|
|
4123
|
+
let [modifiedConfig] = await context.hooks.modifyRspackConfig.callChain({
|
|
4092
4124
|
environment: utils.environment.name,
|
|
4093
4125
|
args: [
|
|
4094
4126
|
rspackConfig,
|
|
@@ -4166,14 +4198,14 @@ async function generateRspackConfig({ target, context, environment }) {
|
|
|
4166
4198
|
}
|
|
4167
4199
|
async function modifyRsbuildConfig(context) {
|
|
4168
4200
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
|
|
4169
|
-
let [modified] = await context.hooks.modifyRsbuildConfig.
|
|
4201
|
+
let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
|
|
4170
4202
|
mergeRsbuildConfig: mergeRsbuildConfig
|
|
4171
4203
|
});
|
|
4172
4204
|
context.config = modified, __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config done');
|
|
4173
4205
|
}
|
|
4174
4206
|
async function modifyEnvironmentConfig(context, config, name) {
|
|
4175
4207
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config`);
|
|
4176
|
-
let [modified] = await context.hooks.modifyEnvironmentConfig.
|
|
4208
|
+
let [modified] = await context.hooks.modifyEnvironmentConfig.callChain({
|
|
4177
4209
|
environment: name,
|
|
4178
4210
|
args: [
|
|
4179
4211
|
config,
|
|
@@ -4879,15 +4911,12 @@ class BasicRunner {
|
|
|
4879
4911
|
content: `module.exports = (${modulePath.map((arg)=>`require(${JSON.stringify(`./${arg}`)})`).join(', ')});`,
|
|
4880
4912
|
subPath: ''
|
|
4881
4913
|
};
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
};
|
|
4889
|
-
}
|
|
4890
|
-
return null;
|
|
4914
|
+
let joinedPath = isRelativePath(modulePath) ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(currentDirectory, modulePath) : modulePath;
|
|
4915
|
+
return this._options.isBundleOutput(joinedPath) ? {
|
|
4916
|
+
path: joinedPath,
|
|
4917
|
+
content: this._options.readFileSync(joinedPath),
|
|
4918
|
+
subPath: getSubPath(modulePath)
|
|
4919
|
+
} : null;
|
|
4891
4920
|
}
|
|
4892
4921
|
preExecute(_code, _file) {}
|
|
4893
4922
|
postExecute(_m, _file) {}
|
|
@@ -4941,7 +4970,14 @@ class CommonJsRunner extends BasicRunner {
|
|
|
4941
4970
|
this.requirers.set('miss', this.createMissRequirer()), this.requirers.set('entry', this.createCjsRequirer());
|
|
4942
4971
|
}
|
|
4943
4972
|
createMissRequirer() {
|
|
4944
|
-
return (_currentDirectory, modulePath, _context = {})=>
|
|
4973
|
+
return (_currentDirectory, modulePath, _context = {})=>{
|
|
4974
|
+
let resolvedPath = cjs_require.resolve(modulePath, {
|
|
4975
|
+
paths: [
|
|
4976
|
+
_currentDirectory
|
|
4977
|
+
]
|
|
4978
|
+
});
|
|
4979
|
+
return cjs_require(resolvedPath.startsWith('node:') ? resolvedPath.slice(5) : resolvedPath);
|
|
4980
|
+
};
|
|
4945
4981
|
}
|
|
4946
4982
|
createCjsRequirer() {
|
|
4947
4983
|
let requireCache = Object.create(null);
|
|
@@ -4963,10 +4999,12 @@ class CommonJsRunner extends BasicRunner {
|
|
|
4963
4999
|
var type_EsmMode = ((EsmMode = {})[EsmMode.Unknown = 0] = "Unknown", EsmMode[EsmMode.Evaluated = 1] = "Evaluated", EsmMode[EsmMode.Unlinked = 2] = "Unlinked", EsmMode);
|
|
4964
5000
|
class EsmRunner extends CommonJsRunner {
|
|
4965
5001
|
createRunner() {
|
|
4966
|
-
|
|
4967
|
-
|
|
5002
|
+
var _this__options_compilerOptions_experiments;
|
|
5003
|
+
super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
|
|
5004
|
+
let outputModule = null === (_this__options_compilerOptions_experiments = this._options.compilerOptions.experiments) || void 0 === _this__options_compilerOptions_experiments ? void 0 : _this__options_compilerOptions_experiments.outputModule;
|
|
5005
|
+
this.requirers.set('entry', (currentDirectory, modulePath, context)=>{
|
|
4968
5006
|
let file = this.getFile(modulePath, currentDirectory);
|
|
4969
|
-
return file ? file.path.endsWith('.
|
|
5007
|
+
return file ? outputModule && !file.path.endsWith('.cjs') ? this.requirers.get('esm')(currentDirectory, modulePath, {
|
|
4970
5008
|
...context,
|
|
4971
5009
|
file
|
|
4972
5010
|
}) : this.requirers.get('cjs')(currentDirectory, modulePath, {
|
|
@@ -5008,16 +5046,14 @@ class EsmRunner extends CommonJsRunner {
|
|
|
5008
5046
|
}
|
|
5009
5047
|
}
|
|
5010
5048
|
class BasicRunnerFactory {
|
|
5011
|
-
create(
|
|
5012
|
-
return this.createRunner(
|
|
5049
|
+
create(options) {
|
|
5050
|
+
return this.createRunner(options);
|
|
5013
5051
|
}
|
|
5014
|
-
createRunner(
|
|
5052
|
+
createRunner(options) {
|
|
5015
5053
|
let runnerOptions = {
|
|
5016
5054
|
name: this.name,
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
readFileSync
|
|
5020
|
-
};
|
|
5055
|
+
...options
|
|
5056
|
+
}, { compilerOptions } = options;
|
|
5021
5057
|
if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
|
|
5022
5058
|
return new EsmRunner(runnerOptions);
|
|
5023
5059
|
}
|
|
@@ -5031,7 +5067,7 @@ class BasicRunnerFactory {
|
|
|
5031
5067
|
}) : this[key] = value, this.name = name;
|
|
5032
5068
|
}
|
|
5033
5069
|
}
|
|
5034
|
-
let runner_run = async (bundlePath,
|
|
5070
|
+
let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunnerFactory(bundlePath).create(runnerFactoryOptions).run(bundlePath), loadBundle = async (stats, entryName, utils)=>{
|
|
5035
5071
|
let { chunks, entrypoints, outputPath } = stats.toJson({
|
|
5036
5072
|
all: !1,
|
|
5037
5073
|
chunks: !0,
|
|
@@ -5048,7 +5084,14 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5048
5084
|
}, []);
|
|
5049
5085
|
if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
|
|
5050
5086
|
if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
|
|
5051
|
-
|
|
5087
|
+
let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, file))) || [];
|
|
5088
|
+
return await runner_run({
|
|
5089
|
+
bundlePath: files[0],
|
|
5090
|
+
dist: outputPath,
|
|
5091
|
+
compilerOptions: stats.compilation.options,
|
|
5092
|
+
readFileSync: utils.readFileSync,
|
|
5093
|
+
isBundleOutput: (modulePath)=>allChunkFiles.includes(modulePath)
|
|
5094
|
+
});
|
|
5052
5095
|
}, getTransformedHtml = async (entryName, utils)=>{
|
|
5053
5096
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
5054
5097
|
if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
|
|
@@ -5229,12 +5272,11 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5229
5272
|
let opts = {
|
|
5230
5273
|
context,
|
|
5231
5274
|
changeOrigin: !0,
|
|
5232
|
-
logLevel: 'warn'
|
|
5275
|
+
logLevel: 'warn',
|
|
5276
|
+
logProvider: ()=>__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger
|
|
5233
5277
|
};
|
|
5234
5278
|
'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
|
|
5235
5279
|
}
|
|
5236
|
-
let handleError = (err)=>__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
5237
|
-
for (let opts of ret)opts.onError ??= handleError;
|
|
5238
5280
|
return ret;
|
|
5239
5281
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
|
|
5240
5282
|
for (let opts of formattedOptions){
|
|
@@ -5263,7 +5305,7 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5263
5305
|
before,
|
|
5264
5306
|
after
|
|
5265
5307
|
};
|
|
5266
|
-
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
5308
|
+
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments, postCallbacks })=>{
|
|
5267
5309
|
let upgradeEvents = [];
|
|
5268
5310
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
5269
5311
|
var _parseUrl;
|
|
@@ -5306,6 +5348,7 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5306
5348
|
});
|
|
5307
5349
|
middlewares.push(assetMiddleware);
|
|
5308
5350
|
}
|
|
5351
|
+
for (let callback of postCallbacks)callback();
|
|
5309
5352
|
if (compileMiddlewareAPI && middlewares.push(getHtmlFallbackMiddleware({
|
|
5310
5353
|
distPath,
|
|
5311
5354
|
callback: compileMiddlewareAPI.middleware,
|
|
@@ -5359,11 +5402,11 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5359
5402
|
return createServer(middlewares);
|
|
5360
5403
|
}, devServer_formatDevConfig = (config, port)=>('<port>' === config.client.port && (config.client.port = String(port)), config);
|
|
5361
5404
|
async function devServer_createDevServer(options, createCompiler, config, { compiler: customCompiler, getPortSilently, runCompile = !0 } = {}) {
|
|
5362
|
-
let lastStats;
|
|
5405
|
+
let lastStats, fileWatcher, devMiddlewares;
|
|
5363
5406
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create dev server');
|
|
5364
5407
|
let { port, host, https, portTip } = await getServerConfig({
|
|
5365
5408
|
config
|
|
5366
|
-
}), devConfig = devServer_formatDevConfig(config.dev, port), routes = getRoutes(options.context);
|
|
5409
|
+
}), devConfig = devServer_formatDevConfig(config.dev, port), routes = getRoutes(options.context), root = options.context.rootPath;
|
|
5367
5410
|
options.context.devServer = {
|
|
5368
5411
|
hostname: host,
|
|
5369
5412
|
port,
|
|
@@ -5397,11 +5440,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5397
5440
|
protocol,
|
|
5398
5441
|
port,
|
|
5399
5442
|
host
|
|
5400
|
-
})
|
|
5401
|
-
await options.context.hooks.onBeforeStartDevServer.call({
|
|
5402
|
-
environments: options.context.environments
|
|
5403
|
-
});
|
|
5404
|
-
let cliShortcutsEnabled = isCliShortcutsEnabled(devConfig), printUrls = ()=>printServerURLs({
|
|
5443
|
+
}), cliShortcutsEnabled = isCliShortcutsEnabled(devConfig), printUrls = ()=>printServerURLs({
|
|
5405
5444
|
urls,
|
|
5406
5445
|
port,
|
|
5407
5446
|
routes,
|
|
@@ -5415,8 +5454,8 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5415
5454
|
config,
|
|
5416
5455
|
clearCache: !0
|
|
5417
5456
|
}), closeServer = async ()=>{
|
|
5418
|
-
await options.context.hooks.onCloseDevServer.
|
|
5419
|
-
devMiddlewares.close(),
|
|
5457
|
+
await options.context.hooks.onCloseDevServer.callBatch(), await Promise.all([
|
|
5458
|
+
null == devMiddlewares ? void 0 : devMiddlewares.close(),
|
|
5420
5459
|
null == fileWatcher ? void 0 : fileWatcher.close()
|
|
5421
5460
|
]);
|
|
5422
5461
|
}, beforeCreateCompiler = ()=>{
|
|
@@ -5434,14 +5473,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5434
5473
|
options.context.hooks.onCloseDevServer.tap(cleanup);
|
|
5435
5474
|
}
|
|
5436
5475
|
!getPortSilently && portTip && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(portTip);
|
|
5437
|
-
}
|
|
5438
|
-
runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5439
|
-
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0, root = options.context.rootPath, fileWatcher = await setupWatchFiles({
|
|
5440
|
-
dev: devConfig,
|
|
5441
|
-
server: config.server,
|
|
5442
|
-
compileMiddlewareAPI,
|
|
5443
|
-
root
|
|
5444
|
-
}), readFileSync = (fileName)=>'readFileSync' in outputFileSystem ? outputFileSystem.readFileSync(fileName, 'utf-8') : __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(fileName, 'utf-8'), cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>getTransformedHtml(entryName, utils)), environmentAPI = Object.fromEntries(Object.entries(options.context.environments).map(([name, environment])=>[
|
|
5476
|
+
}, readFileSync = (fileName)=>'readFileSync' in outputFileSystem ? outputFileSystem.readFileSync(fileName, 'utf-8') : __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(fileName, 'utf-8'), cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>getTransformedHtml(entryName, utils)), environmentAPI = Object.fromEntries(Object.entries(options.context.environments).map(([name, environment])=>[
|
|
5445
5477
|
name,
|
|
5446
5478
|
{
|
|
5447
5479
|
getStats: async ()=>{
|
|
@@ -5457,34 +5489,23 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5457
5489
|
environment
|
|
5458
5490
|
}))
|
|
5459
5491
|
}
|
|
5460
|
-
])),
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
server: config.server,
|
|
5465
|
-
environments: environmentAPI,
|
|
5466
|
-
output: {
|
|
5467
|
-
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5468
|
-
},
|
|
5469
|
-
outputFileSystem
|
|
5470
|
-
}), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect();
|
|
5471
|
-
for (let item of devMiddlewares.middlewares)Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5472
|
-
let devServerAPI = {
|
|
5492
|
+
])), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect(), httpServer = await createHttpServer({
|
|
5493
|
+
serverConfig: config.server,
|
|
5494
|
+
middlewares
|
|
5495
|
+
}), devServerAPI = {
|
|
5473
5496
|
port,
|
|
5474
5497
|
middlewares,
|
|
5475
5498
|
environments: environmentAPI,
|
|
5499
|
+
httpServer,
|
|
5476
5500
|
listen: async ()=>{
|
|
5477
|
-
let
|
|
5478
|
-
serverConfig: config.server,
|
|
5479
|
-
middlewares
|
|
5480
|
-
}), serverTerminator = getServerTerminator(httpServer);
|
|
5501
|
+
let serverTerminator = getServerTerminator(httpServer);
|
|
5481
5502
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5482
5503
|
httpServer.listen({
|
|
5483
5504
|
host,
|
|
5484
5505
|
port
|
|
5485
5506
|
}, async (err)=>{
|
|
5486
5507
|
if (err) throw err;
|
|
5487
|
-
middlewares.use(notFoundMiddleware), httpServer.on('upgrade', devMiddlewares.onUpgrade), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5508
|
+
middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5488
5509
|
port,
|
|
5489
5510
|
urls: urls.map((item)=>item.url),
|
|
5490
5511
|
server: {
|
|
@@ -5495,25 +5516,47 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5495
5516
|
});
|
|
5496
5517
|
},
|
|
5497
5518
|
afterListen: async ()=>{
|
|
5498
|
-
await options.context.hooks.onAfterStartDevServer.
|
|
5519
|
+
await options.context.hooks.onAfterStartDevServer.callBatch({
|
|
5499
5520
|
port,
|
|
5500
5521
|
routes,
|
|
5501
5522
|
environments: options.context.environments
|
|
5502
5523
|
});
|
|
5503
5524
|
},
|
|
5504
5525
|
connectWebSocket: ({ server })=>{
|
|
5505
|
-
server.on('upgrade', devMiddlewares.onUpgrade);
|
|
5526
|
+
devMiddlewares && server.on('upgrade', devMiddlewares.onUpgrade);
|
|
5506
5527
|
},
|
|
5507
5528
|
close: closeServer,
|
|
5508
5529
|
printUrls,
|
|
5509
5530
|
open: openPage
|
|
5510
|
-
}
|
|
5531
|
+
}, postCallbacks = (await options.context.hooks.onBeforeStartDevServer.callBatch({
|
|
5532
|
+
server: devServerAPI,
|
|
5533
|
+
environments: options.context.environments
|
|
5534
|
+
})).filter((item)=>'function' == typeof item);
|
|
5535
|
+
runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5536
|
+
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
5537
|
+
for (let item of (fileWatcher = await setupWatchFiles({
|
|
5538
|
+
dev: devConfig,
|
|
5539
|
+
server: config.server,
|
|
5540
|
+
compileMiddlewareAPI,
|
|
5541
|
+
root
|
|
5542
|
+
}), (devMiddlewares = await getMiddlewares({
|
|
5543
|
+
pwd: root,
|
|
5544
|
+
compileMiddlewareAPI,
|
|
5545
|
+
dev: devConfig,
|
|
5546
|
+
server: config.server,
|
|
5547
|
+
environments: environmentAPI,
|
|
5548
|
+
output: {
|
|
5549
|
+
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5550
|
+
},
|
|
5551
|
+
outputFileSystem,
|
|
5552
|
+
postCallbacks
|
|
5553
|
+
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5511
5554
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create dev server done'), devServerAPI;
|
|
5512
5555
|
}
|
|
5513
5556
|
async function createCompiler_createCompiler(options) {
|
|
5514
5557
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create compiler');
|
|
5515
5558
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
5516
|
-
if (await context.hooks.onBeforeCreateCompiler.
|
|
5559
|
+
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
5517
5560
|
bundlerConfigs: rspackConfigs,
|
|
5518
5561
|
environments: context.environments
|
|
5519
5562
|
}), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(rspackMinVersion)}`);
|
|
@@ -5552,7 +5595,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
5552
5595
|
compiler,
|
|
5553
5596
|
bundlerConfigs: rspackConfigs,
|
|
5554
5597
|
MultiStatsCtor: __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.MultiStats
|
|
5555
|
-
}), await context.hooks.onAfterCreateCompiler.
|
|
5598
|
+
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
5556
5599
|
compiler,
|
|
5557
5600
|
environments: context.environments
|
|
5558
5601
|
}), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create compiler done'), {
|
|
@@ -5716,7 +5759,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
5716
5759
|
},
|
|
5717
5760
|
serverConfig
|
|
5718
5761
|
}, middlewares);
|
|
5719
|
-
await context.hooks.onBeforeStartProdServer.
|
|
5762
|
+
await context.hooks.onBeforeStartProdServer.callBatch();
|
|
5720
5763
|
let httpServer = await createHttpServer({
|
|
5721
5764
|
serverConfig,
|
|
5722
5765
|
middlewares: server.middlewares
|
|
@@ -5727,7 +5770,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
5727
5770
|
port
|
|
5728
5771
|
}, async ()=>{
|
|
5729
5772
|
let routes = getRoutes(context);
|
|
5730
|
-
await context.hooks.onAfterStartProdServer.
|
|
5773
|
+
await context.hooks.onAfterStartProdServer.callBatch({
|
|
5731
5774
|
port,
|
|
5732
5775
|
routes,
|
|
5733
5776
|
environments: context.environments
|
|
@@ -5786,7 +5829,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
5786
5829
|
pluginFileSize(),
|
|
5787
5830
|
pluginCleanOutput(),
|
|
5788
5831
|
pluginAsset(),
|
|
5789
|
-
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.
|
|
5832
|
+
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.callChain({
|
|
5790
5833
|
environment,
|
|
5791
5834
|
args
|
|
5792
5835
|
}))[0]),
|
|
@@ -6056,7 +6099,7 @@ async function createRsbuild(options = {}) {
|
|
|
6056
6099
|
});
|
|
6057
6100
|
}, onExitListened = !1, onExit = (cb)=>{
|
|
6058
6101
|
onExitListened || (process.on('exit', ()=>{
|
|
6059
|
-
hooks.onExit.
|
|
6102
|
+
hooks.onExit.callBatch();
|
|
6060
6103
|
}), onExitListened = !0), hooks.onExit.tap(cb);
|
|
6061
6104
|
};
|
|
6062
6105
|
return (environment)=>({
|
|
@@ -6134,7 +6177,7 @@ async function createRsbuild(options = {}) {
|
|
|
6134
6177
|
return {
|
|
6135
6178
|
...buildInstance,
|
|
6136
6179
|
close: async ()=>{
|
|
6137
|
-
await context.hooks.onCloseBuild.
|
|
6180
|
+
await context.hooks.onCloseBuild.callBatch(), await buildInstance.close();
|
|
6138
6181
|
}
|
|
6139
6182
|
};
|
|
6140
6183
|
},
|
|
@@ -6504,7 +6547,7 @@ class CAC extends __WEBPACK_EXTERNAL_MODULE_events__.EventEmitter {
|
|
|
6504
6547
|
}), actionArgs.push(options), command.commandAction.apply(this, actionArgs);
|
|
6505
6548
|
}
|
|
6506
6549
|
}
|
|
6507
|
-
let
|
|
6550
|
+
let dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6508
6551
|
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
6552
|
default: 'jiti'
|
|
6510
6553
|
}).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', {
|
|
@@ -6528,12 +6571,12 @@ async function runCLI() {
|
|
|
6528
6571
|
}
|
|
6529
6572
|
}(), process.title = 'rsbuild-node';
|
|
6530
6573
|
let { npm_execpath } = process.env;
|
|
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.
|
|
6574
|
+
(!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.9\n`);
|
|
6532
6575
|
}();
|
|
6533
6576
|
try {
|
|
6534
6577
|
!function() {
|
|
6535
|
-
let cli =
|
|
6536
|
-
cli.help(), cli.version("1.2.
|
|
6578
|
+
let cli = dist('rsbuild');
|
|
6579
|
+
cli.help(), cli.version("1.2.9"), applyCommonOptions(cli);
|
|
6537
6580
|
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');
|
|
6538
6581
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6539
6582
|
try {
|
|
@@ -6584,6 +6627,6 @@ async function runCLI() {
|
|
|
6584
6627
|
__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);
|
|
6585
6628
|
}
|
|
6586
6629
|
}
|
|
6587
|
-
let src_version = "1.2.
|
|
6630
|
+
let src_version = "1.2.9";
|
|
6588
6631
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6589
6632
|
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 };
|