@rsbuild/core 1.2.8 → 1.2.10
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/html-rspack-plugin/index.js +14 -14
- package/compiled/launch-editor-middleware/index.js +22 -15
- package/compiled/launch-editor-middleware/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/dist/index.cjs +93 -60
- package/dist/index.js +93 -60
- package/dist-types/server/devServer.d.ts +11 -6
- package/dist-types/server/getDevMiddlewares.d.ts +4 -0
- package/dist-types/server/middlewares.d.ts +1 -0
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +63 -8
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -606,38 +606,39 @@ var __webpack_exports__ = {};
|
|
|
606
606
|
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (message = hintNodePolyfill(message = function(message) {
|
|
607
607
|
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
608
608
|
if (-1 === message.indexOf(hint)) return message;
|
|
609
|
+
let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${index_js_default().yellow(`@rsbuild/plugin-${packageName}`)}" ${index_js_default().dim(`(https://www.npmjs.com/package/@rsbuild/plugin-${packageName})`)}.`;
|
|
609
610
|
for (let plugin of [
|
|
610
611
|
{
|
|
611
612
|
test: /File: .+\.s(c|a)ss/,
|
|
612
|
-
hint:
|
|
613
|
+
hint: createPluginHint('sass', 'Sass')
|
|
613
614
|
},
|
|
614
615
|
{
|
|
615
616
|
test: /File: .+\.less/,
|
|
616
|
-
hint:
|
|
617
|
+
hint: createPluginHint('less', 'Less')
|
|
617
618
|
},
|
|
618
619
|
{
|
|
619
620
|
test: /File: .+\.styl(us)?/,
|
|
620
|
-
hint:
|
|
621
|
+
hint: createPluginHint('stylus', 'Stylus')
|
|
621
622
|
},
|
|
622
623
|
{
|
|
623
624
|
test: /File: .+\.vue?/,
|
|
624
|
-
hint:
|
|
625
|
+
hint: createPluginHint('vue', 'Vue')
|
|
625
626
|
},
|
|
626
627
|
{
|
|
627
628
|
test: /File: .+\.svelte?/,
|
|
628
|
-
hint:
|
|
629
|
+
hint: createPluginHint('svelte', 'Svelte')
|
|
629
630
|
},
|
|
630
631
|
{
|
|
631
632
|
test: /File: .+\.mdx/,
|
|
632
|
-
hint:
|
|
633
|
+
hint: createPluginHint('mdx', 'MDX')
|
|
633
634
|
},
|
|
634
635
|
{
|
|
635
636
|
test: /File: .+\.toml/,
|
|
636
|
-
hint:
|
|
637
|
+
hint: createPluginHint('toml', 'TOML')
|
|
637
638
|
},
|
|
638
639
|
{
|
|
639
640
|
test: /File: .+\.yaml/,
|
|
640
|
-
hint:
|
|
641
|
+
hint: createPluginHint('yaml', 'YAML')
|
|
641
642
|
}
|
|
642
643
|
])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
|
|
643
644
|
return message;
|
|
@@ -918,7 +919,7 @@ var __webpack_exports__ = {};
|
|
|
918
919
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
919
920
|
cliOptions && (commonOpts = cliOptions);
|
|
920
921
|
try {
|
|
921
|
-
var _config_server, _config_dev;
|
|
922
|
+
var _config_server, _config_dev, _config_performance;
|
|
922
923
|
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
|
|
923
924
|
cwd: getEnvDir(root, commonOpts.envDir),
|
|
924
925
|
mode: commonOpts.envMode
|
|
@@ -928,10 +929,15 @@ var __webpack_exports__ = {};
|
|
|
928
929
|
envMode: commonOpts.envMode,
|
|
929
930
|
loader: commonOpts.configLoader
|
|
930
931
|
});
|
|
931
|
-
config.source ||= {}, config.source.define = {
|
|
932
|
+
if (config.source ||= {}, config.source.define = {
|
|
932
933
|
...envs.publicVars,
|
|
933
934
|
...config.source.define
|
|
934
|
-
}, commonOpts.base && (config.server ||= {}, config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0)
|
|
935
|
+
}, commonOpts.base && (config.server ||= {}, config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0), (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache) && envs.filePaths.length > 0) {
|
|
936
|
+
let { buildCache } = config.performance;
|
|
937
|
+
!0 === buildCache ? config.performance.buildCache = {
|
|
938
|
+
buildDependencies: envs.filePaths
|
|
939
|
+
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs.filePaths));
|
|
940
|
+
}
|
|
935
941
|
let rsbuild = await createRsbuild({
|
|
936
942
|
cwd: root,
|
|
937
943
|
rsbuildConfig: config,
|
|
@@ -1434,7 +1440,7 @@ var __webpack_exports__ = {};
|
|
|
1434
1440
|
tap: (handler)=>tapEnvironment({
|
|
1435
1441
|
handler
|
|
1436
1442
|
}),
|
|
1437
|
-
|
|
1443
|
+
callChain: async ({ environment, args: params })=>{
|
|
1438
1444
|
for (let callback of [
|
|
1439
1445
|
...preGroup,
|
|
1440
1446
|
...defaultGroup,
|
|
@@ -1445,6 +1451,19 @@ var __webpack_exports__ = {};
|
|
|
1445
1451
|
void 0 !== result && (params[0] = result);
|
|
1446
1452
|
}
|
|
1447
1453
|
return params;
|
|
1454
|
+
},
|
|
1455
|
+
callBatch: async ({ environment, args: params })=>{
|
|
1456
|
+
let results = [];
|
|
1457
|
+
for (let callback of [
|
|
1458
|
+
...preGroup,
|
|
1459
|
+
...defaultGroup,
|
|
1460
|
+
...postGroup
|
|
1461
|
+
]){
|
|
1462
|
+
if (callback.environment && environment && !isPluginMatchEnvironment(callback.environment, environment)) continue;
|
|
1463
|
+
let result = await callback.handler(...params);
|
|
1464
|
+
results.push(result);
|
|
1465
|
+
}
|
|
1466
|
+
return results;
|
|
1448
1467
|
}
|
|
1449
1468
|
};
|
|
1450
1469
|
}
|
|
@@ -1454,7 +1473,7 @@ var __webpack_exports__ = {};
|
|
|
1454
1473
|
tap: (cb)=>{
|
|
1455
1474
|
isFunction(cb) ? defaultGroup.push(cb) : 'pre' === cb.order ? preGroup.push(cb.handler) : 'post' === cb.order ? postGroup.push(cb.handler) : defaultGroup.push(cb.handler);
|
|
1456
1475
|
},
|
|
1457
|
-
|
|
1476
|
+
callChain: async (...params)=>{
|
|
1458
1477
|
for (let callback of [
|
|
1459
1478
|
...preGroup,
|
|
1460
1479
|
...defaultGroup,
|
|
@@ -1464,6 +1483,18 @@ var __webpack_exports__ = {};
|
|
|
1464
1483
|
void 0 !== result && (params[0] = result);
|
|
1465
1484
|
}
|
|
1466
1485
|
return params;
|
|
1486
|
+
},
|
|
1487
|
+
callBatch: async (...params)=>{
|
|
1488
|
+
let results = [];
|
|
1489
|
+
for (let callback of [
|
|
1490
|
+
...preGroup,
|
|
1491
|
+
...defaultGroup,
|
|
1492
|
+
...postGroup
|
|
1493
|
+
]){
|
|
1494
|
+
let result = await callback(...params);
|
|
1495
|
+
results.push(result);
|
|
1496
|
+
}
|
|
1497
|
+
return results;
|
|
1467
1498
|
}
|
|
1468
1499
|
};
|
|
1469
1500
|
}
|
|
@@ -1501,7 +1532,7 @@ var __webpack_exports__ = {};
|
|
|
1501
1532
|
});
|
|
1502
1533
|
}, registerBuildHook = ({ context, isWatch, compiler, bundlerConfigs, MultiStatsCtor })=>{
|
|
1503
1534
|
let isFirstCompile = !0, environmentList = Object.values(context.environments).reduce((prev, curr)=>(prev[curr.index] = curr, prev), []), onDone = async (stats)=>{
|
|
1504
|
-
let p = context.hooks.onAfterBuild.
|
|
1535
|
+
let p = context.hooks.onAfterBuild.callBatch({
|
|
1505
1536
|
isFirstCompile,
|
|
1506
1537
|
stats,
|
|
1507
1538
|
environments: context.environments,
|
|
@@ -1509,7 +1540,7 @@ var __webpack_exports__ = {};
|
|
|
1509
1540
|
});
|
|
1510
1541
|
isFirstCompile = !1, await p;
|
|
1511
1542
|
}, onEnvironmentDone = async (buildIndex, stats)=>{
|
|
1512
|
-
await context.hooks.onAfterEnvironmentCompile.
|
|
1543
|
+
await context.hooks.onAfterEnvironmentCompile.callBatch({
|
|
1513
1544
|
environment: environmentList[buildIndex].name,
|
|
1514
1545
|
args: [
|
|
1515
1546
|
{
|
|
@@ -1523,13 +1554,13 @@ var __webpack_exports__ = {};
|
|
|
1523
1554
|
};
|
|
1524
1555
|
onBeforeCompile({
|
|
1525
1556
|
compiler,
|
|
1526
|
-
beforeCompile: async ()=>await context.hooks.onBeforeBuild.
|
|
1557
|
+
beforeCompile: async ()=>await context.hooks.onBeforeBuild.callBatch({
|
|
1527
1558
|
bundlerConfigs,
|
|
1528
1559
|
environments: context.environments,
|
|
1529
1560
|
isWatch,
|
|
1530
1561
|
isFirstCompile
|
|
1531
1562
|
}),
|
|
1532
|
-
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.
|
|
1563
|
+
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
1533
1564
|
environment: environmentList[buildIndex].name,
|
|
1534
1565
|
args: [
|
|
1535
1566
|
{
|
|
@@ -1549,14 +1580,14 @@ var __webpack_exports__ = {};
|
|
|
1549
1580
|
});
|
|
1550
1581
|
}, registerDevHook = ({ context, compiler, bundlerConfigs, MultiStatsCtor })=>{
|
|
1551
1582
|
let isFirstCompile = !0, environmentList = Object.values(context.environments).reduce((prev, curr)=>(prev[curr.index] = curr, prev), []), onDone = async (stats)=>{
|
|
1552
|
-
let p = context.hooks.onDevCompileDone.
|
|
1583
|
+
let p = context.hooks.onDevCompileDone.callBatch({
|
|
1553
1584
|
isFirstCompile,
|
|
1554
1585
|
stats,
|
|
1555
1586
|
environments: context.environments
|
|
1556
1587
|
});
|
|
1557
1588
|
isFirstCompile = !1, await p;
|
|
1558
1589
|
}, onEnvironmentDone = async (buildIndex, stats)=>{
|
|
1559
|
-
await context.hooks.onAfterEnvironmentCompile.
|
|
1590
|
+
await context.hooks.onAfterEnvironmentCompile.callBatch({
|
|
1560
1591
|
environment: environmentList[buildIndex].name,
|
|
1561
1592
|
args: [
|
|
1562
1593
|
{
|
|
@@ -1570,7 +1601,7 @@ var __webpack_exports__ = {};
|
|
|
1570
1601
|
};
|
|
1571
1602
|
onBeforeCompile({
|
|
1572
1603
|
compiler,
|
|
1573
|
-
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.
|
|
1604
|
+
beforeEnvironmentCompiler: async (buildIndex)=>await context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
1574
1605
|
environment: environmentList[buildIndex].name,
|
|
1575
1606
|
args: [
|
|
1576
1607
|
{
|
|
@@ -1708,7 +1739,7 @@ var __webpack_exports__ = {};
|
|
|
1708
1739
|
async function createContext(options, userConfig, bundlerType) {
|
|
1709
1740
|
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;
|
|
1710
1741
|
return {
|
|
1711
|
-
version: "1.2.
|
|
1742
|
+
version: "1.2.10",
|
|
1712
1743
|
rootPath,
|
|
1713
1744
|
distPath: '',
|
|
1714
1745
|
cachePath,
|
|
@@ -1841,7 +1872,7 @@ var __webpack_exports__ = {};
|
|
|
1841
1872
|
async function modifyBundlerChain(context, utils) {
|
|
1842
1873
|
var _utils_environment_config_tools;
|
|
1843
1874
|
rslog_index_js_namespaceObject.logger.debug('modify bundler chain');
|
|
1844
|
-
let bundlerChain = new (rspack_chain_index_js_default())(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.
|
|
1875
|
+
let bundlerChain = new (rspack_chain_index_js_default())(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
|
|
1845
1876
|
environment: utils.environment.name,
|
|
1846
1877
|
args: [
|
|
1847
1878
|
bundlerChain,
|
|
@@ -3381,7 +3412,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3381
3412
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, isProd, isServer, environment })=>{
|
|
3382
3413
|
let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
|
|
3383
3414
|
var _context_devServer, _context_devServer1, _context_devServer2;
|
|
3384
|
-
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;
|
|
3415
|
+
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;
|
|
3385
3416
|
if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
|
|
3386
3417
|
else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
|
|
3387
3418
|
else if (!0 === dev.assetPrefix) {
|
|
@@ -4197,7 +4228,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4197
4228
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
4198
4229
|
var _utils_environment_config_tools;
|
|
4199
4230
|
rslog_index_js_namespaceObject.logger.debug('modify Rspack config');
|
|
4200
|
-
let [modifiedConfig] = await context.hooks.modifyRspackConfig.
|
|
4231
|
+
let [modifiedConfig] = await context.hooks.modifyRspackConfig.callChain({
|
|
4201
4232
|
environment: utils.environment.name,
|
|
4202
4233
|
args: [
|
|
4203
4234
|
rspackConfig,
|
|
@@ -4275,14 +4306,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4275
4306
|
}
|
|
4276
4307
|
async function modifyRsbuildConfig(context) {
|
|
4277
4308
|
rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config');
|
|
4278
|
-
let [modified] = await context.hooks.modifyRsbuildConfig.
|
|
4309
|
+
let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
|
|
4279
4310
|
mergeRsbuildConfig: mergeRsbuildConfig
|
|
4280
4311
|
});
|
|
4281
4312
|
context.config = modified, rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config done');
|
|
4282
4313
|
}
|
|
4283
4314
|
async function modifyEnvironmentConfig(context, config, name) {
|
|
4284
4315
|
rslog_index_js_namespaceObject.logger.debug(`modify Rsbuild environment(${name}) config`);
|
|
4285
|
-
let [modified] = await context.hooks.modifyEnvironmentConfig.
|
|
4316
|
+
let [modified] = await context.hooks.modifyEnvironmentConfig.callChain({
|
|
4286
4317
|
environment: name,
|
|
4287
4318
|
args: [
|
|
4288
4319
|
config,
|
|
@@ -5239,6 +5270,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5239
5270
|
};
|
|
5240
5271
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
5241
5272
|
res.statusCode = 404, res.end();
|
|
5273
|
+
}, optionsFallbackMiddleware = (req, res, next)=>{
|
|
5274
|
+
if ('OPTIONS' === req.method) {
|
|
5275
|
+
res.statusCode = 204, res.setHeader('Content-Length', '0'), res.end();
|
|
5276
|
+
return;
|
|
5277
|
+
}
|
|
5278
|
+
next();
|
|
5242
5279
|
}, middlewares_isFileExists = async (filePath, outputFileSystem)=>new Promise((resolve)=>{
|
|
5243
5280
|
outputFileSystem.stat(filePath, (_error, stats)=>{
|
|
5244
5281
|
resolve(null == stats ? void 0 : stats.isFile());
|
|
@@ -5357,12 +5394,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5357
5394
|
let opts = {
|
|
5358
5395
|
context,
|
|
5359
5396
|
changeOrigin: !0,
|
|
5360
|
-
logLevel: 'warn'
|
|
5397
|
+
logLevel: 'warn',
|
|
5398
|
+
logProvider: ()=>rslog_index_js_namespaceObject.logger
|
|
5361
5399
|
};
|
|
5362
5400
|
'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
|
|
5363
5401
|
}
|
|
5364
|
-
let handleError = (err)=>rslog_index_js_namespaceObject.logger.error(err);
|
|
5365
|
-
for (let opts of ret)opts.onError ??= handleError;
|
|
5366
5402
|
return ret;
|
|
5367
5403
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/http-proxy-middleware/index.js"));
|
|
5368
5404
|
for (let opts of formattedOptions){
|
|
@@ -5391,7 +5427,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5391
5427
|
before,
|
|
5392
5428
|
after
|
|
5393
5429
|
};
|
|
5394
|
-
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
5430
|
+
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments, postCallbacks })=>{
|
|
5395
5431
|
let upgradeEvents = [];
|
|
5396
5432
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
5397
5433
|
var _parseUrl;
|
|
@@ -5434,6 +5470,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5434
5470
|
});
|
|
5435
5471
|
middlewares.push(assetMiddleware);
|
|
5436
5472
|
}
|
|
5473
|
+
for (let callback of postCallbacks)callback();
|
|
5437
5474
|
if (compileMiddlewareAPI && middlewares.push(getHtmlFallbackMiddleware({
|
|
5438
5475
|
distPath,
|
|
5439
5476
|
callback: compileMiddlewareAPI.middleware,
|
|
@@ -5443,13 +5480,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5443
5480
|
let { default: connectHistoryApiFallback } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect-history-api-fallback/index.js")), historyApiFallbackMiddleware = connectHistoryApiFallback(!0 === server.historyApiFallback ? {} : server.historyApiFallback);
|
|
5444
5481
|
middlewares.push(historyApiFallbackMiddleware), (null == compileMiddlewareAPI ? void 0 : compileMiddlewareAPI.middleware) && middlewares.push(compileMiddlewareAPI.middleware);
|
|
5445
5482
|
}
|
|
5446
|
-
return middlewares.push(faviconFallbackMiddleware),
|
|
5447
|
-
if ('OPTIONS' === req.method) {
|
|
5448
|
-
res.statusCode = 204, res.setHeader('Content-Length', '0'), res.end();
|
|
5449
|
-
return;
|
|
5450
|
-
}
|
|
5451
|
-
next();
|
|
5452
|
-
}), {
|
|
5483
|
+
return middlewares.push(faviconFallbackMiddleware), {
|
|
5453
5484
|
onUpgrade: (...args)=>{
|
|
5454
5485
|
for (let cb of upgradeEvents)cb(...args);
|
|
5455
5486
|
}
|
|
@@ -5539,7 +5570,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5539
5570
|
config,
|
|
5540
5571
|
clearCache: !0
|
|
5541
5572
|
}), closeServer = async ()=>{
|
|
5542
|
-
await options.context.hooks.onCloseDevServer.
|
|
5573
|
+
await options.context.hooks.onCloseDevServer.callBatch(), await Promise.all([
|
|
5543
5574
|
null == devMiddlewares ? void 0 : devMiddlewares.close(),
|
|
5544
5575
|
null == fileWatcher ? void 0 : fileWatcher.close()
|
|
5545
5576
|
]);
|
|
@@ -5574,22 +5605,23 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5574
5605
|
environment
|
|
5575
5606
|
}))
|
|
5576
5607
|
}
|
|
5577
|
-
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(),
|
|
5608
|
+
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), httpServer = await createHttpServer({
|
|
5609
|
+
serverConfig: config.server,
|
|
5610
|
+
middlewares
|
|
5611
|
+
}), devServerAPI = {
|
|
5578
5612
|
port,
|
|
5579
5613
|
middlewares,
|
|
5580
5614
|
environments: environmentAPI,
|
|
5615
|
+
httpServer,
|
|
5581
5616
|
listen: async ()=>{
|
|
5582
|
-
let
|
|
5583
|
-
serverConfig: config.server,
|
|
5584
|
-
middlewares
|
|
5585
|
-
}), serverTerminator = getServerTerminator(httpServer);
|
|
5617
|
+
let serverTerminator = getServerTerminator(httpServer);
|
|
5586
5618
|
return rslog_index_js_namespaceObject.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5587
5619
|
httpServer.listen({
|
|
5588
5620
|
host,
|
|
5589
5621
|
port
|
|
5590
5622
|
}, async (err)=>{
|
|
5591
5623
|
if (err) throw err;
|
|
5592
|
-
middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade), rslog_index_js_namespaceObject.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5624
|
+
middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade), rslog_index_js_namespaceObject.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5593
5625
|
port,
|
|
5594
5626
|
urls: urls.map((item)=>item.url),
|
|
5595
5627
|
server: {
|
|
@@ -5600,7 +5632,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5600
5632
|
});
|
|
5601
5633
|
},
|
|
5602
5634
|
afterListen: async ()=>{
|
|
5603
|
-
await options.context.hooks.onAfterStartDevServer.
|
|
5635
|
+
await options.context.hooks.onAfterStartDevServer.callBatch({
|
|
5604
5636
|
port,
|
|
5605
5637
|
routes,
|
|
5606
5638
|
environments: options.context.environments
|
|
@@ -5612,11 +5644,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5612
5644
|
close: closeServer,
|
|
5613
5645
|
printUrls,
|
|
5614
5646
|
open: openPage
|
|
5615
|
-
}
|
|
5616
|
-
await options.context.hooks.onBeforeStartDevServer.call({
|
|
5647
|
+
}, postCallbacks = (await options.context.hooks.onBeforeStartDevServer.callBatch({
|
|
5617
5648
|
server: devServerAPI,
|
|
5618
5649
|
environments: options.context.environments
|
|
5619
|
-
})
|
|
5650
|
+
})).filter((item)=>'function' == typeof item);
|
|
5651
|
+
runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5620
5652
|
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
5621
5653
|
for (let item of (fileWatcher = await setupWatchFiles({
|
|
5622
5654
|
dev: devConfig,
|
|
@@ -5632,14 +5664,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5632
5664
|
output: {
|
|
5633
5665
|
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5634
5666
|
},
|
|
5635
|
-
outputFileSystem
|
|
5667
|
+
outputFileSystem,
|
|
5668
|
+
postCallbacks
|
|
5636
5669
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5637
5670
|
return rslog_index_js_namespaceObject.logger.debug('create dev server done'), devServerAPI;
|
|
5638
5671
|
}
|
|
5639
5672
|
async function createCompiler_createCompiler(options) {
|
|
5640
5673
|
rslog_index_js_namespaceObject.logger.debug('create compiler');
|
|
5641
5674
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
5642
|
-
if (await context.hooks.onBeforeCreateCompiler.
|
|
5675
|
+
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
5643
5676
|
bundlerConfigs: rspackConfigs,
|
|
5644
5677
|
environments: context.environments
|
|
5645
5678
|
}), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
|
|
@@ -5678,7 +5711,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5678
5711
|
compiler,
|
|
5679
5712
|
bundlerConfigs: rspackConfigs,
|
|
5680
5713
|
MultiStatsCtor: core_namespaceObject.rspack.MultiStats
|
|
5681
|
-
}), await context.hooks.onAfterCreateCompiler.
|
|
5714
|
+
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
5682
5715
|
compiler,
|
|
5683
5716
|
environments: context.environments
|
|
5684
5717
|
}), rslog_index_js_namespaceObject.logger.debug('create compiler done'), {
|
|
@@ -5808,7 +5841,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5808
5841
|
let { default: connectHistoryApiFallback } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect-history-api-fallback/index.js")), historyApiFallbackMiddleware = connectHistoryApiFallback(!0 === historyApiFallback ? {} : historyApiFallback);
|
|
5809
5842
|
this.middlewares.use(historyApiFallbackMiddleware), await this.applyStaticAssetMiddleware();
|
|
5810
5843
|
}
|
|
5811
|
-
this.middlewares.use(faviconFallbackMiddleware);
|
|
5844
|
+
this.middlewares.use(faviconFallbackMiddleware), this.middlewares.use(optionsFallbackMiddleware), this.middlewares.use(notFoundMiddleware);
|
|
5812
5845
|
}
|
|
5813
5846
|
async applyStaticAssetMiddleware() {
|
|
5814
5847
|
let { output: { path, assetPrefixes }, serverConfig: { htmlFallback } } = this.options, { default: sirv } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/sirv/index.js")), assetMiddleware = sirv(path, {
|
|
@@ -5842,7 +5875,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5842
5875
|
},
|
|
5843
5876
|
serverConfig
|
|
5844
5877
|
}, middlewares);
|
|
5845
|
-
await context.hooks.onBeforeStartProdServer.
|
|
5878
|
+
await context.hooks.onBeforeStartProdServer.callBatch();
|
|
5846
5879
|
let httpServer = await createHttpServer({
|
|
5847
5880
|
serverConfig,
|
|
5848
5881
|
middlewares: server.middlewares
|
|
@@ -5853,7 +5886,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5853
5886
|
port
|
|
5854
5887
|
}, async ()=>{
|
|
5855
5888
|
let routes = getRoutes(context);
|
|
5856
|
-
await context.hooks.onAfterStartProdServer.
|
|
5889
|
+
await context.hooks.onAfterStartProdServer.callBatch({
|
|
5857
5890
|
port,
|
|
5858
5891
|
routes,
|
|
5859
5892
|
environments: context.environments
|
|
@@ -5912,7 +5945,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5912
5945
|
pluginFileSize(),
|
|
5913
5946
|
pluginCleanOutput(),
|
|
5914
5947
|
pluginAsset(),
|
|
5915
|
-
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.
|
|
5948
|
+
pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.callChain({
|
|
5916
5949
|
environment,
|
|
5917
5950
|
args
|
|
5918
5951
|
}))[0]),
|
|
@@ -6182,7 +6215,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6182
6215
|
});
|
|
6183
6216
|
}, onExitListened = !1, onExit = (cb)=>{
|
|
6184
6217
|
onExitListened || (process.on('exit', ()=>{
|
|
6185
|
-
hooks.onExit.
|
|
6218
|
+
hooks.onExit.callBatch();
|
|
6186
6219
|
}), onExitListened = !0), hooks.onExit.tap(cb);
|
|
6187
6220
|
};
|
|
6188
6221
|
return (environment)=>({
|
|
@@ -6260,7 +6293,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6260
6293
|
return {
|
|
6261
6294
|
...buildInstance,
|
|
6262
6295
|
close: async ()=>{
|
|
6263
|
-
await context.hooks.onCloseBuild.
|
|
6296
|
+
await context.hooks.onCloseBuild.callBatch(), await buildInstance.close();
|
|
6264
6297
|
}
|
|
6265
6298
|
};
|
|
6266
6299
|
},
|
|
@@ -6655,12 +6688,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6655
6688
|
}
|
|
6656
6689
|
}(), process.title = 'rsbuild-node';
|
|
6657
6690
|
let { npm_execpath } = process.env;
|
|
6658
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6691
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.10\n`);
|
|
6659
6692
|
}();
|
|
6660
6693
|
try {
|
|
6661
6694
|
!function() {
|
|
6662
6695
|
let cli = dist('rsbuild');
|
|
6663
|
-
cli.help(), cli.version("1.2.
|
|
6696
|
+
cli.help(), cli.version("1.2.10"), applyCommonOptions(cli);
|
|
6664
6697
|
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');
|
|
6665
6698
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6666
6699
|
try {
|
|
@@ -6711,7 +6744,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6711
6744
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6712
6745
|
}
|
|
6713
6746
|
}
|
|
6714
|
-
let src_rslib_entry_version = "1.2.
|
|
6747
|
+
let src_rslib_entry_version = "1.2.10";
|
|
6715
6748
|
})();
|
|
6716
6749
|
var __webpack_export_target__ = exports;
|
|
6717
6750
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|