@rsbuild/core 2.2.0-beta.1 → 2.2.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/dist/626.js +156 -92
- package/dist/helpers/restartManager.d.ts +2 -0
- package/dist/manifest-plugin.js +1 -1
- package/dist/server/helper.d.ts +1 -1
- package/dist/server/runner/basic.d.ts +4 -8
- package/dist/server/runner/type.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
277: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const { HtmlWebpackChildCompiler } = __nccwpck_require__(
|
|
5
|
+
const { HtmlWebpackChildCompiler } = __nccwpck_require__(254);
|
|
6
6
|
const compilerMap = new WeakMap();
|
|
7
7
|
class CachedChildCompilation {
|
|
8
8
|
constructor(compiler) {
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
}
|
|
312
312
|
module.exports = { CachedChildCompilation };
|
|
313
313
|
},
|
|
314
|
-
|
|
314
|
+
254: (module) => {
|
|
315
315
|
"use strict";
|
|
316
316
|
class HtmlWebpackChildCompiler {
|
|
317
317
|
constructor(templates) {
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
}
|
|
481
481
|
module.exports = { HtmlWebpackChildCompiler };
|
|
482
482
|
},
|
|
483
|
-
|
|
483
|
+
94: (module) => {
|
|
484
484
|
"use strict";
|
|
485
485
|
module.exports = {};
|
|
486
486
|
module.exports.none = (chunks) => chunks;
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
};
|
|
500
500
|
module.exports.auto = module.exports.none;
|
|
501
501
|
},
|
|
502
|
-
|
|
502
|
+
857: (module) => {
|
|
503
503
|
"use strict";
|
|
504
504
|
module.exports = function (err) {
|
|
505
505
|
return {
|
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
};
|
|
524
524
|
};
|
|
525
525
|
},
|
|
526
|
-
|
|
526
|
+
672: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
527
527
|
"use strict";
|
|
528
528
|
const { AsyncSeriesWaterfallHook } = __nccwpck_require__(517);
|
|
529
529
|
const htmlWebpackPluginHooksMap = new WeakMap();
|
|
@@ -549,7 +549,7 @@
|
|
|
549
549
|
}
|
|
550
550
|
module.exports = { getHtmlRspackPluginHooks };
|
|
551
551
|
},
|
|
552
|
-
|
|
552
|
+
861: (module) => {
|
|
553
553
|
const voidTags = [
|
|
554
554
|
"area",
|
|
555
555
|
"base",
|
|
@@ -617,19 +617,19 @@
|
|
|
617
617
|
htmlTagObjectToString,
|
|
618
618
|
};
|
|
619
619
|
},
|
|
620
|
-
|
|
620
|
+
920: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
621
621
|
"use strict";
|
|
622
622
|
const promisify = __nccwpck_require__(23).promisify;
|
|
623
623
|
const vm = __nccwpck_require__(154);
|
|
624
624
|
const fs = __nccwpck_require__(896);
|
|
625
625
|
const path = __nccwpck_require__(928);
|
|
626
|
-
const { CachedChildCompilation } = __nccwpck_require__(
|
|
626
|
+
const { CachedChildCompilation } = __nccwpck_require__(277);
|
|
627
627
|
const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
|
|
628
|
-
__nccwpck_require__(
|
|
629
|
-
const prettyError = __nccwpck_require__(
|
|
630
|
-
const chunkSorter = __nccwpck_require__(
|
|
628
|
+
__nccwpck_require__(861);
|
|
629
|
+
const prettyError = __nccwpck_require__(857);
|
|
630
|
+
const chunkSorter = __nccwpck_require__(94);
|
|
631
631
|
const getHtmlRspackPluginHooks =
|
|
632
|
-
__nccwpck_require__(
|
|
632
|
+
__nccwpck_require__(672).getHtmlRspackPluginHooks;
|
|
633
633
|
const WITH_PLACEHOLDER = "function __with_placeholder__";
|
|
634
634
|
class HtmlRspackPlugin {
|
|
635
635
|
constructor(userOptions = {}) {
|
|
@@ -2403,6 +2403,6 @@
|
|
|
2403
2403
|
}
|
|
2404
2404
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
2405
2405
|
__nccwpck_require__.ab = __dirname + "/";
|
|
2406
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
2406
|
+
var __webpack_exports__ = __nccwpck_require__(920);
|
|
2407
2407
|
module.exports = __webpack_exports__;
|
|
2408
2408
|
})();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = __nccwpck_require__(
|
|
4
|
+
871: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
module.exports = __nccwpck_require__(737)["default"];
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
737: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8
8
|
var __webpack_unused_export__;
|
|
9
9
|
__webpack_unused_export__ = { value: true };
|
|
10
10
|
exports["default"] = loader;
|
|
11
11
|
var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(756);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
14
|
return e && e.__esModule ? e : { default: e };
|
|
15
15
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
callback(null, result.css, map, { ast });
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
|
|
182
|
+
756: (module, exports, __nccwpck_require__) => {
|
|
183
183
|
module = __nccwpck_require__.nmd(module);
|
|
184
184
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
185
|
exports.exec = exec;
|
|
@@ -716,6 +716,6 @@
|
|
|
716
716
|
})();
|
|
717
717
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
718
718
|
__nccwpck_require__.ab = __dirname + "/";
|
|
719
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
719
|
+
var __webpack_exports__ = __nccwpck_require__(871);
|
|
720
720
|
module.exports = __webpack_exports__;
|
|
721
721
|
})();
|
package/dist/626.js
CHANGED
|
@@ -2996,7 +2996,7 @@ let withDefaultConfig = async (rootPath, userConfig)=>{
|
|
|
2996
2996
|
await isFileExists(tsconfigPath) && (config.source.tsconfigPath = tsconfigPath);
|
|
2997
2997
|
}
|
|
2998
2998
|
return config;
|
|
2999
|
-
}, exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
2999
|
+
}, restartPorts = new WeakMap(), exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
3000
3000
|
function exit(exitCode, type) {
|
|
3001
3001
|
if (!isCalled) {
|
|
3002
3002
|
for (let callback of (isCalled = !0, exitHook_callbacks))callback(exitCode);
|
|
@@ -3425,7 +3425,7 @@ function createPublicContext(context) {
|
|
|
3425
3425
|
async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
3426
3426
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, hooks = initHooks();
|
|
3427
3427
|
return {
|
|
3428
|
-
version: "2.2.0-
|
|
3428
|
+
version: "2.2.0-rc.0",
|
|
3429
3429
|
rootPath,
|
|
3430
3430
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3431
3431
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -3439,9 +3439,16 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3439
3439
|
publicPathnames: [],
|
|
3440
3440
|
hooks,
|
|
3441
3441
|
restartManager: (({ onRestart, restart })=>{
|
|
3442
|
-
let cleanups = new Set();
|
|
3442
|
+
let port, cleanups = new Set();
|
|
3443
3443
|
return {
|
|
3444
3444
|
canRestart: !!restart,
|
|
3445
|
+
setPort (nextPort) {
|
|
3446
|
+
port = nextPort;
|
|
3447
|
+
},
|
|
3448
|
+
inheritPort (options) {
|
|
3449
|
+
let inheritedPort = options ? restartPorts.get(options) : void 0;
|
|
3450
|
+
return options && restartPorts.delete(options), inheritedPort;
|
|
3451
|
+
},
|
|
3445
3452
|
registerCleanup: (cleanup)=>(cleanups.add(cleanup), ()=>{
|
|
3446
3453
|
cleanups.delete(cleanup);
|
|
3447
3454
|
}),
|
|
@@ -3462,7 +3469,13 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3462
3469
|
hasError || (hasError = !0, firstError = error);
|
|
3463
3470
|
}
|
|
3464
3471
|
if (hasError) throw firstError;
|
|
3465
|
-
return restart(context);
|
|
3472
|
+
if ('dev' !== context.action || void 0 === port) return restart(context);
|
|
3473
|
+
restartPorts.set(context.options, port);
|
|
3474
|
+
try {
|
|
3475
|
+
return await restart(context);
|
|
3476
|
+
} finally{
|
|
3477
|
+
restartPorts.delete(context.options);
|
|
3478
|
+
}
|
|
3466
3479
|
}
|
|
3467
3480
|
};
|
|
3468
3481
|
})({
|
|
@@ -5460,7 +5473,7 @@ let entryNameSymbol = Symbol('entryName'), VOID_TAGS = [
|
|
|
5460
5473
|
}, getTagPriority = (tag, tagConfig)=>{
|
|
5461
5474
|
let priority = tag.head ?? HEAD_TAGS.includes(tag.tag) ? -2 : 2, append = tag.append ?? tagConfig.append;
|
|
5462
5475
|
return 'boolean' == typeof append && (priority += append ? 1 : -1), priority;
|
|
5463
|
-
}, formatBasicTag = (tag)=>({
|
|
5476
|
+
}, sortTags = (tags, tagConfig)=>tags.sort((tag1, tag2)=>getTagPriority(tag1, tagConfig) - getTagPriority(tag2, tagConfig)), formatBasicTag = (tag)=>({
|
|
5464
5477
|
tag: tag.tagName,
|
|
5465
5478
|
attrs: tag.attributes,
|
|
5466
5479
|
children: tag.innerHTML,
|
|
@@ -5597,8 +5610,9 @@ class RsbuildHtmlPlugin {
|
|
|
5597
5610
|
entryName,
|
|
5598
5611
|
outputName: data.outputName,
|
|
5599
5612
|
publicPath: data.publicPath
|
|
5600
|
-
};
|
|
5601
|
-
for (let item of tagConfig.tags)isFunction(item) ? tags = item(tags, context) || tags : tags.push(item),
|
|
5613
|
+
}, shouldSort = !1;
|
|
5614
|
+
for (let item of tagConfig.tags)isFunction(item) ? (shouldSort && (tags = sortTags(tags, tagConfig)), tags = item(tags, context) || tags) : tags.push(item), shouldSort = !0;
|
|
5615
|
+
shouldSort && (tags = sortTags(tags, tagConfig));
|
|
5602
5616
|
let [headTags, bodyTags] = partition(tags, (tag)=>tag.head ?? HEAD_TAGS.includes(tag.tag));
|
|
5603
5617
|
return data.headTags = fromInjectTags(headTags), data.bodyTags = fromInjectTags(bodyTags);
|
|
5604
5618
|
})(data, tagConfig, compilation.hash ?? '', entryName), data;
|
|
@@ -5846,6 +5860,10 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5846
5860
|
port,
|
|
5847
5861
|
host
|
|
5848
5862
|
}, ()=>{
|
|
5863
|
+
if (0 === port) {
|
|
5864
|
+
let address = server.address();
|
|
5865
|
+
address && 'string' != typeof address && (port = address.port);
|
|
5866
|
+
}
|
|
5849
5867
|
found = !0, server.close(resolve);
|
|
5850
5868
|
});
|
|
5851
5869
|
});
|
|
@@ -5854,14 +5872,14 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5854
5872
|
port++, attempts++;
|
|
5855
5873
|
}
|
|
5856
5874
|
if (!found) throw Error(`${color.dim('[rsbuild:server]')} Failed to find an available port after ${tryLimits + 1} attempts, starting from ${color.yellow(original)}.`);
|
|
5857
|
-
if (port !== original && strictPort) throw Error(`${color.dim('[rsbuild:server]')} Port ${color.yellow(original)} is occupied, please choose another one.`);
|
|
5875
|
+
if (0 !== original && port !== original && strictPort) throw Error(`${color.dim('[rsbuild:server]')} Port ${color.yellow(original)} is occupied, please choose another one.`);
|
|
5858
5876
|
return port;
|
|
5859
|
-
}, resolvePort = async (config)=>{
|
|
5860
|
-
let { host, port: originalPort, strictPort } = config.server, port = await getPort({
|
|
5877
|
+
}, resolvePort = async (config, lastPort)=>{
|
|
5878
|
+
let { host, port: originalPort, strictPort } = config.server, preferredPort = 0 === originalPort ? lastPort : void 0, port = await getPort({
|
|
5861
5879
|
host,
|
|
5862
|
-
port: originalPort,
|
|
5863
|
-
strictPort
|
|
5864
|
-
}), portTip = port !== originalPort ? `port ${originalPort} is in use, ${color.yellow(`using port ${port}.`)}` : void 0;
|
|
5880
|
+
port: preferredPort ?? originalPort,
|
|
5881
|
+
strictPort: void 0 === preferredPort && strictPort
|
|
5882
|
+
}), portTip = 0 !== originalPort && port !== originalPort ? `port ${originalPort} is in use, ${color.yellow(`using port ${port}.`)}` : void 0;
|
|
5865
5883
|
return {
|
|
5866
5884
|
port,
|
|
5867
5885
|
portTip
|
|
@@ -6017,7 +6035,7 @@ async function open_open({ port, routes, config, protocol, clearCache, logger })
|
|
|
6017
6035
|
})(config);
|
|
6018
6036
|
clearCache && (openedURLs = []);
|
|
6019
6037
|
let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${protocol}://${host}:${port}`;
|
|
6020
|
-
for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url, logger), openedURLs.push(url));
|
|
6038
|
+
for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (await openBrowser(url, logger), openedURLs.push(url));
|
|
6021
6039
|
}
|
|
6022
6040
|
let getServerUrlFromClientConfig = async (config, context)=>{
|
|
6023
6041
|
let { assetPrefix } = config.dev;
|
|
@@ -6072,7 +6090,7 @@ function pluginModuleFederation() {
|
|
|
6072
6090
|
let { moduleFederation } = config;
|
|
6073
6091
|
if (moduleFederation?.options && moduleFederation.options.exposes) {
|
|
6074
6092
|
let userConfig = api.getRsbuildConfig('original');
|
|
6075
|
-
config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port
|
|
6093
|
+
config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port === void 0 || config.dev.client?.port || (config.dev.client ||= {}, config.dev.client.port = 0 === config.server.port ? '<port>' : config.server.port), userConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === config.server?.base && (config.dev.assetPrefix = !0);
|
|
6076
6094
|
}
|
|
6077
6095
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
6078
6096
|
config.moduleFederation?.options && (config.source.include = [
|
|
@@ -6166,22 +6184,35 @@ let HtmlResourceHintsPlugin_defaultOptions = {
|
|
|
6166
6184
|
type: 'async-chunks',
|
|
6167
6185
|
dedupe: !0
|
|
6168
6186
|
};
|
|
6169
|
-
function filterResourceHints(resourceHints,
|
|
6170
|
-
return resourceHints.filter((resourceHint)=>!
|
|
6187
|
+
function filterResourceHints(resourceHints, scriptSources) {
|
|
6188
|
+
return resourceHints.filter((resourceHint)=>!scriptSources.has(resourceHint.attributes.href));
|
|
6171
6189
|
}
|
|
6172
6190
|
function getResourceHintKey(resourceHint) {
|
|
6173
6191
|
return `${resourceHint.attributes.rel}:${resourceHint.attributes.href}`;
|
|
6174
6192
|
}
|
|
6175
6193
|
function mergeResourceHints(resourceHintGroups, scripts) {
|
|
6176
|
-
let links = [], seen = new Set();
|
|
6177
|
-
for (let { links: groupLinks, dedupe } of resourceHintGroups)
|
|
6178
|
-
let
|
|
6179
|
-
|
|
6194
|
+
let scriptSources, links = [], seen = new Set();
|
|
6195
|
+
for (let { links: groupLinks, dedupe } of resourceHintGroups){
|
|
6196
|
+
let filteredLinks = groupLinks;
|
|
6197
|
+
for (let link of (dedupe && (scriptSources ??= new Set(scripts.map((script)=>script.attributes.src)), filteredLinks = filterResourceHints(groupLinks, scriptSources)), filteredLinks)){
|
|
6198
|
+
let key = getResourceHintKey(link);
|
|
6199
|
+
seen.has(key) || (seen.add(key), links.push(link));
|
|
6200
|
+
}
|
|
6180
6201
|
}
|
|
6181
6202
|
return links;
|
|
6182
6203
|
}
|
|
6183
6204
|
function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
|
|
6184
|
-
let extractedChunks = extractChunks(compilation, options.type),
|
|
6205
|
+
let extractedChunks = extractChunks(compilation, options.type), htmlChunks = 'all-assets' === options.type || 1 === HTMLCount ? extractedChunks : extractedChunks.filter((chunk)=>doesChunkBelongToHtml({
|
|
6206
|
+
chunk: chunk,
|
|
6207
|
+
compilation,
|
|
6208
|
+
htmlPluginData: data,
|
|
6209
|
+
pluginOptions: options
|
|
6210
|
+
})), uniqueFiles = new Set();
|
|
6211
|
+
for (let chunk of htmlChunks)for (let files of [
|
|
6212
|
+
chunk.files,
|
|
6213
|
+
chunk.auxiliaryFiles ?? []
|
|
6214
|
+
])for (let file of files)isDev && file.endsWith('.hot-update.js') || file.endsWith('.map') || uniqueFiles.add(file);
|
|
6215
|
+
let sortedFilteredFiles = ((files, include, exclude)=>{
|
|
6185
6216
|
let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
|
|
6186
6217
|
if (include) for (let item of helpers_castArray(include))'string' == typeof item ? includeRegExp.push(new RegExp(item)) : isFunction(item) ? includeFn.push(item) : includeRegExp.push(item);
|
|
6187
6218
|
if (exclude) for (let item of helpers_castArray(exclude))'string' == typeof item ? excludeRegExp.push(new RegExp(item)) : isFunction(item) ? excludeFn.push(item) : excludeRegExp.push(item);
|
|
@@ -6195,15 +6226,7 @@ function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
|
|
|
6195
6226
|
return !0;
|
|
6196
6227
|
});
|
|
6197
6228
|
})([
|
|
6198
|
-
...
|
|
6199
|
-
chunk: chunk,
|
|
6200
|
-
compilation,
|
|
6201
|
-
htmlPluginData: data,
|
|
6202
|
-
pluginOptions: options
|
|
6203
|
-
}))).reduce((accumulated, chunk)=>accumulated.concat([
|
|
6204
|
-
...chunk.files,
|
|
6205
|
-
...chunk.auxiliaryFiles || []
|
|
6206
|
-
]), []).filter((file)=>!(isDev && file.endsWith('.hot-update.js')) && !file.endsWith('.map')))
|
|
6229
|
+
...uniqueFiles
|
|
6207
6230
|
], options.include, options.exclude).sort(), links = [], { publicPath, crossOriginLoading } = compilation.outputOptions;
|
|
6208
6231
|
for (let file of sortedFilteredFiles){
|
|
6209
6232
|
let href = ensureAssetPrefix(file, publicPath), attributes = {
|
|
@@ -7927,7 +7950,7 @@ class BasicRunner {
|
|
|
7927
7950
|
subPath: ''
|
|
7928
7951
|
};
|
|
7929
7952
|
let joinedPath = /^\.\.?\//.test(modulePath) ? node_path.join(currentDirectory, modulePath) : modulePath;
|
|
7930
|
-
return this._options.
|
|
7953
|
+
return this._options.isOutputFile(joinedPath) ? {
|
|
7931
7954
|
path: joinedPath,
|
|
7932
7955
|
content: this._options.readFileSync(joinedPath),
|
|
7933
7956
|
subPath: ((p)=>{
|
|
@@ -8086,14 +8109,18 @@ class BasicRunnerFactory {
|
|
|
8086
8109
|
let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
8087
8110
|
let runner = new BasicRunnerFactory(bundlePath).create(runnerFactoryOptions);
|
|
8088
8111
|
return await runner.run(bundlePath);
|
|
8089
|
-
}, loadBundle = async (stats, entryName, utils)=>{
|
|
8090
|
-
let
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8112
|
+
}, loadBundleStatsCache = new WeakMap(), loadBundle = async (stats, entryName, utils)=>{
|
|
8113
|
+
let loadBundleStats = loadBundleStatsCache.get(stats);
|
|
8114
|
+
loadBundleStats || (loadBundleStats = {
|
|
8115
|
+
...stats.toJson({
|
|
8116
|
+
all: !1,
|
|
8117
|
+
chunks: !0,
|
|
8118
|
+
entrypoints: !0,
|
|
8119
|
+
ids: !0,
|
|
8120
|
+
outputPath: !0
|
|
8121
|
+
})
|
|
8122
|
+
}, loadBundleStatsCache.set(stats, loadBundleStats));
|
|
8123
|
+
let { chunks, entrypoints, outputPath } = loadBundleStats;
|
|
8097
8124
|
if (!entrypoints?.[entryName]) throw Error(`${color.dim('[rsbuild:loadBundle]')} Can't find entry: ${color.yellow(entryName)}`);
|
|
8098
8125
|
let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkId)=>{
|
|
8099
8126
|
let chunk = chunks?.find((chunk)=>chunk.entry && chunk.id === entryChunkId);
|
|
@@ -8101,13 +8128,17 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
8101
8128
|
}, []);
|
|
8102
8129
|
if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
|
|
8103
8130
|
if (files.length > 1) throw Error(`${color.dim('[rsbuild:loadBundle]')} Only support load single entry chunk, but got ${color.yellow(files.length)}: ${files.join(',')}`);
|
|
8104
|
-
let
|
|
8131
|
+
let { outputFilePaths } = loadBundleStats;
|
|
8132
|
+
if (!outputFilePaths) {
|
|
8133
|
+
for (let chunk of (outputFilePaths = new Set(), chunks || []))for (let file of chunk.files)outputFilePaths.add(join(outputPath, file));
|
|
8134
|
+
loadBundleStats.outputFilePaths = outputFilePaths;
|
|
8135
|
+
}
|
|
8105
8136
|
return await runner_run({
|
|
8106
8137
|
bundlePath: files[0],
|
|
8107
8138
|
dist: outputPath,
|
|
8108
8139
|
compilerOptions: stats.compilation.options,
|
|
8109
8140
|
readFileSync: utils.readFileSync,
|
|
8110
|
-
|
|
8141
|
+
isOutputFile: (modulePath)=>outputFilePaths.has(modulePath)
|
|
8111
8142
|
});
|
|
8112
8143
|
}, createCacheableFunction = (getter)=>{
|
|
8113
8144
|
let cache = new WeakMap();
|
|
@@ -8174,7 +8205,9 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8174
8205
|
])
|
|
8175
8206
|
}, { context } = options, { logger } = context;
|
|
8176
8207
|
logger.debug('create dev server');
|
|
8177
|
-
let
|
|
8208
|
+
let isDynamicPort = 0 === config.server.port, lastPort = isDynamicPort ? context.restartManager.inheritPort(devServerOptions) : void 0, { port, portTip } = await resolvePort(config, lastPort);
|
|
8209
|
+
isDynamicPort && context.restartManager.setPort(port);
|
|
8210
|
+
let { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
|
|
8178
8211
|
context.devServer = {
|
|
8179
8212
|
hostname: host,
|
|
8180
8213
|
port,
|
|
@@ -8321,14 +8354,24 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8321
8354
|
listen: async ()=>{
|
|
8322
8355
|
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
8323
8356
|
let serverTerminator = getServerTerminator(httpServer);
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8357
|
+
logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator);
|
|
8358
|
+
try {
|
|
8359
|
+
return httpServer.listen({
|
|
8360
|
+
host,
|
|
8361
|
+
port
|
|
8362
|
+
}), await once(httpServer, 'listening'), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), state.devMiddlewares && httpServer.on('upgrade', state.devMiddlewares.onUpgrade), logger.debug('listen dev server done'), await devServer.afterListen(), {
|
|
8363
|
+
port,
|
|
8364
|
+
urls: urls.map((item)=>item.url),
|
|
8365
|
+
server: devServer
|
|
8366
|
+
};
|
|
8367
|
+
} catch (error) {
|
|
8368
|
+
try {
|
|
8369
|
+
await closeServer();
|
|
8370
|
+
} catch (closeError) {
|
|
8371
|
+
logger.error('Failed to close dev server after startup error.'), logger.error(closeError);
|
|
8372
|
+
}
|
|
8373
|
+
throw error;
|
|
8374
|
+
}
|
|
8332
8375
|
},
|
|
8333
8376
|
afterListen: async ()=>{
|
|
8334
8377
|
await context.hooks.onAfterStartDevServer.callBatch({
|
|
@@ -8446,32 +8489,42 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
8446
8489
|
for (let callback of (base && '/' !== base && middlewares.use(getBaseUrlMiddleware({
|
|
8447
8490
|
base
|
|
8448
8491
|
})), middlewares.use(assetsMiddleware), middlewares.use(getHtmlCompletionMiddleware(htmlMiddlewareOptions)), historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === historyApiFallback ? {} : historyApiFallback)), middlewares.use(assetsMiddleware)), postSetupCallbacks))await callback();
|
|
8449
|
-
|
|
8492
|
+
serverConfig.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
|
|
8450
8493
|
...htmlMiddlewareOptions,
|
|
8451
8494
|
logger
|
|
8452
|
-
})), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware)
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8495
|
+
})), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware);
|
|
8496
|
+
try {
|
|
8497
|
+
if (httpServer.listen({
|
|
8498
|
+
host,
|
|
8499
|
+
port
|
|
8500
|
+
}), await once(httpServer, 'listening'), await context.hooks.onAfterStartPreviewServer.callBatch({
|
|
8501
|
+
port,
|
|
8502
|
+
routes,
|
|
8503
|
+
environments: context.environments
|
|
8504
|
+
}), registerCleanup(closeServer), printUrls(), cliShortcutsEnabled) {
|
|
8505
|
+
let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
|
|
8506
|
+
await setupCliShortcuts({
|
|
8507
|
+
openPage,
|
|
8508
|
+
closeServer,
|
|
8509
|
+
printUrls,
|
|
8510
|
+
help: shortcutsOptions.help,
|
|
8511
|
+
customShortcuts: shortcutsOptions.custom,
|
|
8512
|
+
logger
|
|
8513
|
+
});
|
|
8514
|
+
}
|
|
8515
|
+
return !getPortSilently && portTip && logger.info(portTip), {
|
|
8516
|
+
port,
|
|
8517
|
+
urls: urls.map((item)=>item.url),
|
|
8518
|
+
server: previewServer
|
|
8519
|
+
};
|
|
8520
|
+
} catch (error) {
|
|
8521
|
+
try {
|
|
8522
|
+
await closeServer();
|
|
8523
|
+
} catch (closeError) {
|
|
8524
|
+
logger.error('Failed to close preview server after startup error.'), logger.error(closeError);
|
|
8525
|
+
}
|
|
8526
|
+
throw error;
|
|
8469
8527
|
}
|
|
8470
|
-
return !getPortSilently && portTip && logger.info(portTip), {
|
|
8471
|
-
port,
|
|
8472
|
-
urls: urls.map((item)=>item.url),
|
|
8473
|
-
server: previewServer
|
|
8474
|
-
};
|
|
8475
8528
|
}
|
|
8476
8529
|
function applyDefaultPlugins(pluginManager, context) {
|
|
8477
8530
|
pluginManager.addPlugins([
|
|
@@ -8486,7 +8539,6 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8486
8539
|
aggregateTimeout: 0
|
|
8487
8540
|
}), chain.performance.hints(!1), chain.experiments({
|
|
8488
8541
|
...chain.get('experiments'),
|
|
8489
|
-
nativeWatcher: !0,
|
|
8490
8542
|
sourceImport: !0
|
|
8491
8543
|
}), chain.module.parser.merge({
|
|
8492
8544
|
javascript: {
|
|
@@ -9336,7 +9388,19 @@ try {
|
|
|
9336
9388
|
javascript: {
|
|
9337
9389
|
dynamicImportMode: 'eager'
|
|
9338
9390
|
}
|
|
9339
|
-
}), isServer
|
|
9391
|
+
}), isServer) {
|
|
9392
|
+
if (!1 === splitChunks) chain.optimization.splitChunks(!1);
|
|
9393
|
+
else {
|
|
9394
|
+
let { preset = 'none', ...rest } = splitChunks;
|
|
9395
|
+
chain.optimization.splitChunks({
|
|
9396
|
+
chunks: 'all',
|
|
9397
|
+
...getSplitChunksByPreset(config, preset),
|
|
9398
|
+
...rest
|
|
9399
|
+
});
|
|
9400
|
+
}
|
|
9401
|
+
return;
|
|
9402
|
+
}
|
|
9403
|
+
if (isWebWorker) {
|
|
9340
9404
|
if (!1 === splitChunks || 0 === Object.keys(splitChunks).length) chain.optimization.splitChunks(!1);
|
|
9341
9405
|
else {
|
|
9342
9406
|
let { preset = 'none', ...rest } = splitChunks;
|
|
@@ -9534,11 +9598,11 @@ try {
|
|
|
9534
9598
|
{
|
|
9535
9599
|
name: 'rsbuild:server',
|
|
9536
9600
|
setup (api) {
|
|
9537
|
-
let onStartServer = ({ port, routes })=>{
|
|
9601
|
+
let onStartServer = async ({ port, routes })=>{
|
|
9538
9602
|
let config = api.getNormalizedConfig();
|
|
9539
9603
|
if (config.server.open) {
|
|
9540
9604
|
let protocol = config.server.https ? 'https' : 'http';
|
|
9541
|
-
open_open({
|
|
9605
|
+
await open_open({
|
|
9542
9606
|
port,
|
|
9543
9607
|
routes,
|
|
9544
9608
|
config,
|
|
@@ -9592,18 +9656,20 @@ try {
|
|
|
9592
9656
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
9593
9657
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
9594
9658
|
if (!1 === manifest) return;
|
|
9595
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.2.0-
|
|
9659
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.2.0-rc.0/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
9596
9660
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
9597
9661
|
let pluginOptions = {
|
|
9598
9662
|
fileName: manifestOptions.filename,
|
|
9599
9663
|
filter,
|
|
9600
9664
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
9601
9665
|
generate: (_seed, files, entries, { compilation })=>{
|
|
9602
|
-
let chunkEntries = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
|
|
9603
|
-
if (file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk))
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9666
|
+
let chunkEntries = new Map(), filePathByName = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
|
|
9667
|
+
if (filePathByName.has(file.name) || filePathByName.set(file.name, file.path), file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk)){
|
|
9668
|
+
let chunkFiles = chunkEntries.get(entryName);
|
|
9669
|
+
chunkFiles ? chunkFiles.push(file) : chunkEntries.set(entryName, [
|
|
9670
|
+
file
|
|
9671
|
+
]);
|
|
9672
|
+
}
|
|
9607
9673
|
if (file.path.endsWith('.LICENSE.txt')) {
|
|
9608
9674
|
let sourceFilePath = file.path.split('.LICENSE.txt')[0];
|
|
9609
9675
|
licenseMap.set(sourceFilePath, file.path);
|
|
@@ -9623,7 +9689,7 @@ try {
|
|
|
9623
9689
|
}
|
|
9624
9690
|
let entryManifest = {};
|
|
9625
9691
|
assets.size && (entryManifest.assets = Array.from(assets));
|
|
9626
|
-
let htmlPath =
|
|
9692
|
+
let htmlPath = filePathByName.get(htmlPaths[entryName]);
|
|
9627
9693
|
htmlPath && (entryManifest.html = [
|
|
9628
9694
|
htmlPath
|
|
9629
9695
|
]), initialJS.length && (entryManifest.initial = {
|
|
@@ -9845,9 +9911,7 @@ async function createRsbuild(options = {}) {
|
|
|
9845
9911
|
context,
|
|
9846
9912
|
pluginManager,
|
|
9847
9913
|
rsbuildOptions: resolvedOptions
|
|
9848
|
-
}, createCompiler, config,
|
|
9849
|
-
...options
|
|
9850
|
-
})).listen();
|
|
9914
|
+
}, createCompiler, config, options)).listen();
|
|
9851
9915
|
}, createDevServer = async (options)=>{
|
|
9852
9916
|
context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
|
|
9853
9917
|
let config = await initRsbuildConfig({
|
|
@@ -10088,7 +10152,7 @@ let cliState = {
|
|
|
10088
10152
|
loader: options.configLoader,
|
|
10089
10153
|
command
|
|
10090
10154
|
}), { content: config } = result;
|
|
10091
|
-
if (config.dev ||= {}, config.source ||= {}, config.server ||= {}, options.base && (config.server.base = options.base), options.root && (config.root = root), options.mode && (config.mode = options.mode), options.logLevel && (config.logLevel = options.logLevel), options.open && !config.server?.open && (config.server.open = options.open), void 0 !== options.host && (config.server.host = options.host), options.port && (config.server.port = options.port), void 0 !== options.strictPort && (config.server.strictPort = options.strictPort), void 0 !== options.distPath) {
|
|
10155
|
+
if (config.dev ||= {}, config.source ||= {}, config.server ||= {}, options.base && (config.server.base = options.base), options.root && (config.root = root), options.mode && (config.mode = options.mode), options.logLevel && (config.logLevel = options.logLevel), options.open && !config.server?.open && (config.server.open = options.open), void 0 !== options.host && (config.server.host = options.host), void 0 !== options.port && (config.server.port = options.port), void 0 !== options.strictPort && (config.server.strictPort = options.strictPort), void 0 !== options.distPath) {
|
|
10092
10156
|
config.output ||= {};
|
|
10093
10157
|
let { distPath } = config.output;
|
|
10094
10158
|
config.output.distPath = distPath && 'object' == typeof distPath ? {
|
|
@@ -10135,7 +10199,7 @@ let applyServerOptions = (command)=>{
|
|
|
10135
10199
|
};
|
|
10136
10200
|
function setupCommands(argv) {
|
|
10137
10201
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10138
|
-
cli.version("2.2.0-
|
|
10202
|
+
cli.version("2.2.0-rc.0"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
10139
10203
|
default: 'auto'
|
|
10140
10204
|
}).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
10141
10205
|
type: [
|
|
@@ -10200,7 +10264,7 @@ function setupCommands(argv) {
|
|
|
10200
10264
|
}
|
|
10201
10265
|
function showGreeting() {
|
|
10202
10266
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10203
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.0-
|
|
10267
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.0-rc.0\n`);
|
|
10204
10268
|
}
|
|
10205
10269
|
function setupLogLevel(argv) {
|
|
10206
10270
|
if (argv.length <= 3) return;
|
|
@@ -10222,5 +10286,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10222
10286
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10223
10287
|
}
|
|
10224
10288
|
}
|
|
10225
|
-
let src_version = "2.2.0-
|
|
10289
|
+
let src_version = "2.2.0-rc.0";
|
|
10226
10290
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
|
|
@@ -3,6 +3,8 @@ import type { MaybePromise } from '../types/utils.js';
|
|
|
3
3
|
type Cleanup = () => MaybePromise<void>;
|
|
4
4
|
export type RestartManager = {
|
|
5
5
|
/** Whether a restart executor is available. */ readonly canRestart: boolean;
|
|
6
|
+
/** Store the dynamic port for the next restart. */ setPort(port: number): void;
|
|
7
|
+
/** Consume the dynamic port associated with restart options. */ inheritPort(options?: object): number | undefined;
|
|
6
8
|
/** Register a cleanup callback and return a function that unregisters it. */ registerCleanup(cleanup: Cleanup): () => void;
|
|
7
9
|
/** Handle a restart request and return whether the restart succeeded. */ requestRestart(context: RestartContext): Promise<boolean>;
|
|
8
10
|
};
|