@rsbuild/core 1.2.8 → 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 +18 -18
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/style-loader/index.js +10 -10
- package/dist/index.cjs +76 -48
- package/dist/index.js +76 -48
- package/dist-types/server/devServer.d.ts +11 -6
- package/dist-types/server/getDevMiddlewares.d.ts +4 -0
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +63 -8
- package/package.json +2 -2
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,
|
|
@@ -3282,7 +3308,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
|
|
|
3282
3308
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, isProd, isServer, environment })=>{
|
|
3283
3309
|
let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
|
|
3284
3310
|
var _context_devServer, _context_devServer1, _context_devServer2;
|
|
3285
|
-
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;
|
|
3286
3312
|
if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
|
|
3287
3313
|
else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
|
|
3288
3314
|
else if (!0 === dev.assetPrefix) {
|
|
@@ -4094,7 +4120,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
|
|
|
4094
4120
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
4095
4121
|
var _utils_environment_config_tools;
|
|
4096
4122
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rspack config');
|
|
4097
|
-
let [modifiedConfig] = await context.hooks.modifyRspackConfig.
|
|
4123
|
+
let [modifiedConfig] = await context.hooks.modifyRspackConfig.callChain({
|
|
4098
4124
|
environment: utils.environment.name,
|
|
4099
4125
|
args: [
|
|
4100
4126
|
rspackConfig,
|
|
@@ -4172,14 +4198,14 @@ async function generateRspackConfig({ target, context, environment }) {
|
|
|
4172
4198
|
}
|
|
4173
4199
|
async function modifyRsbuildConfig(context) {
|
|
4174
4200
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
|
|
4175
|
-
let [modified] = await context.hooks.modifyRsbuildConfig.
|
|
4201
|
+
let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
|
|
4176
4202
|
mergeRsbuildConfig: mergeRsbuildConfig
|
|
4177
4203
|
});
|
|
4178
4204
|
context.config = modified, __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config done');
|
|
4179
4205
|
}
|
|
4180
4206
|
async function modifyEnvironmentConfig(context, config, name) {
|
|
4181
4207
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config`);
|
|
4182
|
-
let [modified] = await context.hooks.modifyEnvironmentConfig.
|
|
4208
|
+
let [modified] = await context.hooks.modifyEnvironmentConfig.callChain({
|
|
4183
4209
|
environment: name,
|
|
4184
4210
|
args: [
|
|
4185
4211
|
config,
|
|
@@ -5246,12 +5272,11 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
|
|
|
5246
5272
|
let opts = {
|
|
5247
5273
|
context,
|
|
5248
5274
|
changeOrigin: !0,
|
|
5249
|
-
logLevel: 'warn'
|
|
5275
|
+
logLevel: 'warn',
|
|
5276
|
+
logProvider: ()=>__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger
|
|
5250
5277
|
};
|
|
5251
5278
|
'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
|
|
5252
5279
|
}
|
|
5253
|
-
let handleError = (err)=>__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
5254
|
-
for (let opts of ret)opts.onError ??= handleError;
|
|
5255
5280
|
return ret;
|
|
5256
5281
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
|
|
5257
5282
|
for (let opts of formattedOptions){
|
|
@@ -5280,7 +5305,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
|
|
|
5280
5305
|
before,
|
|
5281
5306
|
after
|
|
5282
5307
|
};
|
|
5283
|
-
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
5308
|
+
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments, postCallbacks })=>{
|
|
5284
5309
|
let upgradeEvents = [];
|
|
5285
5310
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
5286
5311
|
var _parseUrl;
|
|
@@ -5323,6 +5348,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
|
|
|
5323
5348
|
});
|
|
5324
5349
|
middlewares.push(assetMiddleware);
|
|
5325
5350
|
}
|
|
5351
|
+
for (let callback of postCallbacks)callback();
|
|
5326
5352
|
if (compileMiddlewareAPI && middlewares.push(getHtmlFallbackMiddleware({
|
|
5327
5353
|
distPath,
|
|
5328
5354
|
callback: compileMiddlewareAPI.middleware,
|
|
@@ -5428,7 +5454,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5428
5454
|
config,
|
|
5429
5455
|
clearCache: !0
|
|
5430
5456
|
}), closeServer = async ()=>{
|
|
5431
|
-
await options.context.hooks.onCloseDevServer.
|
|
5457
|
+
await options.context.hooks.onCloseDevServer.callBatch(), await Promise.all([
|
|
5432
5458
|
null == devMiddlewares ? void 0 : devMiddlewares.close(),
|
|
5433
5459
|
null == fileWatcher ? void 0 : fileWatcher.close()
|
|
5434
5460
|
]);
|
|
@@ -5463,15 +5489,16 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5463
5489
|
environment
|
|
5464
5490
|
}))
|
|
5465
5491
|
}
|
|
5466
|
-
])), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect(),
|
|
5492
|
+
])), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect(), httpServer = await createHttpServer({
|
|
5493
|
+
serverConfig: config.server,
|
|
5494
|
+
middlewares
|
|
5495
|
+
}), devServerAPI = {
|
|
5467
5496
|
port,
|
|
5468
5497
|
middlewares,
|
|
5469
5498
|
environments: environmentAPI,
|
|
5499
|
+
httpServer,
|
|
5470
5500
|
listen: async ()=>{
|
|
5471
|
-
let
|
|
5472
|
-
serverConfig: config.server,
|
|
5473
|
-
middlewares
|
|
5474
|
-
}), serverTerminator = getServerTerminator(httpServer);
|
|
5501
|
+
let serverTerminator = getServerTerminator(httpServer);
|
|
5475
5502
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5476
5503
|
httpServer.listen({
|
|
5477
5504
|
host,
|
|
@@ -5489,7 +5516,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5489
5516
|
});
|
|
5490
5517
|
},
|
|
5491
5518
|
afterListen: async ()=>{
|
|
5492
|
-
await options.context.hooks.onAfterStartDevServer.
|
|
5519
|
+
await options.context.hooks.onAfterStartDevServer.callBatch({
|
|
5493
5520
|
port,
|
|
5494
5521
|
routes,
|
|
5495
5522
|
environments: options.context.environments
|
|
@@ -5501,11 +5528,11 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5501
5528
|
close: closeServer,
|
|
5502
5529
|
printUrls,
|
|
5503
5530
|
open: openPage
|
|
5504
|
-
}
|
|
5505
|
-
await options.context.hooks.onBeforeStartDevServer.call({
|
|
5531
|
+
}, postCallbacks = (await options.context.hooks.onBeforeStartDevServer.callBatch({
|
|
5506
5532
|
server: devServerAPI,
|
|
5507
5533
|
environments: options.context.environments
|
|
5508
|
-
})
|
|
5534
|
+
})).filter((item)=>'function' == typeof item);
|
|
5535
|
+
runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5509
5536
|
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
5510
5537
|
for (let item of (fileWatcher = await setupWatchFiles({
|
|
5511
5538
|
dev: devConfig,
|
|
@@ -5521,14 +5548,15 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5521
5548
|
output: {
|
|
5522
5549
|
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5523
5550
|
},
|
|
5524
|
-
outputFileSystem
|
|
5551
|
+
outputFileSystem,
|
|
5552
|
+
postCallbacks
|
|
5525
5553
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5526
5554
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create dev server done'), devServerAPI;
|
|
5527
5555
|
}
|
|
5528
5556
|
async function createCompiler_createCompiler(options) {
|
|
5529
5557
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create compiler');
|
|
5530
5558
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
5531
|
-
if (await context.hooks.onBeforeCreateCompiler.
|
|
5559
|
+
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
5532
5560
|
bundlerConfigs: rspackConfigs,
|
|
5533
5561
|
environments: context.environments
|
|
5534
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)}`);
|
|
@@ -5567,7 +5595,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
5567
5595
|
compiler,
|
|
5568
5596
|
bundlerConfigs: rspackConfigs,
|
|
5569
5597
|
MultiStatsCtor: __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.MultiStats
|
|
5570
|
-
}), await context.hooks.onAfterCreateCompiler.
|
|
5598
|
+
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
5571
5599
|
compiler,
|
|
5572
5600
|
environments: context.environments
|
|
5573
5601
|
}), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create compiler done'), {
|
|
@@ -5731,7 +5759,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
5731
5759
|
},
|
|
5732
5760
|
serverConfig
|
|
5733
5761
|
}, middlewares);
|
|
5734
|
-
await context.hooks.onBeforeStartProdServer.
|
|
5762
|
+
await context.hooks.onBeforeStartProdServer.callBatch();
|
|
5735
5763
|
let httpServer = await createHttpServer({
|
|
5736
5764
|
serverConfig,
|
|
5737
5765
|
middlewares: server.middlewares
|
|
@@ -5742,7 +5770,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
5742
5770
|
port
|
|
5743
5771
|
}, async ()=>{
|
|
5744
5772
|
let routes = getRoutes(context);
|
|
5745
|
-
await context.hooks.onAfterStartProdServer.
|
|
5773
|
+
await context.hooks.onAfterStartProdServer.callBatch({
|
|
5746
5774
|
port,
|
|
5747
5775
|
routes,
|
|
5748
5776
|
environments: context.environments
|
|
@@ -5801,7 +5829,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
5801
5829
|
pluginFileSize(),
|
|
5802
5830
|
pluginCleanOutput(),
|
|
5803
5831
|
pluginAsset(),
|
|
5804
|
-
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.
|
|
5832
|
+
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.callChain({
|
|
5805
5833
|
environment,
|
|
5806
5834
|
args
|
|
5807
5835
|
}))[0]),
|
|
@@ -6071,7 +6099,7 @@ async function createRsbuild(options = {}) {
|
|
|
6071
6099
|
});
|
|
6072
6100
|
}, onExitListened = !1, onExit = (cb)=>{
|
|
6073
6101
|
onExitListened || (process.on('exit', ()=>{
|
|
6074
|
-
hooks.onExit.
|
|
6102
|
+
hooks.onExit.callBatch();
|
|
6075
6103
|
}), onExitListened = !0), hooks.onExit.tap(cb);
|
|
6076
6104
|
};
|
|
6077
6105
|
return (environment)=>({
|
|
@@ -6149,7 +6177,7 @@ async function createRsbuild(options = {}) {
|
|
|
6149
6177
|
return {
|
|
6150
6178
|
...buildInstance,
|
|
6151
6179
|
close: async ()=>{
|
|
6152
|
-
await context.hooks.onCloseBuild.
|
|
6180
|
+
await context.hooks.onCloseBuild.callBatch(), await buildInstance.close();
|
|
6153
6181
|
}
|
|
6154
6182
|
};
|
|
6155
6183
|
},
|
|
@@ -6543,12 +6571,12 @@ async function runCLI() {
|
|
|
6543
6571
|
}
|
|
6544
6572
|
}(), process.title = 'rsbuild-node';
|
|
6545
6573
|
let { npm_execpath } = process.env;
|
|
6546
|
-
(!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`);
|
|
6547
6575
|
}();
|
|
6548
6576
|
try {
|
|
6549
6577
|
!function() {
|
|
6550
6578
|
let cli = dist('rsbuild');
|
|
6551
|
-
cli.help(), cli.version("1.2.
|
|
6579
|
+
cli.help(), cli.version("1.2.9"), applyCommonOptions(cli);
|
|
6552
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');
|
|
6553
6581
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6554
6582
|
try {
|
|
@@ -6599,6 +6627,6 @@ async function runCLI() {
|
|
|
6599
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);
|
|
6600
6628
|
}
|
|
6601
6629
|
}
|
|
6602
|
-
let src_version = "1.2.
|
|
6630
|
+
let src_version = "1.2.9";
|
|
6603
6631
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6604
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 };
|
|
@@ -5,7 +5,17 @@ import type { CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalCo
|
|
|
5
5
|
type HTTPServer = Server | Http2SecureServer;
|
|
6
6
|
export type RsbuildDevServer = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The `connect` app instance.
|
|
9
|
+
* Can be used to attach custom middlewares to the dev server.
|
|
10
|
+
*/
|
|
11
|
+
middlewares: Connect.Server;
|
|
12
|
+
/**
|
|
13
|
+
* The Node.js HTTP server instance.
|
|
14
|
+
* Will be `Http2SecureServer` if `server.https` config is used.
|
|
15
|
+
*/
|
|
16
|
+
httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
|
|
17
|
+
/**
|
|
18
|
+
* Start listening on the Rsbuild dev server.
|
|
9
19
|
* Do not call this method if you are using a custom server.
|
|
10
20
|
*/
|
|
11
21
|
listen: () => Promise<{
|
|
@@ -24,11 +34,6 @@ export type RsbuildDevServer = {
|
|
|
24
34
|
* By default, Rsbuild server listens on port `3000` and automatically increments the port number if the port is occupied.
|
|
25
35
|
*/
|
|
26
36
|
port: number;
|
|
27
|
-
/**
|
|
28
|
-
* The `connect` app instance.
|
|
29
|
-
* Can be used to attach custom middlewares to the dev server.
|
|
30
|
-
*/
|
|
31
|
-
middlewares: Connect.Server;
|
|
32
37
|
/**
|
|
33
38
|
* Notify that the Rsbuild server has been started.
|
|
34
39
|
* Rsbuild will trigger `onAfterStartDevServer` hook in this stage.
|
|
@@ -16,6 +16,10 @@ export type RsbuildDevMiddlewareOptions = {
|
|
|
16
16
|
output: {
|
|
17
17
|
distPath: string;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Callbacks returned by the `onBeforeStartDevServer` hook.
|
|
21
|
+
*/
|
|
22
|
+
postCallbacks: (() => void)[];
|
|
19
23
|
};
|
|
20
24
|
export type Middlewares = Array<RequestHandler | [string, RequestHandler]>;
|
|
21
25
|
export type GetMiddlewaresResult = {
|
|
@@ -42,7 +42,7 @@ export type OnBeforeStartDevServerFn = (params: {
|
|
|
42
42
|
* A read-only object that provides some context information about different environments.
|
|
43
43
|
*/
|
|
44
44
|
environments: Record<string, EnvironmentContext>;
|
|
45
|
-
}) => MaybePromise<void>;
|
|
45
|
+
}) => MaybePromise<(() => void) | void>;
|
|
46
46
|
export type OnBeforeStartProdServerFn = () => MaybePromise<void>;
|
|
47
47
|
export type Routes = Array<{
|
|
48
48
|
entryName: string;
|
|
@@ -14,27 +14,82 @@ export type HookDescriptor<T extends (...args: any[]) => any> = {
|
|
|
14
14
|
handler: T;
|
|
15
15
|
order: HookOrder;
|
|
16
16
|
};
|
|
17
|
-
export type EnvironmentAsyncHook<Callback extends (...args: any[]) => any> = {
|
|
17
|
+
export type EnvironmentAsyncHook<Callback extends (...args: any[]) => T, T = any> = {
|
|
18
|
+
/**
|
|
19
|
+
* Registers a callback function to be executed when the hook is triggered.
|
|
20
|
+
* The callback can be a plain function or a HookDescriptor that includes execution order.
|
|
21
|
+
* The callback will be executed in all environments by default.
|
|
22
|
+
* If you need to specify the environment, please use `tapEnvironment`
|
|
23
|
+
* @param cb The callback function or hook descriptor to register
|
|
24
|
+
*/
|
|
25
|
+
tap: (cb: Callback | HookDescriptor<Callback>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Registers a callback function to be executed when the hook is triggered.
|
|
28
|
+
* The callback will only be executed under the specified environment.
|
|
29
|
+
*/
|
|
18
30
|
tapEnvironment: (params: {
|
|
19
31
|
/**
|
|
20
|
-
* Specify that the callback will
|
|
32
|
+
* Specify the environment that the callback will be executed under.
|
|
21
33
|
*/
|
|
22
34
|
environment?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The callback function or hook descriptor to register
|
|
37
|
+
*/
|
|
23
38
|
handler: Callback | HookDescriptor<Callback>;
|
|
24
39
|
}) => void;
|
|
25
40
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
41
|
+
* Executes callbacks in sequence independently and collects all their results into an array.
|
|
42
|
+
* Each callback receives the original parameters, and their results don't affect subsequent callbacks.
|
|
43
|
+
* @returns A promise that resolves with an array containing the results of all callbacks
|
|
28
44
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
callChain: (params: {
|
|
46
|
+
/**
|
|
47
|
+
* Specify the environment for filtering callbacks.
|
|
48
|
+
*/
|
|
31
49
|
environment?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The parameters to pass to each callback
|
|
52
|
+
*/
|
|
32
53
|
args: Parameters<Callback>;
|
|
33
54
|
}) => Promise<Parameters<Callback>>;
|
|
55
|
+
/**
|
|
56
|
+
* Executes callbacks in sequence independently and collects all their results into an array.
|
|
57
|
+
* Each callback receives the original parameters, and their results don't affect subsequent callbacks.
|
|
58
|
+
* @returns A promise that resolves with an array containing the results of all callbacks
|
|
59
|
+
*/
|
|
60
|
+
callBatch: (params: {
|
|
61
|
+
/**
|
|
62
|
+
* Specify the environment for filtering callbacks.
|
|
63
|
+
*/
|
|
64
|
+
environment?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The parameters to pass to each callback
|
|
67
|
+
*/
|
|
68
|
+
args: Parameters<Callback>;
|
|
69
|
+
}) => Promise<Awaited<ReturnType<Callback>>[]>;
|
|
34
70
|
};
|
|
35
|
-
export type AsyncHook<Callback extends (...args: any[]) => any> = {
|
|
71
|
+
export type AsyncHook<Callback extends (...args: any[]) => T, T = any> = {
|
|
72
|
+
/**
|
|
73
|
+
* Registers a callback function to be executed when the hook is triggered.
|
|
74
|
+
* The callback can be a plain function or a HookDescriptor that includes execution order.
|
|
75
|
+
* @param cb The callback function or hook descriptor to register
|
|
76
|
+
*/
|
|
36
77
|
tap: (cb: Callback | HookDescriptor<Callback>) => void;
|
|
37
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Executes callbacks in sequence, passing the result of each callback as the first argument
|
|
80
|
+
* to the next callback in the chain. If a callback returns undefined, the original arguments
|
|
81
|
+
* will be passed to the next callback.
|
|
82
|
+
* @param params The initial parameters to pass to the first callback
|
|
83
|
+
* @returns A promise that resolves with the final parameters after all callbacks have executed
|
|
84
|
+
*/
|
|
85
|
+
callChain: (...args: Parameters<Callback>) => Promise<Parameters<Callback>>;
|
|
86
|
+
/**
|
|
87
|
+
* Executes callbacks in sequence independently and collects all their results into an array.
|
|
88
|
+
* Each callback receives the original parameters, and their results don't affect subsequent callbacks.
|
|
89
|
+
* @param params The parameters to pass to each callback
|
|
90
|
+
* @returns A promise that resolves with an array containing the results of all callbacks
|
|
91
|
+
*/
|
|
92
|
+
callBatch: (...args: Parameters<Callback>) => Promise<Awaited<ReturnType<Callback>>[]>;
|
|
38
93
|
};
|
|
39
94
|
export type ModifyRspackConfigFn = (config: Rspack.Configuration, utils: ModifyRspackConfigUtils) => MaybePromise<Rspack.Configuration | void>;
|
|
40
95
|
export type ModifyWebpackChainUtils = ModifyChainUtils & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@rslib/core": "0.4.1",
|
|
56
56
|
"@types/connect": "3.4.38",
|
|
57
|
-
"@types/node": "^22.13.
|
|
57
|
+
"@types/node": "^22.13.4",
|
|
58
58
|
"@types/on-finished": "2.3.4",
|
|
59
59
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
60
60
|
"@types/ws": "^8.5.14",
|