@rsbuild/core 1.2.18 → 1.3.0-beta.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 +20 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/client/overlay.js +9 -6
- package/dist/index.cjs +121 -131
- package/dist/index.js +121 -131
- package/dist-types/configChain.d.ts +1 -3
- package/dist-types/createContext.d.ts +2 -2
- package/dist-types/index.d.ts +1 -1
- package/dist-types/loadEnv.d.ts +2 -1
- package/dist-types/provider/build.d.ts +1 -0
- package/dist-types/server/helper.d.ts +10 -0
- package/dist-types/types/config.d.ts +9 -0
- package/dist-types/types/rsbuild.d.ts +14 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1327,7 +1327,7 @@ var __webpack_exports__ = {};
|
|
|
1327
1327
|
warnings: getAllStatsWarnings(statsData)
|
|
1328
1328
|
}, verbose);
|
|
1329
1329
|
if (warnings.length) {
|
|
1330
|
-
let title = index_js_default().bold(index_js_default().yellow('Compile
|
|
1330
|
+
let title = index_js_default().bold(index_js_default().yellow('Compile warning: \n'));
|
|
1331
1331
|
return {
|
|
1332
1332
|
message: `${title}${warnings.join('\n\n')}\n`,
|
|
1333
1333
|
level: 'warning'
|
|
@@ -1541,10 +1541,14 @@ var __webpack_exports__ = {};
|
|
|
1541
1541
|
x,
|
|
1542
1542
|
y
|
|
1543
1543
|
];
|
|
1544
|
-
if (pair.some(Array.isArray)) return [
|
|
1544
|
+
if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
|
|
1545
1545
|
...castArray(x),
|
|
1546
1546
|
...castArray(y)
|
|
1547
|
-
]
|
|
1547
|
+
] : Array.isArray(x) ? merge({
|
|
1548
|
+
patterns: x
|
|
1549
|
+
}, y, path) : merge(x, {
|
|
1550
|
+
patterns: y
|
|
1551
|
+
}, path);
|
|
1548
1552
|
if (pair.some(isFunction)) return pair;
|
|
1549
1553
|
if (!isPlainObject(x) || !isPlainObject(y)) return y;
|
|
1550
1554
|
let merged = {};
|
|
@@ -1556,43 +1560,39 @@ var __webpack_exports__ = {};
|
|
|
1556
1560
|
merged[key] = merge(x[key], y[key], childPath);
|
|
1557
1561
|
}
|
|
1558
1562
|
return merged;
|
|
1559
|
-
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? external_node_path_default().isAbsolute(envDir) ? envDir : external_node_path_default().join(cwd, envDir) : cwd
|
|
1563
|
+
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? external_node_path_default().isAbsolute(envDir) ? envDir : external_node_path_default().join(cwd, envDir) : cwd, init_loadConfig = async (root)=>{
|
|
1564
|
+
var _config_server;
|
|
1565
|
+
let { content: config, filePath } = await config_loadConfig({
|
|
1566
|
+
cwd: root,
|
|
1567
|
+
path: commonOpts.config,
|
|
1568
|
+
envMode: commonOpts.envMode,
|
|
1569
|
+
loader: commonOpts.configLoader
|
|
1570
|
+
});
|
|
1571
|
+
return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (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.open = commonOpts.open), commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
|
|
1572
|
+
...config.dev.watchFiles ? castArray(config.dev.watchFiles) : [],
|
|
1573
|
+
{
|
|
1574
|
+
paths: filePath,
|
|
1575
|
+
type: 'reload-server'
|
|
1576
|
+
}
|
|
1577
|
+
]), config;
|
|
1578
|
+
};
|
|
1560
1579
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
1561
1580
|
cliOptions && (commonOpts = cliOptions);
|
|
1562
1581
|
try {
|
|
1563
|
-
|
|
1564
|
-
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
|
|
1565
|
-
cwd: getEnvDir(root, commonOpts.envDir),
|
|
1566
|
-
mode: commonOpts.envMode
|
|
1567
|
-
}), { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
1568
|
-
cwd: root,
|
|
1569
|
-
path: commonOpts.config,
|
|
1570
|
-
envMode: commonOpts.envMode,
|
|
1571
|
-
loader: commonOpts.configLoader
|
|
1572
|
-
});
|
|
1573
|
-
if (config.source ||= {}, config.source.define = {
|
|
1574
|
-
...envs.publicVars,
|
|
1575
|
-
...config.source.define
|
|
1576
|
-
}, 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) {
|
|
1577
|
-
let { buildCache } = config.performance;
|
|
1578
|
-
!0 === buildCache ? config.performance.buildCache = {
|
|
1579
|
-
buildDependencies: envs.filePaths
|
|
1580
|
-
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs.filePaths));
|
|
1581
|
-
}
|
|
1582
|
-
let rsbuild = await createRsbuild({
|
|
1582
|
+
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
|
|
1583
1583
|
cwd: root,
|
|
1584
|
-
rsbuildConfig:
|
|
1585
|
-
environment: commonOpts.environment
|
|
1584
|
+
rsbuildConfig: ()=>init_loadConfig(root),
|
|
1585
|
+
environment: commonOpts.environment,
|
|
1586
|
+
loadEnv: {
|
|
1587
|
+
cwd: getEnvDir(root, commonOpts.envDir),
|
|
1588
|
+
mode: commonOpts.envMode
|
|
1589
|
+
}
|
|
1586
1590
|
});
|
|
1587
1591
|
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
1588
1592
|
let command = process.argv[2];
|
|
1589
1593
|
if ('dev' === command || isBuildWatch) {
|
|
1590
1594
|
var _config_dev;
|
|
1591
|
-
let files = [
|
|
1592
|
-
...envs.filePaths
|
|
1593
|
-
];
|
|
1594
|
-
configFilePath && files.push(configFilePath);
|
|
1595
|
-
let config = rsbuild.getNormalizedConfig();
|
|
1595
|
+
let files = [], config = rsbuild.getNormalizedConfig();
|
|
1596
1596
|
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
1597
1597
|
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
1598
1598
|
let paths = castArray(watchFilesConfig.paths);
|
|
@@ -1600,7 +1600,7 @@ var __webpack_exports__ = {};
|
|
|
1600
1600
|
}
|
|
1601
1601
|
watchFilesForRestart(files, root, isBuildWatch);
|
|
1602
1602
|
}
|
|
1603
|
-
}), rsbuild
|
|
1603
|
+
}), rsbuild;
|
|
1604
1604
|
} catch (err) {
|
|
1605
1605
|
if (isRestart) rslog_index_js_namespaceObject.logger.error(err);
|
|
1606
1606
|
else throw err;
|
|
@@ -2379,14 +2379,14 @@ var __webpack_exports__ = {};
|
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
2381
|
}
|
|
2382
|
-
async function createContext(options, userConfig
|
|
2382
|
+
async function createContext(options, userConfig) {
|
|
2383
2383
|
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;
|
|
2384
2384
|
return {
|
|
2385
|
-
version: "1.
|
|
2385
|
+
version: "1.3.0-beta.0",
|
|
2386
2386
|
rootPath,
|
|
2387
2387
|
distPath: '',
|
|
2388
2388
|
cachePath,
|
|
2389
|
-
bundlerType,
|
|
2389
|
+
bundlerType: userConfig.provider ? 'webpack' : 'rspack',
|
|
2390
2390
|
environments: {},
|
|
2391
2391
|
hooks: {
|
|
2392
2392
|
onExit: createAsyncHook(),
|
|
@@ -2600,8 +2600,7 @@ var __webpack_exports__ = {};
|
|
|
2600
2600
|
MINI_CSS_EXTRACT: 'mini-css-extract',
|
|
2601
2601
|
VUE_LOADER_PLUGIN: 'vue-loader-plugin',
|
|
2602
2602
|
REACT_FAST_REFRESH: 'react-fast-refresh',
|
|
2603
|
-
SUBRESOURCE_INTEGRITY: 'subresource-integrity'
|
|
2604
|
-
AUTO_SET_ROOT_SIZE: 'auto-set-root-size'
|
|
2603
|
+
SUBRESOURCE_INTEGRITY: 'subresource-integrity'
|
|
2605
2604
|
},
|
|
2606
2605
|
MINIMIZER: {
|
|
2607
2606
|
JS: 'js',
|
|
@@ -2773,7 +2772,10 @@ var __webpack_exports__ = {};
|
|
|
2773
2772
|
cache: {
|
|
2774
2773
|
type: 'persistent',
|
|
2775
2774
|
version: cacheVersion,
|
|
2776
|
-
|
|
2775
|
+
storage: {
|
|
2776
|
+
type: 'filesystem',
|
|
2777
|
+
directory: cacheDirectory
|
|
2778
|
+
},
|
|
2777
2779
|
buildDependencies: Object.values(buildDependencies).flat()
|
|
2778
2780
|
}
|
|
2779
2781
|
})) : chain.cache({
|
|
@@ -3107,7 +3109,7 @@ var __webpack_exports__ = {};
|
|
|
3107
3109
|
groupAssetsByChunk: !1,
|
|
3108
3110
|
groupAssetsByExtension: !1,
|
|
3109
3111
|
groupAssetsByEmitStatus: !1
|
|
3110
|
-
}), exclude = options.exclude ?? excludeAsset, filteredAssets = origin.assets.filter((asset)=>{
|
|
3112
|
+
}), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
|
|
3111
3113
|
let assetInfo = {
|
|
3112
3114
|
name: asset.name,
|
|
3113
3115
|
size: asset.size
|
|
@@ -3632,7 +3634,7 @@ var __webpack_exports__ = {};
|
|
|
3632
3634
|
for (let file of chunkFiles){
|
|
3633
3635
|
file.isInitial ? file.path.endsWith('.css') ? initialCSS.push(file.path) : initialJS.push(file.path) : file.path.endsWith('.css') ? asyncCSS.push(file.path) : asyncJS.push(file.path);
|
|
3634
3636
|
let relatedLICENSE = licenseMap.get(file.path);
|
|
3635
|
-
|
|
3637
|
+
if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
|
|
3636
3638
|
}
|
|
3637
3639
|
let entryManifest = {};
|
|
3638
3640
|
assets.size && (entryManifest.assets = Array.from(assets));
|
|
@@ -4654,65 +4656,27 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4654
4656
|
chain.optimization.splitChunks(splitChunksOptions);
|
|
4655
4657
|
});
|
|
4656
4658
|
}
|
|
4657
|
-
}),
|
|
4658
|
-
'stylesheet',
|
|
4659
|
-
'preload',
|
|
4660
|
-
'modulepreload'
|
|
4661
|
-
].includes(rel), pluginSri = ()=>({
|
|
4659
|
+
}), pluginSri = ()=>({
|
|
4662
4660
|
name: 'rsbuild:sri',
|
|
4663
4661
|
setup (api) {
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4662
|
+
api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
|
|
4663
|
+
if ('webpack' === api.context.bundlerType) return;
|
|
4664
|
+
let { config, htmlPaths } = environment;
|
|
4665
|
+
if (0 === Object.keys(htmlPaths).length) return;
|
|
4666
|
+
let { sri } = config.security;
|
|
4667
|
+
if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return;
|
|
4668
|
+
let crossorigin = chain.output.get('crossOriginLoading');
|
|
4669
|
+
(!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
|
|
4667
4670
|
let { algorithm = 'sha384' } = sri;
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
...tags.headTags,
|
|
4676
|
-
...tags.bodyTags
|
|
4677
|
-
]){
|
|
4678
|
-
let url = '';
|
|
4679
|
-
if (!tag.attrs || ("script" === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url)) continue;
|
|
4680
|
-
let assetName = getAssetName(url, assetPrefix);
|
|
4681
|
-
assetName && (tag.attrs.integrity ??= `${placeholder}${assetName}`);
|
|
4682
|
-
}
|
|
4683
|
-
return tags;
|
|
4684
|
-
}
|
|
4685
|
-
});
|
|
4686
|
-
let replaceIntegrity = (htmlContent, assets, algorithm, integrityCache)=>{
|
|
4687
|
-
let matches = htmlContent.matchAll(/integrity="RSBUILD_INTEGRITY_PLACEHOLDER:([^"]+)"/g), replacedHtml = htmlContent, calcIntegrity = (algorithm, assetName, data)=>{
|
|
4688
|
-
if (integrityCache.has(assetName)) return integrityCache.get(assetName);
|
|
4689
|
-
let hash = external_node_crypto_default().createHash(algorithm).update(data).digest().toString('base64'), integrity = `${algorithm}-${hash}`;
|
|
4690
|
-
return integrityCache.set(assetName, integrity), integrity;
|
|
4691
|
-
};
|
|
4692
|
-
for (let match of matches){
|
|
4693
|
-
let assetName = match[1];
|
|
4694
|
-
if (assetName) {
|
|
4695
|
-
if (assets[assetName]) {
|
|
4696
|
-
let integrity = calcIntegrity(algorithm, assetName, assets[assetName].buffer());
|
|
4697
|
-
replacedHtml = replacedHtml.replaceAll(`integrity="${placeholder}${assetName}"`, `integrity="${integrity}"`);
|
|
4698
|
-
} else rslog_index_js_namespaceObject.logger.debug(`[rsbuild:sri] failed to generate integrity for ${assetName}.`), replacedHtml = replacedHtml.replace(`integrity="${placeholder}${assetName}"`, '');
|
|
4671
|
+
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(core_namespaceObject.rspack.experiments.SubresourceIntegrityPlugin, [
|
|
4672
|
+
{
|
|
4673
|
+
enabled: !0,
|
|
4674
|
+
hashFuncNames: [
|
|
4675
|
+
algorithm
|
|
4676
|
+
],
|
|
4677
|
+
htmlPlugin: external_node_path_default().join(COMPILED_PATH, 'html-rspack-plugin/index.js')
|
|
4699
4678
|
}
|
|
4700
|
-
|
|
4701
|
-
return replacedHtml;
|
|
4702
|
-
};
|
|
4703
|
-
api.processAssets({
|
|
4704
|
-
stage: 'report'
|
|
4705
|
-
}, ({ assets, sources, environment })=>{
|
|
4706
|
-
let { htmlPaths } = environment;
|
|
4707
|
-
if (0 === Object.keys(htmlPaths).length) return;
|
|
4708
|
-
let algorithm = getAlgorithm(environment);
|
|
4709
|
-
if (!algorithm) return;
|
|
4710
|
-
let integrityCache = new Map();
|
|
4711
|
-
for (let asset of Object.keys(assets)){
|
|
4712
|
-
if (!HTML_REGEX.test(asset)) continue;
|
|
4713
|
-
let htmlContent = assets[asset].source();
|
|
4714
|
-
htmlContent.includes(placeholder) && (assets[asset] = new sources.RawSource(replaceIntegrity(htmlContent, assets, algorithm, integrityCache)));
|
|
4715
|
-
}
|
|
4679
|
+
]);
|
|
4716
4680
|
});
|
|
4717
4681
|
}
|
|
4718
4682
|
}), swc_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), builtinSwcLoaderName = 'builtin:swc-loader', pluginSwc = ()=>({
|
|
@@ -5362,24 +5326,24 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5362
5326
|
getStats(name) {
|
|
5363
5327
|
let curStats = this.stats[name];
|
|
5364
5328
|
if (!curStats) return null;
|
|
5365
|
-
let statsOptions = getStatsOptions(curStats.compilation.compiler)
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5329
|
+
let statsOptions = getStatsOptions(curStats.compilation.compiler), statsJson = curStats.toJson({
|
|
5330
|
+
all: !1,
|
|
5331
|
+
hash: !0,
|
|
5332
|
+
assets: !0,
|
|
5333
|
+
warnings: !0,
|
|
5334
|
+
warningsCount: !0,
|
|
5335
|
+
errors: !0,
|
|
5336
|
+
errorsCount: !0,
|
|
5337
|
+
errorDetails: !1,
|
|
5338
|
+
entrypoints: !0,
|
|
5339
|
+
children: !0,
|
|
5340
|
+
moduleTrace: !0,
|
|
5341
|
+
...statsOptions
|
|
5342
|
+
});
|
|
5343
|
+
return statsJson ? {
|
|
5344
|
+
statsJson,
|
|
5381
5345
|
root: curStats.compilation.compiler.options.context
|
|
5382
|
-
};
|
|
5346
|
+
} : null;
|
|
5383
5347
|
}
|
|
5384
5348
|
sendStats({ force = !1, compilationId }) {
|
|
5385
5349
|
let result = this.getStats(compilationId);
|
|
@@ -6468,7 +6432,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6468
6432
|
rspackConfigs
|
|
6469
6433
|
};
|
|
6470
6434
|
}
|
|
6471
|
-
let build_build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
6435
|
+
let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
6472
6436
|
let compiler, bundlerConfigs;
|
|
6473
6437
|
let { context } = initOptions;
|
|
6474
6438
|
if (customCompiler) compiler = customCompiler;
|
|
@@ -6493,7 +6457,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6493
6457
|
};
|
|
6494
6458
|
let { stats } = await new Promise((resolve, reject)=>{
|
|
6495
6459
|
compiler.run((err, stats)=>{
|
|
6496
|
-
err ? reject(err) : (null == stats ? void 0 : stats.hasErrors()) ? reject(Error(
|
|
6460
|
+
err ? reject(err) : (null == stats ? void 0 : stats.hasErrors()) ? reject(Error(RSPACK_BUILD_ERROR)) : compiler.close((closeErr)=>{
|
|
6497
6461
|
closeErr && rslog_index_js_namespaceObject.logger.error(closeErr), resolve({
|
|
6498
6462
|
stats
|
|
6499
6463
|
});
|
|
@@ -6789,10 +6753,34 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6789
6753
|
}
|
|
6790
6754
|
async function createRsbuild(options = {}) {
|
|
6791
6755
|
let plugins;
|
|
6792
|
-
let
|
|
6756
|
+
let envs = options.loadEnv ? loadEnv({
|
|
6757
|
+
cwd: options.cwd,
|
|
6758
|
+
...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
|
|
6759
|
+
}) : null, config = isFunction(options.rsbuildConfig) ? await options.rsbuildConfig() : options.rsbuildConfig || {};
|
|
6760
|
+
!function(config, envs) {
|
|
6761
|
+
var _config_performance;
|
|
6762
|
+
if (null !== envs) {
|
|
6763
|
+
if (config.source ||= {}, config.source.define = {
|
|
6764
|
+
...envs.publicVars,
|
|
6765
|
+
...config.source.define
|
|
6766
|
+
}, 0 !== envs.filePaths.length && (config.dev ||= {}, config.dev.watchFiles = [
|
|
6767
|
+
...config.dev.watchFiles ? castArray(config.dev.watchFiles) : [],
|
|
6768
|
+
{
|
|
6769
|
+
paths: envs.filePaths,
|
|
6770
|
+
type: 'reload-server'
|
|
6771
|
+
}
|
|
6772
|
+
], null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache)) {
|
|
6773
|
+
let { buildCache } = config.performance;
|
|
6774
|
+
!0 === buildCache ? config.performance.buildCache = {
|
|
6775
|
+
buildDependencies: envs.filePaths
|
|
6776
|
+
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs.filePaths));
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
}(config, envs);
|
|
6780
|
+
let resolvedOptions = {
|
|
6793
6781
|
cwd: process.cwd(),
|
|
6794
|
-
|
|
6795
|
-
|
|
6782
|
+
...options,
|
|
6783
|
+
rsbuildConfig: config
|
|
6796
6784
|
}, pluginManager = (plugins = [], {
|
|
6797
6785
|
getPlugins: (options = {
|
|
6798
6786
|
environment: RSBUILD_ALL_ENVIRONMENT_SYMBOL
|
|
@@ -6844,7 +6832,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6844
6832
|
isPluginExists: (pluginName, options = {
|
|
6845
6833
|
environment: RSBUILD_ALL_ENVIRONMENT_SYMBOL
|
|
6846
6834
|
})=>!!plugins.find((plugin)=>plugin.instance.name === pluginName && isPluginMatchEnvironment(plugin.environment, options.environment))
|
|
6847
|
-
}), context = await createContext(
|
|
6835
|
+
}), context = await createContext(resolvedOptions, config), getPluginAPI = function({ context, pluginManager }) {
|
|
6848
6836
|
let { hooks } = context, publicContext = function(context) {
|
|
6849
6837
|
let exposedKeys = [
|
|
6850
6838
|
'version',
|
|
@@ -7025,10 +7013,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7025
7013
|
context.getPluginAPI = getPluginAPI;
|
|
7026
7014
|
let globalPluginAPI = getPluginAPI();
|
|
7027
7015
|
rslog_index_js_namespaceObject.logger.debug('add default plugins'), await applyDefaultPlugins(pluginManager, context), rslog_index_js_namespaceObject.logger.debug('add default plugins done');
|
|
7028
|
-
let provider =
|
|
7016
|
+
let provider = config.provider || rspackProvider, providerInstance = await provider({
|
|
7029
7017
|
context,
|
|
7030
7018
|
pluginManager,
|
|
7031
|
-
rsbuildOptions,
|
|
7019
|
+
rsbuildOptions: resolvedOptions,
|
|
7032
7020
|
helpers: provider_helpers_namespaceObject
|
|
7033
7021
|
}), rsbuild = {
|
|
7034
7022
|
build: async (...args)=>{
|
|
@@ -7086,19 +7074,21 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7086
7074
|
'initConfigs',
|
|
7087
7075
|
'inspectConfig'
|
|
7088
7076
|
])
|
|
7089
|
-
}
|
|
7077
|
+
};
|
|
7078
|
+
envs && (rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup));
|
|
7079
|
+
let getFlattenedPlugins = async (pluginOptions)=>{
|
|
7090
7080
|
let plugins = pluginOptions;
|
|
7091
7081
|
do plugins = (await Promise.all(plugins)).flat(Number.POSITIVE_INFINITY);
|
|
7092
7082
|
while (plugins.some((v)=>(0, types_namespaceObject.isPromise)(v)));
|
|
7093
7083
|
return plugins;
|
|
7094
7084
|
};
|
|
7095
|
-
if (
|
|
7096
|
-
let plugins = await getFlattenedPlugins(
|
|
7085
|
+
if (config.plugins) {
|
|
7086
|
+
let plugins = await getFlattenedPlugins(config.plugins);
|
|
7097
7087
|
rsbuild.addPlugins(plugins);
|
|
7098
7088
|
}
|
|
7099
|
-
return
|
|
7100
|
-
if (!
|
|
7101
|
-
let plugins = await getFlattenedPlugins(
|
|
7089
|
+
return config.environments && await Promise.all(Object.entries(config.environments).map(async ([name, environmentConfig])=>{
|
|
7090
|
+
if (!environmentConfig.plugins || context.specifiedEnvironments && !context.specifiedEnvironments.includes(name)) return;
|
|
7091
|
+
let plugins = await getFlattenedPlugins(environmentConfig.plugins);
|
|
7102
7092
|
rsbuild.addPlugins(plugins, {
|
|
7103
7093
|
environment: name
|
|
7104
7094
|
});
|
|
@@ -7432,13 +7422,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7432
7422
|
}
|
|
7433
7423
|
}(), process.title = 'rsbuild-node';
|
|
7434
7424
|
let { npm_execpath } = process.env;
|
|
7435
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.
|
|
7425
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.0-beta.0\n`);
|
|
7436
7426
|
}();
|
|
7437
7427
|
try {
|
|
7438
7428
|
!function() {
|
|
7439
7429
|
let cli = cac_dist('rsbuild');
|
|
7440
|
-
cli.help(), cli.version("1.
|
|
7441
|
-
let devCommand = cli.command('
|
|
7430
|
+
cli.help(), cli.version("1.3.0-beta.0"), applyCommonOptions(cli);
|
|
7431
|
+
let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
7442
7432
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7443
7433
|
try {
|
|
7444
7434
|
let rsbuild = await init({
|
|
@@ -7458,7 +7448,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7458
7448
|
}));
|
|
7459
7449
|
buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
|
|
7460
7450
|
} catch (err) {
|
|
7461
|
-
rslog_index_js_namespaceObject.logger.error('Failed to build.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7451
|
+
err instanceof Error && err.message === RSPACK_BUILD_ERROR || rslog_index_js_namespaceObject.logger.error('Failed to build.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7462
7452
|
}
|
|
7463
7453
|
}), previewCommand.action(async (options)=>{
|
|
7464
7454
|
try {
|
|
@@ -7488,7 +7478,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7488
7478
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7489
7479
|
}
|
|
7490
7480
|
}
|
|
7491
|
-
let src_rslib_entry_version = "1.
|
|
7481
|
+
let src_rslib_entry_version = "1.3.0-beta.0";
|
|
7492
7482
|
})();
|
|
7493
7483
|
var __webpack_export_target__ = exports;
|
|
7494
7484
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|