@rsbuild/core 1.3.14 → 1.3.15
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/dist/index.cjs +67 -51
- package/dist/index.js +67 -51
- package/dist-types/hooks.d.ts +2 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/plugins/html.d.ts +2 -2
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +4 -4
- package/dist-types/types/hooks.d.ts +21 -11
- package/dist-types/types/plugin.d.ts +19 -8
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2251,14 +2251,14 @@ for(var __webpack_i__ in (()=>{
|
|
|
2251
2251
|
};
|
|
2252
2252
|
context.environments[name] = new Proxy(environmentContext, {
|
|
2253
2253
|
get: (target, prop)=>target[prop],
|
|
2254
|
-
set: (
|
|
2254
|
+
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : rslog_index_js_namespaceObject.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
|
|
2255
2255
|
});
|
|
2256
2256
|
}
|
|
2257
2257
|
}
|
|
2258
2258
|
async function createContext(options, userConfig) {
|
|
2259
2259
|
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;
|
|
2260
2260
|
return {
|
|
2261
|
-
version: "1.3.
|
|
2261
|
+
version: "1.3.15",
|
|
2262
2262
|
rootPath,
|
|
2263
2263
|
distPath: '',
|
|
2264
2264
|
cachePath,
|
|
@@ -2277,6 +2277,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2277
2277
|
onBeforeStartProdServer: createAsyncHook(),
|
|
2278
2278
|
onAfterCreateCompiler: createAsyncHook(),
|
|
2279
2279
|
onBeforeCreateCompiler: createAsyncHook(),
|
|
2280
|
+
modifyHTML: createEnvironmentAsyncHook(),
|
|
2280
2281
|
modifyHTMLTags: createEnvironmentAsyncHook(),
|
|
2281
2282
|
modifyRspackConfig: createEnvironmentAsyncHook(),
|
|
2282
2283
|
modifyBundlerChain: createEnvironmentAsyncHook(),
|
|
@@ -3111,28 +3112,28 @@ for(var __webpack_i__ in (()=>{
|
|
|
3111
3112
|
showGzipHeader && rowTypes.push('Gzip');
|
|
3112
3113
|
let headerRow = rowTypes.reduce((prev, cur, index)=>{
|
|
3113
3114
|
let length = lengths[index], curLabel = cur;
|
|
3114
|
-
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel}
|
|
3115
|
-
}, '
|
|
3115
|
+
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
|
|
3116
|
+
}, '');
|
|
3116
3117
|
return index_js_default().blue(headerRow);
|
|
3117
3118
|
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
|
|
3118
3119
|
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
|
|
3119
3120
|
sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
|
|
3120
3121
|
let fileNameLabel = index_js_default().dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
|
|
3121
3122
|
fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
|
|
3122
|
-
let log =
|
|
3123
|
-
gzipSizeLabel && (log += `
|
|
3123
|
+
let log = `${fileNameLabel} ${sizeLabel}`;
|
|
3124
|
+
gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
|
|
3124
3125
|
}
|
|
3125
3126
|
if (showTotal) {
|
|
3126
3127
|
logs.push('');
|
|
3127
|
-
let log = '
|
|
3128
|
-
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += `
|
|
3128
|
+
let log = '';
|
|
3129
|
+
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
|
|
3129
3130
|
let colorFn = getAssetColor(totalGzipSize / assets.length);
|
|
3130
|
-
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += `
|
|
3131
|
+
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
|
|
3131
3132
|
}
|
|
3132
3133
|
logs.push(log);
|
|
3133
3134
|
}
|
|
3134
3135
|
} else if (showTotal) {
|
|
3135
|
-
let log =
|
|
3136
|
+
let log = `${index_js_default().magenta(totalSizeLabel)} ${totalSizeStr}`;
|
|
3136
3137
|
options.compressed && (log += index_js_default().green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
|
|
3137
3138
|
}
|
|
3138
3139
|
return logs.push(''), logs;
|
|
@@ -3156,7 +3157,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3156
3157
|
...defaultConfig,
|
|
3157
3158
|
...printFileSize
|
|
3158
3159
|
}, statsLogs = await printFileSizes(mergedConfig, multiStats[index], api.context.rootPath, environment.name);
|
|
3159
|
-
logs.
|
|
3160
|
+
logs.push(...statsLogs);
|
|
3160
3161
|
})).catch((err)=>{
|
|
3161
3162
|
rslog_index_js_namespaceObject.logger.warn('Failed to print file size.'), rslog_index_js_namespaceObject.logger.warn(err);
|
|
3162
3163
|
}), rslog_index_js_namespaceObject.logger.log(logs.join('\n'));
|
|
@@ -3299,7 +3300,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
3299
3300
|
href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
|
|
3300
3301
|
};
|
|
3301
3302
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3302
|
-
getHTMLPlugin().getCompilationHooks(compilation)
|
|
3303
|
+
let hooks = getHTMLPlugin().getCompilationHooks(compilation);
|
|
3304
|
+
hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
|
|
3303
3305
|
var _data_plugin_options, _data_plugin_options1;
|
|
3304
3306
|
let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
|
|
3305
3307
|
if (!entryName) return data;
|
|
@@ -3308,22 +3310,45 @@ for(var __webpack_i__ in (()=>{
|
|
|
3308
3310
|
let tags = {
|
|
3309
3311
|
headTags: headTags.map(formatBasicTag),
|
|
3310
3312
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
3311
|
-
},
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3313
|
+
}, context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTMLTags.callChain({
|
|
3314
|
+
environment: environment.name,
|
|
3315
|
+
args: [
|
|
3316
|
+
tags,
|
|
3317
|
+
{
|
|
3318
|
+
compiler,
|
|
3319
|
+
compilation,
|
|
3320
|
+
assetPrefix: data.publicPath,
|
|
3321
|
+
filename: data.outputName,
|
|
3322
|
+
environment
|
|
3323
|
+
}
|
|
3324
|
+
]
|
|
3325
|
+
});
|
|
3318
3326
|
return Object.assign(data, {
|
|
3319
3327
|
headTags: modified.headTags.map(fromBasicTag),
|
|
3320
3328
|
bodyTags: modified.bodyTags.map(fromBasicTag)
|
|
3321
3329
|
}), tagConfig && applyTagConfig(data, tagConfig, compilation.hash ?? '', entryName), data;
|
|
3330
|
+
}), hooks.beforeEmit.tapPromise(this.name, async (data)=>{
|
|
3331
|
+
let context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTML.callChain({
|
|
3332
|
+
environment: environment.name,
|
|
3333
|
+
args: [
|
|
3334
|
+
data.html,
|
|
3335
|
+
{
|
|
3336
|
+
compiler,
|
|
3337
|
+
compilation,
|
|
3338
|
+
filename: data.outputName,
|
|
3339
|
+
environment
|
|
3340
|
+
}
|
|
3341
|
+
]
|
|
3342
|
+
});
|
|
3343
|
+
return {
|
|
3344
|
+
...data,
|
|
3345
|
+
html: modified
|
|
3346
|
+
};
|
|
3322
3347
|
});
|
|
3323
3348
|
});
|
|
3324
3349
|
}
|
|
3325
|
-
constructor(options, getEnvironment,
|
|
3326
|
-
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "
|
|
3350
|
+
constructor(options, getEnvironment, getContext){
|
|
3351
|
+
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "getContext", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.getEnvironment = getEnvironment, this.getContext = getContext;
|
|
3327
3352
|
}
|
|
3328
3353
|
}
|
|
3329
3354
|
let getDefaultTemplateContent = (mountId)=>`<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`, existTemplatePath = new Set();
|
|
@@ -3358,7 +3383,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3358
3383
|
publicPath: !0,
|
|
3359
3384
|
tags
|
|
3360
3385
|
};
|
|
3361
|
-
}, pluginHtml = (
|
|
3386
|
+
}, pluginHtml = (context)=>({
|
|
3362
3387
|
name: 'rsbuild:html',
|
|
3363
3388
|
setup (api) {
|
|
3364
3389
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID, environment })=>{
|
|
@@ -3458,7 +3483,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3458
3483
|
}), chain.plugin('rsbuild-html-plugin').use(RsbuildHtmlPlugin, [
|
|
3459
3484
|
htmlInfoMap,
|
|
3460
3485
|
()=>environment,
|
|
3461
|
-
|
|
3486
|
+
()=>context
|
|
3462
3487
|
]), config.html) {
|
|
3463
3488
|
let { crossorigin } = config.html;
|
|
3464
3489
|
crossorigin && chain.output.crossOriginLoading(!0 === crossorigin ? 'anonymous' : crossorigin);
|
|
@@ -3585,7 +3610,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3585
3610
|
})(chunkGroup)).filter((name)=>!!name))
|
|
3586
3611
|
];
|
|
3587
3612
|
}
|
|
3588
|
-
let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
3613
|
+
let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)=>{
|
|
3589
3614
|
let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
|
|
3590
3615
|
if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
|
|
3591
3616
|
file,
|
|
@@ -3631,10 +3656,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
3631
3656
|
files,
|
|
3632
3657
|
manifestData
|
|
3633
3658
|
});
|
|
3634
|
-
if (isObject(generatedManifest)) return generatedManifest;
|
|
3659
|
+
if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
|
|
3635
3660
|
throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
|
|
3636
3661
|
}
|
|
3637
|
-
return manifestData;
|
|
3662
|
+
return environment.manifest = manifestData, manifestData;
|
|
3638
3663
|
}, pluginManifest = ()=>({
|
|
3639
3664
|
name: 'rsbuild:manifest',
|
|
3640
3665
|
setup (api) {
|
|
@@ -3658,7 +3683,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
3658
3683
|
fileName: manifestOptions.filename,
|
|
3659
3684
|
filter,
|
|
3660
3685
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
3661
|
-
generate: generateManifest(htmlPaths, manifestOptions)
|
|
3686
|
+
generate: generateManifest(htmlPaths, manifestOptions, environment)
|
|
3662
3687
|
}
|
|
3663
3688
|
]);
|
|
3664
3689
|
});
|
|
@@ -3822,13 +3847,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3822
3847
|
if (routes.length <= 1) {
|
|
3823
3848
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
3824
3849
|
return urls.map(({ label, url })=>{
|
|
3825
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix =
|
|
3850
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${index_js_default().dim(label.padEnd(10))}`;
|
|
3826
3851
|
return ` ${prefix}${index_js_default().cyan(normalizedPathname)}\n`;
|
|
3827
3852
|
}).join('');
|
|
3828
3853
|
}
|
|
3829
3854
|
let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
3830
3855
|
return urls.forEach(({ label, url }, index)=>{
|
|
3831
|
-
for (let r of (index > 0 && (message += '\n'), message += `
|
|
3856
|
+
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${index_js_default().dim('-')} ${index_js_default().dim(r.entryName.padEnd(maxNameLength + 4))}${index_js_default().cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
|
|
3832
3857
|
}), message;
|
|
3833
3858
|
}(urls, routes);
|
|
3834
3859
|
return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), rslog_index_js_namespaceObject.logger.log(message), message;
|
|
@@ -4378,7 +4403,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4378
4403
|
if ('webpack' === api.context.bundlerType) return;
|
|
4379
4404
|
let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
|
|
4380
4405
|
if (!RSPACK_PROFILE) return;
|
|
4381
|
-
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'),
|
|
4406
|
+
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), onStart = async ()=>{
|
|
4382
4407
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName), traceFilePath = external_node_path_default().join(profileDir, 'trace.json');
|
|
4383
4408
|
await isFileExists(profileDir) || await external_node_fs_default().promises.mkdir(profileDir, {
|
|
4384
4409
|
recursive: !0
|
|
@@ -4386,17 +4411,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4386
4411
|
};
|
|
4387
4412
|
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
4388
4413
|
isFirstCompile && onStart();
|
|
4389
|
-
}), api.onBeforeStartDevServer(onStart), api.
|
|
4390
|
-
let loggingFilePath = external_node_path_default().join(api.context.distPath, profileDirName, 'logging.json');
|
|
4391
|
-
if (enableLogging && stats) {
|
|
4392
|
-
let logging = stats.toJson({
|
|
4393
|
-
all: !1,
|
|
4394
|
-
logging: 'verbose',
|
|
4395
|
-
loggingTrace: !0
|
|
4396
|
-
});
|
|
4397
|
-
await external_node_fs_default().promises.writeFile(loggingFilePath, JSON.stringify(logging));
|
|
4398
|
-
}
|
|
4399
|
-
}), api.onExit(()=>{
|
|
4414
|
+
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
4400
4415
|
enableProfileTrace && core_default().experiments.globalTrace.cleanup();
|
|
4401
4416
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName);
|
|
4402
4417
|
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`profile files saved to ${index_js_default().cyan(profileDir)}`);
|
|
@@ -5210,7 +5225,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5210
5225
|
}
|
|
5211
5226
|
].filter(Boolean);
|
|
5212
5227
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
|
|
5213
|
-
help && rslog_index_js_namespaceObject.logger.log(`
|
|
5228
|
+
help && rslog_index_js_namespaceObject.logger.log(` \u{279C} ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
|
|
5214
5229
|
let rl = external_node_readline_default().createInterface({
|
|
5215
5230
|
input: process.stdin
|
|
5216
5231
|
});
|
|
@@ -6741,10 +6756,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6741
6756
|
pluginFileSize(),
|
|
6742
6757
|
pluginCleanOutput(),
|
|
6743
6758
|
pluginAsset(),
|
|
6744
|
-
pluginHtml(
|
|
6745
|
-
environment,
|
|
6746
|
-
args
|
|
6747
|
-
}))[0]),
|
|
6759
|
+
pluginHtml(context),
|
|
6748
6760
|
pluginAppIcon(),
|
|
6749
6761
|
pluginWasm(),
|
|
6750
6762
|
pluginMoment(),
|
|
@@ -6995,7 +7007,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6995
7007
|
}
|
|
6996
7008
|
});
|
|
6997
7009
|
});
|
|
6998
|
-
let
|
|
7010
|
+
let getTransformHook = (environment)=>(descriptor, handler)=>{
|
|
6999
7011
|
let id = `rsbuild-transform-${transformId++}`;
|
|
7000
7012
|
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
7001
7013
|
environment,
|
|
@@ -7041,7 +7053,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7041
7053
|
return (environment)=>({
|
|
7042
7054
|
context: publicContext,
|
|
7043
7055
|
expose,
|
|
7044
|
-
transform:
|
|
7056
|
+
transform: getTransformHook(environment),
|
|
7045
7057
|
useExposed,
|
|
7046
7058
|
processAssets: setProcessAssets(environment),
|
|
7047
7059
|
resolve: setResolve(environment),
|
|
@@ -7061,6 +7073,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7061
7073
|
onAfterStartProdServer: hooks.onAfterStartProdServer.tap,
|
|
7062
7074
|
onBeforeStartProdServer: hooks.onBeforeStartProdServer.tap,
|
|
7063
7075
|
modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
|
|
7076
|
+
modifyHTML: (handler)=>hooks.modifyHTML.tapEnvironment({
|
|
7077
|
+
environment,
|
|
7078
|
+
handler
|
|
7079
|
+
}),
|
|
7064
7080
|
modifyHTMLTags: (handler)=>hooks.modifyHTMLTags.tapEnvironment({
|
|
7065
7081
|
environment,
|
|
7066
7082
|
handler
|
|
@@ -7507,11 +7523,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7507
7523
|
}
|
|
7508
7524
|
process.title = 'rsbuild-node';
|
|
7509
7525
|
let { npm_execpath } = process.env;
|
|
7510
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.
|
|
7526
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.15\n`);
|
|
7511
7527
|
try {
|
|
7512
7528
|
!function() {
|
|
7513
7529
|
let cli = cac_dist('rsbuild');
|
|
7514
|
-
cli.help(), cli.version("1.3.
|
|
7530
|
+
cli.help(), cli.version("1.3.15"), applyCommonOptions(cli);
|
|
7515
7531
|
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');
|
|
7516
7532
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7517
7533
|
try {
|
|
@@ -7562,7 +7578,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7562
7578
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7563
7579
|
}
|
|
7564
7580
|
}
|
|
7565
|
-
let src_version = "1.3.
|
|
7581
|
+
let src_version = "1.3.15";
|
|
7566
7582
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
7567
7583
|
"PLUGIN_CSS_NAME",
|
|
7568
7584
|
"PLUGIN_SWC_NAME",
|
package/dist/index.js
CHANGED
|
@@ -2110,14 +2110,14 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2110
2110
|
};
|
|
2111
2111
|
context.environments[name] = new Proxy(environmentContext, {
|
|
2112
2112
|
get: (target, prop)=>target[prop],
|
|
2113
|
-
set: (
|
|
2113
|
+
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
|
|
2114
2114
|
});
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
2117
|
async function createContext(options, userConfig) {
|
|
2118
2118
|
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;
|
|
2119
2119
|
return {
|
|
2120
|
-
version: "1.3.
|
|
2120
|
+
version: "1.3.15",
|
|
2121
2121
|
rootPath,
|
|
2122
2122
|
distPath: '',
|
|
2123
2123
|
cachePath,
|
|
@@ -2136,6 +2136,7 @@ async function createContext(options, userConfig) {
|
|
|
2136
2136
|
onBeforeStartProdServer: createAsyncHook(),
|
|
2137
2137
|
onAfterCreateCompiler: createAsyncHook(),
|
|
2138
2138
|
onBeforeCreateCompiler: createAsyncHook(),
|
|
2139
|
+
modifyHTML: createEnvironmentAsyncHook(),
|
|
2139
2140
|
modifyHTMLTags: createEnvironmentAsyncHook(),
|
|
2140
2141
|
modifyRspackConfig: createEnvironmentAsyncHook(),
|
|
2141
2142
|
modifyBundlerChain: createEnvironmentAsyncHook(),
|
|
@@ -2967,28 +2968,28 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
2967
2968
|
showGzipHeader && rowTypes.push('Gzip');
|
|
2968
2969
|
let headerRow = rowTypes.reduce((prev, cur, index)=>{
|
|
2969
2970
|
let length = lengths[index], curLabel = cur;
|
|
2970
|
-
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel}
|
|
2971
|
-
}, '
|
|
2971
|
+
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
|
|
2972
|
+
}, '');
|
|
2972
2973
|
return __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.blue(headerRow);
|
|
2973
2974
|
}(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
|
|
2974
2975
|
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
|
|
2975
2976
|
sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
|
|
2976
2977
|
let fileNameLabel = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(asset.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep) + coloringAssetName(asset.name);
|
|
2977
2978
|
fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
|
|
2978
|
-
let log =
|
|
2979
|
-
gzipSizeLabel && (log += `
|
|
2979
|
+
let log = `${fileNameLabel} ${sizeLabel}`;
|
|
2980
|
+
gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
|
|
2980
2981
|
}
|
|
2981
2982
|
if (showTotal) {
|
|
2982
2983
|
logs.push('');
|
|
2983
|
-
let log = '
|
|
2984
|
-
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel), log += `
|
|
2984
|
+
let log = '';
|
|
2985
|
+
if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
|
|
2985
2986
|
let colorFn = getAssetColor(totalGzipSize / assets.length);
|
|
2986
|
-
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += `
|
|
2987
|
+
log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
|
|
2987
2988
|
}
|
|
2988
2989
|
logs.push(log);
|
|
2989
2990
|
}
|
|
2990
2991
|
} else if (showTotal) {
|
|
2991
|
-
let log =
|
|
2992
|
+
let log = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel)} ${totalSizeStr}`;
|
|
2992
2993
|
options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
|
|
2993
2994
|
}
|
|
2994
2995
|
return logs.push(''), logs;
|
|
@@ -3012,7 +3013,7 @@ let pluginFileSize = ()=>({
|
|
|
3012
3013
|
...defaultConfig,
|
|
3013
3014
|
...printFileSize
|
|
3014
3015
|
}, statsLogs = await printFileSizes(mergedConfig, multiStats[index], api.context.rootPath, environment.name);
|
|
3015
|
-
logs.
|
|
3016
|
+
logs.push(...statsLogs);
|
|
3016
3017
|
})).catch((err)=>{
|
|
3017
3018
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('Failed to print file size.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(err);
|
|
3018
3019
|
}), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(logs.join('\n'));
|
|
@@ -3155,7 +3156,8 @@ class RsbuildHtmlPlugin {
|
|
|
3155
3156
|
href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
|
|
3156
3157
|
};
|
|
3157
3158
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3158
|
-
getHTMLPlugin().getCompilationHooks(compilation)
|
|
3159
|
+
let hooks = getHTMLPlugin().getCompilationHooks(compilation);
|
|
3160
|
+
hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
|
|
3159
3161
|
var _data_plugin_options, _data_plugin_options1;
|
|
3160
3162
|
let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
|
|
3161
3163
|
if (!entryName) return data;
|
|
@@ -3164,22 +3166,45 @@ class RsbuildHtmlPlugin {
|
|
|
3164
3166
|
let tags = {
|
|
3165
3167
|
headTags: headTags.map(formatBasicTag),
|
|
3166
3168
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
3167
|
-
},
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3169
|
+
}, context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTMLTags.callChain({
|
|
3170
|
+
environment: environment.name,
|
|
3171
|
+
args: [
|
|
3172
|
+
tags,
|
|
3173
|
+
{
|
|
3174
|
+
compiler,
|
|
3175
|
+
compilation,
|
|
3176
|
+
assetPrefix: data.publicPath,
|
|
3177
|
+
filename: data.outputName,
|
|
3178
|
+
environment
|
|
3179
|
+
}
|
|
3180
|
+
]
|
|
3181
|
+
});
|
|
3174
3182
|
return Object.assign(data, {
|
|
3175
3183
|
headTags: modified.headTags.map(fromBasicTag),
|
|
3176
3184
|
bodyTags: modified.bodyTags.map(fromBasicTag)
|
|
3177
3185
|
}), tagConfig && applyTagConfig(data, tagConfig, compilation.hash ?? '', entryName), data;
|
|
3186
|
+
}), hooks.beforeEmit.tapPromise(this.name, async (data)=>{
|
|
3187
|
+
let context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTML.callChain({
|
|
3188
|
+
environment: environment.name,
|
|
3189
|
+
args: [
|
|
3190
|
+
data.html,
|
|
3191
|
+
{
|
|
3192
|
+
compiler,
|
|
3193
|
+
compilation,
|
|
3194
|
+
filename: data.outputName,
|
|
3195
|
+
environment
|
|
3196
|
+
}
|
|
3197
|
+
]
|
|
3198
|
+
});
|
|
3199
|
+
return {
|
|
3200
|
+
...data,
|
|
3201
|
+
html: modified
|
|
3202
|
+
};
|
|
3178
3203
|
});
|
|
3179
3204
|
});
|
|
3180
3205
|
}
|
|
3181
|
-
constructor(options, getEnvironment,
|
|
3182
|
-
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "
|
|
3206
|
+
constructor(options, getEnvironment, getContext){
|
|
3207
|
+
RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "getContext", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.getEnvironment = getEnvironment, this.getContext = getContext;
|
|
3183
3208
|
}
|
|
3184
3209
|
}
|
|
3185
3210
|
let getDefaultTemplateContent = (mountId)=>`<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`, existTemplatePath = new Set();
|
|
@@ -3214,7 +3239,7 @@ let getTagConfig = (config)=>{
|
|
|
3214
3239
|
publicPath: !0,
|
|
3215
3240
|
tags
|
|
3216
3241
|
};
|
|
3217
|
-
}, pluginHtml = (
|
|
3242
|
+
}, pluginHtml = (context)=>({
|
|
3218
3243
|
name: 'rsbuild:html',
|
|
3219
3244
|
setup (api) {
|
|
3220
3245
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID, environment })=>{
|
|
@@ -3313,7 +3338,7 @@ let getTagConfig = (config)=>{
|
|
|
3313
3338
|
}), chain.plugin('rsbuild-html-plugin').use(RsbuildHtmlPlugin, [
|
|
3314
3339
|
htmlInfoMap,
|
|
3315
3340
|
()=>environment,
|
|
3316
|
-
|
|
3341
|
+
()=>context
|
|
3317
3342
|
]), config.html) {
|
|
3318
3343
|
let { crossorigin } = config.html;
|
|
3319
3344
|
crossorigin && chain.output.crossOriginLoading(!0 === crossorigin ? 'anonymous' : crossorigin);
|
|
@@ -3440,7 +3465,7 @@ function recursiveChunkEntryNames(chunk) {
|
|
|
3440
3465
|
})(chunkGroup)).filter((name)=>!!name))
|
|
3441
3466
|
];
|
|
3442
3467
|
}
|
|
3443
|
-
let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
3468
|
+
let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)=>{
|
|
3444
3469
|
let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
|
|
3445
3470
|
if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
|
|
3446
3471
|
file,
|
|
@@ -3486,10 +3511,10 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
|
3486
3511
|
files,
|
|
3487
3512
|
manifestData
|
|
3488
3513
|
});
|
|
3489
|
-
if (isObject(generatedManifest)) return generatedManifest;
|
|
3514
|
+
if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
|
|
3490
3515
|
throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
|
|
3491
3516
|
}
|
|
3492
|
-
return manifestData;
|
|
3517
|
+
return environment.manifest = manifestData, manifestData;
|
|
3493
3518
|
}, pluginManifest = ()=>({
|
|
3494
3519
|
name: 'rsbuild:manifest',
|
|
3495
3520
|
setup (api) {
|
|
@@ -3513,7 +3538,7 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
|
3513
3538
|
fileName: manifestOptions.filename,
|
|
3514
3539
|
filter,
|
|
3515
3540
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
3516
|
-
generate: generateManifest(htmlPaths, manifestOptions)
|
|
3541
|
+
generate: generateManifest(htmlPaths, manifestOptions, environment)
|
|
3517
3542
|
}
|
|
3518
3543
|
]);
|
|
3519
3544
|
});
|
|
@@ -3674,13 +3699,13 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
|
|
|
3674
3699
|
if (routes.length <= 1) {
|
|
3675
3700
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
3676
3701
|
return urls.map(({ label, url })=>{
|
|
3677
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix =
|
|
3702
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(label.padEnd(10))}`;
|
|
3678
3703
|
return ` ${prefix}${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(normalizedPathname)}\n`;
|
|
3679
3704
|
}).join('');
|
|
3680
3705
|
}
|
|
3681
3706
|
let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
3682
3707
|
return urls.forEach(({ label, url }, index)=>{
|
|
3683
|
-
for (let r of (index > 0 && (message += '\n'), message += `
|
|
3708
|
+
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('-')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(r.entryName.padEnd(maxNameLength + 4))}${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
|
|
3684
3709
|
}), message;
|
|
3685
3710
|
}(urls, routes);
|
|
3686
3711
|
return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(message), message;
|
|
@@ -4228,7 +4253,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4228
4253
|
if ('webpack' === api.context.bundlerType) return;
|
|
4229
4254
|
let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
|
|
4230
4255
|
if (!RSPACK_PROFILE) return;
|
|
4231
|
-
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'),
|
|
4256
|
+
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), onStart = async ()=>{
|
|
4232
4257
|
let profileDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName), traceFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'trace.json');
|
|
4233
4258
|
await isFileExists(profileDir) || await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(profileDir, {
|
|
4234
4259
|
recursive: !0
|
|
@@ -4236,17 +4261,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4236
4261
|
};
|
|
4237
4262
|
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
4238
4263
|
isFirstCompile && onStart();
|
|
4239
|
-
}), api.onBeforeStartDevServer(onStart), api.
|
|
4240
|
-
let loggingFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName, 'logging.json');
|
|
4241
|
-
if (enableLogging && stats) {
|
|
4242
|
-
let logging = stats.toJson({
|
|
4243
|
-
all: !1,
|
|
4244
|
-
logging: 'verbose',
|
|
4245
|
-
loggingTrace: !0
|
|
4246
|
-
});
|
|
4247
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(loggingFilePath, JSON.stringify(logging));
|
|
4248
|
-
}
|
|
4249
|
-
}), api.onExit(()=>{
|
|
4264
|
+
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
4250
4265
|
enableProfileTrace && __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.globalTrace.cleanup();
|
|
4251
4266
|
let profileDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName);
|
|
4252
4267
|
stopProfiler(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'jscpuprofile.json'), profileSession), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`profile files saved to ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(profileDir)}`);
|
|
@@ -5054,7 +5069,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
|
|
|
5054
5069
|
}
|
|
5055
5070
|
].filter(Boolean);
|
|
5056
5071
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
|
|
5057
|
-
help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(`
|
|
5072
|
+
help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(` \u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('press')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold('h + enter')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('to show shortcuts')}\n`);
|
|
5058
5073
|
let rl = __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__.default.createInterface({
|
|
5059
5074
|
input: process.stdin
|
|
5060
5075
|
});
|
|
@@ -6578,10 +6593,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6578
6593
|
pluginFileSize(),
|
|
6579
6594
|
pluginCleanOutput(),
|
|
6580
6595
|
pluginAsset(),
|
|
6581
|
-
pluginHtml(
|
|
6582
|
-
environment,
|
|
6583
|
-
args
|
|
6584
|
-
}))[0]),
|
|
6596
|
+
pluginHtml(context),
|
|
6585
6597
|
pluginAppIcon(),
|
|
6586
6598
|
pluginWasm(),
|
|
6587
6599
|
pluginMoment(),
|
|
@@ -6831,7 +6843,7 @@ async function createRsbuild(options = {}) {
|
|
|
6831
6843
|
}
|
|
6832
6844
|
});
|
|
6833
6845
|
});
|
|
6834
|
-
let
|
|
6846
|
+
let getTransformHook = (environment)=>(descriptor, handler)=>{
|
|
6835
6847
|
let id = `rsbuild-transform-${transformId++}`;
|
|
6836
6848
|
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
6837
6849
|
environment,
|
|
@@ -6877,7 +6889,7 @@ async function createRsbuild(options = {}) {
|
|
|
6877
6889
|
return (environment)=>({
|
|
6878
6890
|
context: publicContext,
|
|
6879
6891
|
expose,
|
|
6880
|
-
transform:
|
|
6892
|
+
transform: getTransformHook(environment),
|
|
6881
6893
|
useExposed,
|
|
6882
6894
|
processAssets: setProcessAssets(environment),
|
|
6883
6895
|
resolve: setResolve(environment),
|
|
@@ -6897,6 +6909,10 @@ async function createRsbuild(options = {}) {
|
|
|
6897
6909
|
onAfterStartProdServer: hooks.onAfterStartProdServer.tap,
|
|
6898
6910
|
onBeforeStartProdServer: hooks.onBeforeStartProdServer.tap,
|
|
6899
6911
|
modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
|
|
6912
|
+
modifyHTML: (handler)=>hooks.modifyHTML.tapEnvironment({
|
|
6913
|
+
environment,
|
|
6914
|
+
handler
|
|
6915
|
+
}),
|
|
6900
6916
|
modifyHTMLTags: (handler)=>hooks.modifyHTMLTags.tapEnvironment({
|
|
6901
6917
|
environment,
|
|
6902
6918
|
handler
|
|
@@ -7342,11 +7358,11 @@ async function runCLI() {
|
|
|
7342
7358
|
}
|
|
7343
7359
|
process.title = 'rsbuild-node';
|
|
7344
7360
|
let { npm_execpath } = process.env;
|
|
7345
|
-
(!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.3.
|
|
7361
|
+
(!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.3.15\n`);
|
|
7346
7362
|
try {
|
|
7347
7363
|
!function() {
|
|
7348
7364
|
let cli = cac_dist('rsbuild');
|
|
7349
|
-
cli.help(), cli.version("1.3.
|
|
7365
|
+
cli.help(), cli.version("1.3.15"), applyCommonOptions(cli);
|
|
7350
7366
|
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');
|
|
7351
7367
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7352
7368
|
try {
|
|
@@ -7397,6 +7413,6 @@ async function runCLI() {
|
|
|
7397
7413
|
__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);
|
|
7398
7414
|
}
|
|
7399
7415
|
}
|
|
7400
|
-
let src_version = "1.3.
|
|
7416
|
+
let src_version = "1.3.15";
|
|
7401
7417
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7402
7418
|
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 };
|
package/dist-types/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
|
|
1
|
+
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
|
|
2
2
|
export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
|
|
3
3
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
4
4
|
export declare function initHooks(): {
|
|
@@ -16,6 +16,7 @@ export declare function initHooks(): {
|
|
|
16
16
|
onAfterCreateCompiler: AsyncHook<OnAfterCreateCompilerFn>;
|
|
17
17
|
onBeforeCreateCompiler: AsyncHook<OnBeforeCreateCompilerFn>;
|
|
18
18
|
/** The following hooks are related to the environment */
|
|
19
|
+
modifyHTML: EnvironmentAsyncHook<ModifyHTMLFn>;
|
|
19
20
|
modifyHTMLTags: EnvironmentAsyncHook<ModifyHTMLTagsFn>;
|
|
20
21
|
modifyRspackConfig: EnvironmentAsyncHook<ModifyRspackConfigFn>;
|
|
21
22
|
modifyBundlerChain: EnvironmentAsyncHook<ModifyBundlerChainFn>;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { logger } from './logger';
|
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { ensureAssetPrefix } from './helpers';
|
|
17
17
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
18
|
-
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, Charset, ClientConfig, CliShortcut, CleanDistPath, CleanDistPathObject, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentContext, EnvironmentConfig, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlConfig, HtmlRspackPlugin, HtmlBasicTag, HtmlFallback, HtmlTagHandler, HtmlTagDescriptor, HtmlTagContext, InspectConfigOptions, InspectConfigResult, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InternalContext, LegalComments, ManifestData, ManifestConfig, ManifestObjectConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterEnvironmentCompileFn, OnBeforeEnvironmentCompileFn, OnCloseBuildFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ResourceHintsIncludeType, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig,
|
|
18
|
+
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, Charset, ClientConfig, CliShortcut, CleanDistPath, CleanDistPathObject, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentContext, EnvironmentConfig, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlConfig, HtmlRspackPlugin, HtmlBasicTag, HtmlFallback, HtmlTagHandler, HtmlTagDescriptor, HtmlTagContext, InspectConfigOptions, InspectConfigResult, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InternalContext, LegalComments, ManifestData, ManifestConfig, ManifestObjectConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterEnvironmentCompileFn, OnBeforeEnvironmentCompileFn, OnCloseBuildFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProcessAssetsDescriptor, ProcessAssetsHook, ProcessAssetsHandler, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolveHook, ResolveHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ResourceHintsIncludeType, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformHook, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
19
19
|
export type { ChainIdentifier } from './configChain';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
21
21
|
export type { StartServerResult } from './server/helper';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InternalContext, NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
2
2
|
export declare function getTemplate(entryName: string, config: NormalizedEnvironmentConfig, rootPath: string): Promise<{
|
|
3
3
|
templatePath: string;
|
|
4
4
|
templateContent?: string;
|
|
@@ -6,4 +6,4 @@ export declare function getTemplate(entryName: string, config: NormalizedEnviron
|
|
|
6
6
|
templatePath: undefined;
|
|
7
7
|
templateContent: string;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const pluginHtml: (
|
|
9
|
+
export declare const pluginHtml: (context: InternalContext) => RsbuildPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type { HtmlRspackPlugin } from '../types';
|
|
3
|
-
import type { EnvironmentContext, HtmlTag, HtmlTagDescriptor
|
|
2
|
+
import type { HtmlRspackPlugin, InternalContext } from '../types';
|
|
3
|
+
import type { EnvironmentContext, HtmlTag, HtmlTagDescriptor } from '../types';
|
|
4
4
|
type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject;
|
|
5
5
|
export type TagConfig = {
|
|
6
6
|
tags?: HtmlTagDescriptor[];
|
|
@@ -30,8 +30,8 @@ export declare class RsbuildHtmlPlugin {
|
|
|
30
30
|
readonly name: string;
|
|
31
31
|
readonly getEnvironment: () => EnvironmentContext;
|
|
32
32
|
readonly options: RsbuildHtmlPluginOptions;
|
|
33
|
-
readonly
|
|
34
|
-
constructor(options: RsbuildHtmlPluginOptions, getEnvironment: () => EnvironmentContext,
|
|
33
|
+
readonly getContext: () => InternalContext;
|
|
34
|
+
constructor(options: RsbuildHtmlPluginOptions, getEnvironment: () => EnvironmentContext, getContext: () => InternalContext);
|
|
35
35
|
apply(compiler: Compiler): void;
|
|
36
36
|
}
|
|
37
37
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { rspack } from '@rspack/core';
|
|
2
|
-
import type { ChainIdentifier } from '..';
|
|
2
|
+
import type { ChainIdentifier, ManifestData } from '..';
|
|
3
3
|
import type RspackChain from '../../compiled/rspack-chain';
|
|
4
4
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
5
5
|
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
@@ -70,11 +70,7 @@ export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCom
|
|
|
70
70
|
export type OnExitFn = (context: {
|
|
71
71
|
exitCode: number;
|
|
72
72
|
}) => void;
|
|
73
|
-
type
|
|
74
|
-
headTags: HtmlBasicTag[];
|
|
75
|
-
bodyTags: HtmlBasicTag[];
|
|
76
|
-
};
|
|
77
|
-
export type ModifyHTMLTagsContext = {
|
|
73
|
+
export type ModifyHTMLContext = {
|
|
78
74
|
/**
|
|
79
75
|
* The Compilation object of Rspack.
|
|
80
76
|
*/
|
|
@@ -83,11 +79,6 @@ export type ModifyHTMLTagsContext = {
|
|
|
83
79
|
* The Compiler object of Rspack.
|
|
84
80
|
*/
|
|
85
81
|
compiler: Rspack.Compiler;
|
|
86
|
-
/**
|
|
87
|
-
* URL prefix of assets.
|
|
88
|
-
* @example 'https://example.com/'
|
|
89
|
-
*/
|
|
90
|
-
assetPrefix: string;
|
|
91
82
|
/**
|
|
92
83
|
* The name of the HTML file, relative to the dist directory.
|
|
93
84
|
* @example 'index.html'
|
|
@@ -98,6 +89,18 @@ export type ModifyHTMLTagsContext = {
|
|
|
98
89
|
*/
|
|
99
90
|
environment: EnvironmentContext;
|
|
100
91
|
};
|
|
92
|
+
export type ModifyHTMLFn = (html: string, context: ModifyHTMLContext) => MaybePromise<string>;
|
|
93
|
+
type HTMLTags = {
|
|
94
|
+
headTags: HtmlBasicTag[];
|
|
95
|
+
bodyTags: HtmlBasicTag[];
|
|
96
|
+
};
|
|
97
|
+
export type ModifyHTMLTagsContext = Pick<ModifyHTMLContext, 'compilation' | 'compiler' | 'filename' | 'environment'> & {
|
|
98
|
+
/**
|
|
99
|
+
* URL prefix of assets.
|
|
100
|
+
* @example 'https://example.com/'
|
|
101
|
+
*/
|
|
102
|
+
assetPrefix: string;
|
|
103
|
+
};
|
|
101
104
|
export type ModifyHTMLTagsFn = (tags: HTMLTags, context: ModifyHTMLTagsContext) => MaybePromise<HTMLTags>;
|
|
102
105
|
export type ModifyRsbuildConfigUtils = {
|
|
103
106
|
/** Merge multiple Rsbuild config objects into one. */
|
|
@@ -147,6 +150,13 @@ export type EnvironmentContext = {
|
|
|
147
150
|
* The normalized Rsbuild config for the current environment.
|
|
148
151
|
*/
|
|
149
152
|
config: NormalizedEnvironmentConfig;
|
|
153
|
+
/**
|
|
154
|
+
* Manifest data. Only available when:
|
|
155
|
+
* - The `output.manifest` config is enabled
|
|
156
|
+
* - The build has completed, accessible in hooks like `onAfterBuild`,
|
|
157
|
+
* `onDevCompileDone` and `onAfterEnvironmentCompile`
|
|
158
|
+
*/
|
|
159
|
+
manifest?: Record<string, unknown> | ManifestData;
|
|
150
160
|
};
|
|
151
161
|
export type ModifyChainUtils = {
|
|
152
162
|
/**
|
|
@@ -4,7 +4,7 @@ import type RspackChain from '../../compiled/rspack-chain';
|
|
|
4
4
|
import type { ChainIdentifier } from '../configChain';
|
|
5
5
|
import type { ModifyRspackConfigUtils, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig, WebpackMerge } from './config';
|
|
6
6
|
import type { RsbuildContext } from './context';
|
|
7
|
-
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from './hooks';
|
|
7
|
+
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from './hooks';
|
|
8
8
|
import type { RsbuildInstance, RsbuildTarget } from './rsbuild';
|
|
9
9
|
import type { Rspack } from './rspack';
|
|
10
10
|
import type { HtmlRspackPlugin } from './thirdParty';
|
|
@@ -285,7 +285,7 @@ export type TransformDescriptor = {
|
|
|
285
285
|
*/
|
|
286
286
|
with?: Record<string, Rspack.RuleSetCondition>;
|
|
287
287
|
};
|
|
288
|
-
export type
|
|
288
|
+
export type TransformHook = (descriptor: TransformDescriptor, handler: TransformHandler) => void;
|
|
289
289
|
export type ProcessAssetsStage = 'additional' | 'pre-process' | 'derived' | 'additions' | 'none' | 'optimize' | 'optimize-count' | 'optimize-compatibility' | 'optimize-size' | 'dev-tooling' | 'optimize-inline' | 'summarize' | 'optimize-hash' | 'optimize-transfer' | 'analyse' | 'report';
|
|
290
290
|
export type ProcessAssetsDescriptor = {
|
|
291
291
|
/**
|
|
@@ -325,8 +325,8 @@ export type ResolveHandler = (context: {
|
|
|
325
325
|
compiler: Rspack.Compiler;
|
|
326
326
|
compilation: Rspack.Compilation;
|
|
327
327
|
}) => Promise<void> | void;
|
|
328
|
-
export type
|
|
329
|
-
export type
|
|
328
|
+
export type ResolveHook = (handler: ResolveHandler) => void;
|
|
329
|
+
export type ProcessAssetsHook = (descriptor: ProcessAssetsDescriptor, handler: ProcessAssetsHandler) => void;
|
|
330
330
|
declare function getNormalizedConfig(): NormalizedConfig;
|
|
331
331
|
declare function getNormalizedConfig(options: {
|
|
332
332
|
environment: string;
|
|
@@ -374,8 +374,16 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
374
374
|
* Modify the Rsbuild configuration of a specific environment.
|
|
375
375
|
*/
|
|
376
376
|
modifyEnvironmentConfig: PluginHook<ModifyEnvironmentConfigFn>;
|
|
377
|
+
/**
|
|
378
|
+
* Modify the final HTML content. The hook receives a HTML string
|
|
379
|
+
* and a context object, and you can return a new HTML string to
|
|
380
|
+
* replace the original one. This hook is triggered after the
|
|
381
|
+
* `modifyHTMLTags` hook.
|
|
382
|
+
*/
|
|
383
|
+
modifyHTML: PluginHook<ModifyHTMLFn>;
|
|
377
384
|
/**
|
|
378
385
|
* Modify the tags that are injected into the HTML.
|
|
386
|
+
* This hook is triggered before the `modifyHTML` hook.
|
|
379
387
|
*/
|
|
380
388
|
modifyHTMLTags: PluginHook<ModifyHTMLTagsFn>;
|
|
381
389
|
/**
|
|
@@ -473,16 +481,19 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
473
481
|
* Modify assets before emitting, the same as Rspack's
|
|
474
482
|
* [compilation.hooks.processAssets](https://rspack.dev/api/plugin-api/compilation-hooks#processassets) hook.
|
|
475
483
|
*/
|
|
476
|
-
processAssets:
|
|
484
|
+
processAssets: ProcessAssetsHook;
|
|
477
485
|
/**
|
|
478
486
|
* Intercept and modify module request information before module resolution begins.
|
|
479
487
|
* The same as Rspack's [normalModuleFactory.hooks.resolve](https://rspack.dev/api/plugin-api/normal-module-factory-hooks#resolve) hook.
|
|
480
488
|
*/
|
|
481
|
-
resolve:
|
|
489
|
+
resolve: ResolveHook;
|
|
482
490
|
/**
|
|
483
|
-
*
|
|
491
|
+
* A simplified wrapper around Rspack loaders, `api.transform` lets you
|
|
492
|
+
* easily transform the code of specific modules during the build process.
|
|
493
|
+
* You can match files by module path, query, or other conditions, and
|
|
494
|
+
* apply custom transformations to their contents.
|
|
484
495
|
*/
|
|
485
|
-
transform:
|
|
496
|
+
transform: TransformHook;
|
|
486
497
|
/**
|
|
487
498
|
* Get the properties or methods exposed by other plugins.
|
|
488
499
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.15",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"@rspack/core": "1.3.8",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
|
-
"core-js": "~3.
|
|
52
|
+
"core-js": "~3.42.0",
|
|
53
53
|
"jiti": "^2.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.6.
|
|
56
|
+
"@rslib/core": "0.6.8",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.17",
|
|
59
|
-
"@types/node": "^22.15.
|
|
59
|
+
"@types/node": "^22.15.3",
|
|
60
60
|
"@types/on-finished": "2.3.4",
|
|
61
61
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|