@rsbuild/core 1.3.9 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/html-rspack-plugin/index.d.ts +51 -46
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/tinyglobby/index.js +50 -43
- package/compiled/tinyglobby/package.json +1 -1
- package/dist/index.cjs +151 -80
- package/dist/index.js +94 -61
- package/dist-types/configChain.d.ts +2 -2
- package/dist-types/index.d.ts +1 -1
- package/dist-types/plugins/inlineChunk.d.ts +5 -1
- package/dist-types/rspack/{preload/HtmlPreloadOrPrefetchPlugin.d.ts → resource-hints/HtmlResourceHintsPlugin.d.ts} +4 -4
- package/dist-types/rspack/{preload/helpers → resource-hints}/doesChunkBelongToHtml.d.ts +4 -4
- package/dist-types/rspack/{preload/helpers → resource-hints}/extractChunks.d.ts +2 -7
- package/dist-types/rspack/{preload/helpers/determineAsValue.d.ts → resource-hints/getResourceType.d.ts} +3 -3
- package/dist-types/types/config.d.ts +56 -16
- package/package.json +5 -5
- package/dist-types/rspack/preload/helpers/index.d.ts +0 -4
- package/dist-types/rspack/preload/helpers/type.d.ts +0 -13
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ var EsmMode, __webpack_modules__ = {
|
|
|
97
97
|
}, {});
|
|
98
98
|
}, module.exports = deepmerge;
|
|
99
99
|
},
|
|
100
|
-
"../../node_modules/.pnpm/dotenv-expand@12.0.
|
|
100
|
+
"../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js": function(module) {
|
|
101
101
|
function _resolveEscapeSequences(value) {
|
|
102
102
|
return value.replace(/\\\$/g, '$');
|
|
103
103
|
}
|
|
@@ -942,7 +942,7 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
|
|
|
942
942
|
setHTMLPlugin: ()=>setHTMLPlugin,
|
|
943
943
|
stringifyConfig: ()=>stringifyConfig
|
|
944
944
|
});
|
|
945
|
-
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.
|
|
945
|
+
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js"), cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
|
|
946
946
|
let constants_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url), constants_dirname = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname), STATIC_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../static'), COMPILED_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
|
|
947
947
|
'chrome >= 87',
|
|
948
948
|
'edge >= 88',
|
|
@@ -1057,13 +1057,15 @@ async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
|
1057
1057
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to empty dir: ${dir}`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
|
-
let formatFileName = (fileName)=>/:\d+:\d+/.test(fileName) ? `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(fileName)}\n` : `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(fileName
|
|
1060
|
+
let formatFileName = (fileName)=>/:\d+:\d+/.test(fileName) ? `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(fileName)}\n` : `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(`${fileName}:1:1`)}\n`, hintNodePolyfill = (message)=>{
|
|
1061
1061
|
let getTips = (moduleName)=>{
|
|
1062
1062
|
let tips = [
|
|
1063
|
-
`
|
|
1064
|
-
|
|
1063
|
+
`Error: "${moduleName}" is a built-in Node.js module and cannot be imported in client-side code.\n`,
|
|
1064
|
+
'Solution: Check if you need to import Node.js module.',
|
|
1065
|
+
' - If not needed, remove the import.',
|
|
1066
|
+
` - If needed, use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('@rsbuild/plugin-node-polyfill')}" to polyfill it. (See ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('https://npmjs.com/package/@rsbuild/plugin-node-polyfill')})`
|
|
1065
1067
|
];
|
|
1066
|
-
return `${message}\n\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.
|
|
1068
|
+
return `${message}\n\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red(tips.join('\n'))}`;
|
|
1067
1069
|
};
|
|
1068
1070
|
if (message.includes('need an additional plugin to handle "node:" URIs')) return getTips('node:*');
|
|
1069
1071
|
if (!message.includes("Can't resolve")) return message;
|
|
@@ -2115,7 +2117,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2115
2117
|
async function createContext(options, userConfig) {
|
|
2116
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;
|
|
2117
2119
|
return {
|
|
2118
|
-
version: "1.3.
|
|
2120
|
+
version: "1.3.10",
|
|
2119
2121
|
rootPath,
|
|
2120
2122
|
distPath: '',
|
|
2121
2123
|
cachePath,
|
|
@@ -3340,13 +3342,19 @@ function updateSourceMappingURL({ source, compilation, publicPath, type, config
|
|
|
3340
3342
|
}
|
|
3341
3343
|
return source;
|
|
3342
3344
|
}
|
|
3343
|
-
function matchTests(name,
|
|
3345
|
+
function matchTests(name, asset, tests) {
|
|
3344
3346
|
return tests.some((test)=>isFunction(test) ? test({
|
|
3345
3347
|
name,
|
|
3346
|
-
size:
|
|
3348
|
+
size: asset.size()
|
|
3347
3349
|
}) : test.exec(name));
|
|
3348
3350
|
}
|
|
3349
|
-
let
|
|
3351
|
+
let getInlineTests = (config)=>{
|
|
3352
|
+
let isProd = 'production' === config.mode, { inlineStyles, inlineScripts } = config.output, scriptTests = [], styleTests = [];
|
|
3353
|
+
return inlineScripts && (!0 === inlineScripts ? isProd && scriptTests.push(JS_REGEX) : (0, __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__.isRegExp)(inlineScripts) || isFunction(inlineScripts) ? isProd && scriptTests.push(inlineScripts) : ('auto' === inlineScripts.enable ? isProd : inlineScripts.enable) && scriptTests.push(inlineScripts.test)), inlineStyles && (!0 === inlineStyles ? isProd && styleTests.push(CSS_REGEX) : (0, __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__.isRegExp)(inlineStyles) || isFunction(inlineStyles) ? isProd && styleTests.push(inlineStyles) : ('auto' === inlineStyles.enable ? isProd : inlineStyles.enable) && styleTests.push(inlineStyles.test)), {
|
|
3354
|
+
scriptTests,
|
|
3355
|
+
styleTests
|
|
3356
|
+
};
|
|
3357
|
+
}, pluginInlineChunk = ()=>({
|
|
3350
3358
|
name: 'rsbuild:inline-chunk',
|
|
3351
3359
|
setup (api) {
|
|
3352
3360
|
let inlinedAssets = new Set(), getInlinedScriptTag = (publicPath, tag, compilation, scriptTests, config)=>{
|
|
@@ -3354,13 +3362,11 @@ let pluginInlineChunk = ()=>({
|
|
|
3354
3362
|
let { assets } = compilation;
|
|
3355
3363
|
if (!((null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.src) && 'string' == typeof tag.attrs.src)) return tag;
|
|
3356
3364
|
let { src, ...otherAttrs } = tag.attrs, scriptName = publicPath ? src.replace(publicPath, '') : src, asset = assets[scriptName];
|
|
3357
|
-
if (null == asset) return tag;
|
|
3358
|
-
let source = asset.source().toString();
|
|
3359
|
-
if (!matchTests(scriptName, source, scriptTests)) return tag;
|
|
3365
|
+
if (null == asset || !matchTests(scriptName, asset, scriptTests)) return tag;
|
|
3360
3366
|
let ret = {
|
|
3361
3367
|
tag: "script",
|
|
3362
3368
|
children: updateSourceMappingURL({
|
|
3363
|
-
source,
|
|
3369
|
+
source: asset.source().toString(),
|
|
3364
3370
|
compilation,
|
|
3365
3371
|
publicPath,
|
|
3366
3372
|
type: 'js',
|
|
@@ -3376,13 +3382,11 @@ let pluginInlineChunk = ()=>({
|
|
|
3376
3382
|
let { assets } = compilation;
|
|
3377
3383
|
if (!((null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.href) && 'string' == typeof tag.attrs.href)) return tag;
|
|
3378
3384
|
let linkName = publicPath ? tag.attrs.href.replace(publicPath, '') : tag.attrs.href, asset = assets[linkName];
|
|
3379
|
-
if (null == asset) return tag;
|
|
3380
|
-
let source = asset.source().toString();
|
|
3381
|
-
if (!matchTests(linkName, source, styleTests)) return tag;
|
|
3385
|
+
if (null == asset || !matchTests(linkName, asset, styleTests)) return tag;
|
|
3382
3386
|
let ret = {
|
|
3383
3387
|
tag: 'style',
|
|
3384
3388
|
children: updateSourceMappingURL({
|
|
3385
|
-
source,
|
|
3389
|
+
source: asset.source().toString(),
|
|
3386
3390
|
compilation,
|
|
3387
3391
|
publicPath,
|
|
3388
3392
|
type: 'css',
|
|
@@ -3404,8 +3408,8 @@ let pluginInlineChunk = ()=>({
|
|
|
3404
3408
|
headTags,
|
|
3405
3409
|
bodyTags
|
|
3406
3410
|
};
|
|
3407
|
-
let {
|
|
3408
|
-
if (
|
|
3411
|
+
let { scriptTests, styleTests } = getInlineTests(config);
|
|
3412
|
+
if (!scriptTests.length && !styleTests.length) return {
|
|
3409
3413
|
headTags,
|
|
3410
3414
|
bodyTags
|
|
3411
3415
|
};
|
|
@@ -3417,9 +3421,6 @@ let pluginInlineChunk = ()=>({
|
|
|
3417
3421
|
});
|
|
3418
3422
|
}
|
|
3419
3423
|
});
|
|
3420
|
-
function isAsync(chunk) {
|
|
3421
|
-
return 'canBeInitial' in chunk ? !chunk.canBeInitial() : 'isInitial' in chunk && !chunk.isInitial();
|
|
3422
|
-
}
|
|
3423
3424
|
function recursiveChunkEntryNames(chunk) {
|
|
3424
3425
|
let [...chunkGroups] = chunk.groupsIterable;
|
|
3425
3426
|
return [
|
|
@@ -3996,7 +3997,10 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
|
|
|
3996
3997
|
});
|
|
3997
3998
|
}
|
|
3998
3999
|
});
|
|
3999
|
-
function
|
|
4000
|
+
function isAsyncChunk(chunk) {
|
|
4001
|
+
return 'canBeInitial' in chunk ? !chunk.canBeInitial() : 'isInitial' in chunk && !chunk.isInitial();
|
|
4002
|
+
}
|
|
4003
|
+
function HtmlResourceHintsPlugin_define_property(obj, key, value) {
|
|
4000
4004
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
4001
4005
|
value: value,
|
|
4002
4006
|
enumerable: !0,
|
|
@@ -4004,20 +4008,35 @@ function HtmlPreloadOrPrefetchPlugin_define_property(obj, key, value) {
|
|
|
4004
4008
|
writable: !0
|
|
4005
4009
|
}) : obj[key] = value, obj;
|
|
4006
4010
|
}
|
|
4007
|
-
let
|
|
4011
|
+
let HtmlResourceHintsPlugin_defaultOptions = {
|
|
4008
4012
|
type: 'async-chunks',
|
|
4009
|
-
dedupe: !0
|
|
4013
|
+
dedupe: !0,
|
|
4014
|
+
exclude: /.map$/
|
|
4015
|
+
}, applyFilter = (files, include, exclude)=>{
|
|
4016
|
+
let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
|
|
4017
|
+
if (include) for (let item of castArray(include))'string' == typeof item ? includeRegExp.push(new RegExp(item)) : isFunction(item) ? includeFn.push(item) : includeRegExp.push(item);
|
|
4018
|
+
if (exclude) for (let item of castArray(exclude))'string' == typeof item ? excludeRegExp.push(new RegExp(item)) : isFunction(item) ? excludeFn.push(item) : excludeRegExp.push(item);
|
|
4019
|
+
return files.filter((file)=>{
|
|
4020
|
+
let includeMatched = !1;
|
|
4021
|
+
for (let item of includeRegExp)item.test(file) && (includeMatched = !0);
|
|
4022
|
+
for (let item of includeFn)item(file) && (includeMatched = !0);
|
|
4023
|
+
if (includeRegExp.length + includeFn.length > 0 && !includeMatched) return !1;
|
|
4024
|
+
for (let item of excludeRegExp)if (item.test(file)) return !1;
|
|
4025
|
+
for (let item of excludeFn)if (item(file)) return !1;
|
|
4026
|
+
return !0;
|
|
4027
|
+
});
|
|
4010
4028
|
};
|
|
4011
|
-
class
|
|
4029
|
+
class HtmlResourceHintsPlugin {
|
|
4012
4030
|
apply(compiler) {
|
|
4013
4031
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
4014
|
-
getHTMLPlugin().
|
|
4015
|
-
|
|
4032
|
+
let pluginHooks = getHTMLPlugin().getCompilationHooks(compilation), pluginName = `HTML${upperFirst(this.type)}Plugin`;
|
|
4033
|
+
pluginHooks.beforeAssetTagGeneration.tap(pluginName, (data)=>(this.resourceHints = function(options, type, compilation, data, HTMLCount) {
|
|
4034
|
+
let extractedChunks = function(compilation, includeType) {
|
|
4016
4035
|
let chunks = [
|
|
4017
4036
|
...compilation.chunks
|
|
4018
4037
|
];
|
|
4019
|
-
if (void 0 === includeType || 'async-chunks' === includeType) return chunks.filter(
|
|
4020
|
-
if ('initial' === includeType) return chunks.filter((chunk)=>!
|
|
4038
|
+
if (void 0 === includeType || 'async-chunks' === includeType) return chunks.filter(isAsyncChunk);
|
|
4039
|
+
if ('initial' === includeType) return chunks.filter((chunk)=>!isAsyncChunk(chunk));
|
|
4021
4040
|
if ('all-chunks' === includeType) return chunks;
|
|
4022
4041
|
if ('all-assets' === includeType) {
|
|
4023
4042
|
var _compilation_assetsInfo;
|
|
@@ -4034,10 +4053,7 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
4034
4053
|
];
|
|
4035
4054
|
}
|
|
4036
4055
|
return chunks;
|
|
4037
|
-
}(
|
|
4038
|
-
compilation,
|
|
4039
|
-
includeType: options.type
|
|
4040
|
-
}), sortedFilteredFiles = [
|
|
4056
|
+
}(compilation, options.type), sortedFilteredFiles = applyFilter([
|
|
4041
4057
|
...new Set(('all-assets' === options.type || 1 === HTMLCount ? extractedChunks : extractedChunks.filter((chunk)=>(function({ chunk, htmlPluginData }) {
|
|
4042
4058
|
let { options } = htmlPluginData.plugin;
|
|
4043
4059
|
return recursiveChunkEntryNames(chunk).some((chunkName)=>{
|
|
@@ -4047,15 +4063,13 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
4047
4063
|
})({
|
|
4048
4064
|
chunk: chunk,
|
|
4049
4065
|
compilation,
|
|
4050
|
-
htmlPluginData,
|
|
4066
|
+
htmlPluginData: data,
|
|
4051
4067
|
pluginOptions: options
|
|
4052
4068
|
}))).reduce((accumulated, chunk)=>accumulated.concat([
|
|
4053
4069
|
...chunk.files,
|
|
4054
4070
|
...chunk.auxiliaryFiles || []
|
|
4055
4071
|
]), []))
|
|
4056
|
-
].
|
|
4057
|
-
/.map$/
|
|
4058
|
-
].every((regex)=>!regex.test(file))).filter((file)=>!options.include || ('function' == typeof options.include ? options.include(file) : options.include.some((regex)=>new RegExp(regex).test(file)))).filter((file)=>!options.exclude || ('function' == typeof options.exclude ? !options.exclude(file) : options.exclude.every((regex)=>!new RegExp(regex).test(file)))).sort(), links = [], { publicPath, crossOriginLoading } = compilation.outputOptions;
|
|
4072
|
+
], options.include, options.exclude).sort(), links = [], { publicPath, crossOriginLoading } = compilation.outputOptions;
|
|
4059
4073
|
for (let file of sortedFilteredFiles){
|
|
4060
4074
|
let href = ensureAssetPrefix(file, publicPath), attributes = {
|
|
4061
4075
|
href,
|
|
@@ -4079,19 +4093,19 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
4079
4093
|
});
|
|
4080
4094
|
}
|
|
4081
4095
|
return links;
|
|
4082
|
-
}(this.options, this.type, compilation,
|
|
4096
|
+
}(this.options, this.type, compilation, data, this.HTMLCount), data)), pluginHooks.alterAssetTags.tap(pluginName, (data)=>{
|
|
4083
4097
|
var resourceHints, scripts;
|
|
4084
|
-
return this.resourceHints && (
|
|
4085
|
-
...this.options.dedupe ? (resourceHints = this.resourceHints, scripts =
|
|
4086
|
-
...
|
|
4087
|
-
]),
|
|
4098
|
+
return this.resourceHints && (data.assetTags.styles = [
|
|
4099
|
+
...this.options.dedupe ? (resourceHints = this.resourceHints, scripts = data.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))) : this.resourceHints,
|
|
4100
|
+
...data.assetTags.styles
|
|
4101
|
+
]), data;
|
|
4088
4102
|
});
|
|
4089
4103
|
});
|
|
4090
4104
|
}
|
|
4091
4105
|
constructor(options, type, HTMLCount){
|
|
4092
|
-
|
|
4093
|
-
...
|
|
4094
|
-
...
|
|
4106
|
+
HtmlResourceHintsPlugin_define_property(this, "options", void 0), HtmlResourceHintsPlugin_define_property(this, "name", 'HtmlResourceHintsPlugin'), HtmlResourceHintsPlugin_define_property(this, "resourceHints", []), HtmlResourceHintsPlugin_define_property(this, "type", void 0), HtmlResourceHintsPlugin_define_property(this, "HTMLCount", void 0), this.options = {
|
|
4107
|
+
...HtmlResourceHintsPlugin_defaultOptions,
|
|
4108
|
+
...options
|
|
4095
4109
|
}, this.type = type, this.HTMLCount = HTMLCount;
|
|
4096
4110
|
}
|
|
4097
4111
|
}
|
|
@@ -4101,7 +4115,13 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4101
4115
|
rel,
|
|
4102
4116
|
...option
|
|
4103
4117
|
}
|
|
4104
|
-
})),
|
|
4118
|
+
})), getInlineExcludes = (config)=>{
|
|
4119
|
+
let { scriptTests, styleTests } = getInlineTests(config);
|
|
4120
|
+
return [
|
|
4121
|
+
...scriptTests,
|
|
4122
|
+
...styleTests
|
|
4123
|
+
].filter((item)=>(0, __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__.isRegExp)(item));
|
|
4124
|
+
}, pluginResourceHints = ()=>({
|
|
4105
4125
|
name: 'rsbuild:resource-hints',
|
|
4106
4126
|
setup (api) {
|
|
4107
4127
|
api.modifyHTMLTags(({ headTags, bodyTags }, { environment })=>{
|
|
@@ -4125,16 +4145,29 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4125
4145
|
}), api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
4126
4146
|
let { config, htmlPaths } = environment;
|
|
4127
4147
|
if (0 === Object.keys(htmlPaths).length) return;
|
|
4128
|
-
let { performance: { preload, prefetch } } = config, HTMLCount = chain.entryPoints.values().length;
|
|
4129
|
-
|
|
4130
|
-
prefetch
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4148
|
+
let { performance: { preload, prefetch } } = config, HTMLCount = chain.entryPoints.values().length, excludes = getInlineExcludes(config);
|
|
4149
|
+
if (prefetch) {
|
|
4150
|
+
let options = !0 === prefetch ? {} : prefetch;
|
|
4151
|
+
excludes.length && (options.exclude = options.exclude ? [
|
|
4152
|
+
...castArray(options.exclude),
|
|
4153
|
+
...excludes
|
|
4154
|
+
] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(HtmlResourceHintsPlugin, [
|
|
4155
|
+
options,
|
|
4156
|
+
'prefetch',
|
|
4157
|
+
HTMLCount
|
|
4158
|
+
]);
|
|
4159
|
+
}
|
|
4160
|
+
if (preload) {
|
|
4161
|
+
let options = !0 === preload ? {} : preload;
|
|
4162
|
+
excludes.length && (options.exclude = options.exclude ? [
|
|
4163
|
+
...castArray(options.exclude),
|
|
4164
|
+
...excludes
|
|
4165
|
+
] : excludes), chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(HtmlResourceHintsPlugin, [
|
|
4166
|
+
options,
|
|
4167
|
+
'preload',
|
|
4168
|
+
HTMLCount
|
|
4169
|
+
]);
|
|
4170
|
+
}
|
|
4138
4171
|
});
|
|
4139
4172
|
}
|
|
4140
4173
|
}), rsdoctor_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), pluginRsdoctor = ()=>({
|
|
@@ -7291,11 +7324,11 @@ async function runCLI() {
|
|
|
7291
7324
|
}
|
|
7292
7325
|
process.title = 'rsbuild-node';
|
|
7293
7326
|
let { npm_execpath } = process.env;
|
|
7294
|
-
(!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.
|
|
7327
|
+
(!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.10\n`);
|
|
7295
7328
|
try {
|
|
7296
7329
|
!function() {
|
|
7297
7330
|
let cli = cac_dist('rsbuild');
|
|
7298
|
-
cli.help(), cli.version("1.3.
|
|
7331
|
+
cli.help(), cli.version("1.3.10"), applyCommonOptions(cli);
|
|
7299
7332
|
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');
|
|
7300
7333
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7301
7334
|
try {
|
|
@@ -7346,6 +7379,6 @@ async function runCLI() {
|
|
|
7346
7379
|
__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);
|
|
7347
7380
|
}
|
|
7348
7381
|
}
|
|
7349
|
-
let src_version = "1.3.
|
|
7382
|
+
let src_version = "1.3.10";
|
|
7350
7383
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7351
7384
|
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 };
|
|
@@ -125,9 +125,9 @@ export declare const CHAIN_ID: {
|
|
|
125
125
|
readonly BUNDLE_ANALYZER: "bundle-analyze";
|
|
126
126
|
/** ModuleFederationPlugin */
|
|
127
127
|
readonly MODULE_FEDERATION: "module-federation";
|
|
128
|
-
/**
|
|
128
|
+
/** HtmlResourceHintsPlugin (prefetch) */
|
|
129
129
|
readonly HTML_PREFETCH: "html-prefetch-plugin";
|
|
130
|
-
/**
|
|
130
|
+
/** HtmlResourceHintsPlugin (preload) */
|
|
131
131
|
readonly HTML_PRELOAD: "html-preload-plugin";
|
|
132
132
|
/** CssExtractRspackPlugin */
|
|
133
133
|
readonly MINI_CSS_EXTRACT: "mini-css-extract";
|
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,
|
|
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, TransformFn, 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,2 +1,6 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '../types';
|
|
1
|
+
import type { InlineChunkTest, NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
2
|
+
export declare const getInlineTests: (config: NormalizedEnvironmentConfig) => {
|
|
3
|
+
scriptTests: InlineChunkTest[];
|
|
4
|
+
styleTests: InlineChunkTest[];
|
|
5
|
+
};
|
|
2
6
|
export declare const pluginInlineChunk: () => RsbuildPlugin;
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
19
|
-
import type { HtmlRspackPlugin,
|
|
19
|
+
import type { HtmlRspackPlugin, ResourceHintsOptions } from '../../types';
|
|
20
20
|
type LinkType = 'preload' | 'prefetch';
|
|
21
|
-
export declare class
|
|
22
|
-
readonly options:
|
|
21
|
+
export declare class HtmlResourceHintsPlugin implements RspackPluginInstance {
|
|
22
|
+
readonly options: ResourceHintsOptions;
|
|
23
23
|
name: string;
|
|
24
24
|
resourceHints: HtmlRspackPlugin.HtmlTagObject[];
|
|
25
25
|
type: LinkType;
|
|
26
26
|
HTMLCount: number;
|
|
27
|
-
constructor(options:
|
|
27
|
+
constructor(options: ResourceHintsOptions, type: LinkType, HTMLCount: number);
|
|
28
28
|
apply(compiler: Compiler): void;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
import type { Chunk, Compilation } from '@rspack/core';
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
19
|
+
import type { ResourceHintsOptions } from '../../types';
|
|
20
|
+
import type { HtmlRspackPlugin } from '../../types';
|
|
21
21
|
interface DoesChunkBelongToHtmlOptions {
|
|
22
22
|
chunk: Chunk;
|
|
23
23
|
compilation?: Compilation;
|
|
24
|
-
htmlPluginData:
|
|
25
|
-
pluginOptions?:
|
|
24
|
+
htmlPluginData: HtmlRspackPlugin.BeforeAssetTagGenerationData;
|
|
25
|
+
pluginOptions?: ResourceHintsOptions;
|
|
26
26
|
}
|
|
27
27
|
export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
|
|
28
28
|
export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
|
|
@@ -16,13 +16,8 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
import type { Chunk, Compilation } from '@rspack/core';
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
compilation: Compilation;
|
|
22
|
-
includeType?: PreloadIncludeType;
|
|
23
|
-
}
|
|
24
|
-
export declare function extractChunks({ compilation, includeType }: ExtractChunks): Chunk[] | Array<{
|
|
19
|
+
import type { ResourceHintsIncludeType } from '../../types';
|
|
20
|
+
export declare function extractChunks(compilation: Compilation, includeType?: ResourceHintsIncludeType): Chunk[] | Array<{
|
|
25
21
|
files: string[];
|
|
26
22
|
auxiliaryFiles?: string[];
|
|
27
23
|
}>;
|
|
28
|
-
export {};
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
export declare function
|
|
18
|
+
export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
|
|
19
|
+
export declare function getResourceType({ href, file, }: {
|
|
20
20
|
href: string;
|
|
21
21
|
file: string;
|
|
22
|
-
}):
|
|
22
|
+
}): ResourceType;
|
|
@@ -435,16 +435,38 @@ export interface PreconnectOption {
|
|
|
435
435
|
}
|
|
436
436
|
export type Preconnect = Array<string | PreconnectOption>;
|
|
437
437
|
export type DnsPrefetch = string[];
|
|
438
|
-
export type
|
|
439
|
-
export type
|
|
440
|
-
export
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
438
|
+
export type ResourceHintsIncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
|
|
439
|
+
export type ResourceHintsFilterFn = (filename: string) => boolean;
|
|
440
|
+
export type ResourceHintsFilter = OneOrMany<string | RegExp | ResourceHintsFilterFn>;
|
|
441
|
+
export interface ResourceHintsOptions {
|
|
442
|
+
/**
|
|
443
|
+
* Specifies which types of resources will be included.
|
|
444
|
+
* - `async-chunks`: Includes all async resources on the current page, such as async JS
|
|
445
|
+
* chunks, and its associated CSS, images, fonts, and other static resources.
|
|
446
|
+
* - `initial`: Includes all non-async resources on the current page.
|
|
447
|
+
* - `all-chunks`: Includes all async and non-async resources on the current page.
|
|
448
|
+
* - `all-assets`: Includes all resources from all pages.
|
|
449
|
+
* @default 'async-chunks'
|
|
450
|
+
*/
|
|
451
|
+
type?: ResourceHintsIncludeType;
|
|
452
|
+
/**
|
|
453
|
+
* A extra filter to determine which resources to include.
|
|
454
|
+
*/
|
|
455
|
+
include?: ResourceHintsFilter;
|
|
456
|
+
/**
|
|
457
|
+
* A extra filter to determine which resources to exclude.
|
|
458
|
+
*/
|
|
459
|
+
exclude?: ResourceHintsFilter;
|
|
460
|
+
/**
|
|
461
|
+
* Whether to dedupe script resources that already exist in the current HTML content.
|
|
462
|
+
* By default, if a resource has been added to the current HTML via a script tag, it will
|
|
463
|
+
* not be preloaded additionally.
|
|
464
|
+
* @default true
|
|
465
|
+
*/
|
|
444
466
|
dedupe?: boolean;
|
|
445
467
|
}
|
|
446
|
-
export type
|
|
447
|
-
export type
|
|
468
|
+
export type PreloadOptions = ResourceHintsOptions;
|
|
469
|
+
export type PrefetchOptions = Omit<ResourceHintsOptions, 'dedupe'>;
|
|
448
470
|
export interface PerformanceConfig {
|
|
449
471
|
/**
|
|
450
472
|
* Whether to remove `console.[methodName]` in production build.
|
|
@@ -485,19 +507,37 @@ export interface PerformanceConfig {
|
|
|
485
507
|
*/
|
|
486
508
|
dnsPrefetch?: DnsPrefetch;
|
|
487
509
|
/**
|
|
488
|
-
*
|
|
510
|
+
* Inject the `<link rel="preload">` tags for the static assets generated by Rsbuild.
|
|
511
|
+
*
|
|
512
|
+
* `performance.preload` can be set to an object to specify the options.
|
|
489
513
|
*
|
|
490
|
-
*
|
|
491
|
-
* current
|
|
514
|
+
* When `performance.preload` is set to `true`, Rsbuild will use the following default options
|
|
515
|
+
* to preload resources. This means preloading all async resources on the current page, including
|
|
516
|
+
* async JS and its associated CSS, image, font, and other resources.
|
|
517
|
+
*
|
|
518
|
+
* ```js
|
|
519
|
+
* const defaultOptions = {
|
|
520
|
+
* type: 'async-chunks',
|
|
521
|
+
* };
|
|
522
|
+
* ```
|
|
492
523
|
*/
|
|
493
|
-
preload?: true |
|
|
524
|
+
preload?: true | PreloadOptions;
|
|
494
525
|
/**
|
|
495
|
-
*
|
|
526
|
+
* Inject the `<link rel="prefetch">` tags for the static assets generated by Rsbuild.
|
|
527
|
+
*
|
|
528
|
+
* `performance.prefetch` can be set to an object to specify the options.
|
|
496
529
|
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
530
|
+
* When `performance.prefetch` is set to `true`, Rsbuild will use the following default options
|
|
531
|
+
* to prefetch resources. This means prefetching all async resources on the current page, including
|
|
532
|
+
* async JS and its associated CSS, image, font, and other resources.
|
|
533
|
+
*
|
|
534
|
+
* ```js
|
|
535
|
+
* const defaultOptions = {
|
|
536
|
+
* type: 'async-chunks',
|
|
537
|
+
* };
|
|
538
|
+
* ```
|
|
499
539
|
*/
|
|
500
|
-
prefetch?: true |
|
|
540
|
+
prefetch?: true | PrefetchOptions;
|
|
501
541
|
/**
|
|
502
542
|
* Whether capture timing information for each module,
|
|
503
543
|
* same as the [profile](https://rspack.dev/config/other-options#profile) config of Rspack.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jiti": "^2.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.6.
|
|
56
|
+
"@rslib/core": "0.6.6",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.17",
|
|
59
59
|
"@types/node": "^22.14.1",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"css-loader": "7.1.2",
|
|
70
70
|
"deepmerge": "^4.3.1",
|
|
71
71
|
"dotenv": "16.5.0",
|
|
72
|
-
"dotenv-expand": "12.0.
|
|
73
|
-
"html-rspack-plugin": "6.0.
|
|
72
|
+
"dotenv-expand": "12.0.2",
|
|
73
|
+
"html-rspack-plugin": "6.0.5",
|
|
74
74
|
"http-proxy-middleware": "^2.0.7",
|
|
75
75
|
"launch-editor-middleware": "^2.10.0",
|
|
76
76
|
"mrmime": "^2.0.1",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"rspack-manifest-plugin": "5.0.3",
|
|
89
89
|
"sirv": "^3.0.1",
|
|
90
90
|
"style-loader": "3.3.4",
|
|
91
|
-
"tinyglobby": "^0.2.
|
|
91
|
+
"tinyglobby": "^0.2.13",
|
|
92
92
|
"typescript": "^5.8.3",
|
|
93
93
|
"webpack": "^5.98.0",
|
|
94
94
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { HtmlRspackPlugin } from '../../../types';
|
|
2
|
-
export type BeforeAssetTagGenerationHtmlPluginData = {
|
|
3
|
-
assets: {
|
|
4
|
-
publicPath: string;
|
|
5
|
-
js: Array<string>;
|
|
6
|
-
css: Array<string>;
|
|
7
|
-
favicon?: string;
|
|
8
|
-
manifest?: string;
|
|
9
|
-
};
|
|
10
|
-
outputName: string;
|
|
11
|
-
plugin: HtmlRspackPlugin;
|
|
12
|
-
};
|
|
13
|
-
export type As = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
|