@rsbuild/core 2.0.0-alpha.3 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/dist/131.js +221 -191
- package/dist/manifest-plugin.js +5 -5
- package/dist-types/configChain.d.ts +2 -14
- package/dist-types/helpers/index.d.ts +1 -0
- package/dist-types/helpers/vendors.d.ts +1 -0
- package/dist-types/index.d.ts +2 -2
- package/dist-types/pluginHelper.d.ts +1 -1
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -1
- package/dist-types/server/assets-middleware/index.d.ts +1 -1
- package/dist-types/types/config.d.ts +21 -7
- package/package.json +2 -2
- package/dist-types/rspack.d.ts +0 -2
package/dist/131.js
CHANGED
|
@@ -14,12 +14,17 @@ import * as __rspack_external_os from "os";
|
|
|
14
14
|
import * as __rspack_external_path from "path";
|
|
15
15
|
import * as __rspack_external_url from "url";
|
|
16
16
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
17
|
+
import { rspack as core_rspack } from "@rspack/core";
|
|
17
18
|
import node_process from "node:process";
|
|
18
19
|
import node_os, { constants as external_node_os_constants, type as external_node_os_type } from "node:os";
|
|
19
20
|
import node_tty from "node:tty";
|
|
20
21
|
import { promisify as external_node_util_promisify, stripVTControlCharacters } from "node:util";
|
|
21
22
|
import { isPromise, isRegExp } from "node:util/types";
|
|
22
23
|
import node_zlib from "node:zlib";
|
|
24
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
25
|
+
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
26
|
+
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
27
|
+
}
|
|
23
28
|
__webpack_require__.add({
|
|
24
29
|
"../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
|
|
25
30
|
var isMergeableObject = function isMergeableObject(value) {
|
|
@@ -1002,11 +1007,6 @@ __webpack_require__.add({
|
|
|
1002
1007
|
module.exports = __rspack_external_url;
|
|
1003
1008
|
}
|
|
1004
1009
|
});
|
|
1005
|
-
let external_node_module_ = __webpack_require__("node:module"), rspack_rspack = (0, external_node_module_.createRequire)(import.meta.url)('@rspack/core');
|
|
1006
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
1007
|
-
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
1008
|
-
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
1009
|
-
}
|
|
1010
1010
|
let { env: dist_env } = node_process;
|
|
1011
1011
|
function envForceColor() {
|
|
1012
1012
|
if (!('FORCE_COLOR' in dist_env)) return;
|
|
@@ -2254,7 +2254,7 @@ class src_class extends ChainedMap {
|
|
|
2254
2254
|
]);
|
|
2255
2255
|
}
|
|
2256
2256
|
}
|
|
2257
|
-
let setNodeEnv = (env)=>{
|
|
2257
|
+
let external_node_module_ = __webpack_require__("node:module"), vendors_require = (0, external_node_module_.createRequire)(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), setNodeEnv = (env)=>{
|
|
2258
2258
|
process.env.NODE_ENV = env;
|
|
2259
2259
|
}, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), objectPrototype = Object.prototype, getProto = Object.getPrototypeOf, isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && getProto(obj) === objectPrototype, helpers_castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
|
|
2260
2260
|
arr
|
|
@@ -2319,7 +2319,7 @@ let compiler_isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isAr
|
|
|
2319
2319
|
}, applyToCompiler = (compiler, apply)=>{
|
|
2320
2320
|
compiler_isMultiCompiler(compiler) ? compiler.compilers.forEach(apply) : apply(compiler, 0);
|
|
2321
2321
|
}, addCompilationError = (compilation, message)=>{
|
|
2322
|
-
compilation.errors.push(new
|
|
2322
|
+
compilation.errors.push(new core_rspack.WebpackError(message));
|
|
2323
2323
|
};
|
|
2324
2324
|
function resolveFileName(stats) {
|
|
2325
2325
|
let file = stats.file || stats.moduleName;
|
|
@@ -2864,7 +2864,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2864
2864
|
}, mergeRsbuildConfig = (...originalConfigs)=>{
|
|
2865
2865
|
let configs = originalConfigs.filter((config)=>void 0 !== config).map(normalizeConfigStructure);
|
|
2866
2866
|
return 2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : 1 === configs.length ? configs[0] : 0 === configs.length ? {} : configs.reduce((result, config)=>mergeConfig_merge(result, config), {});
|
|
2867
|
-
},
|
|
2867
|
+
}, defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
|
|
2868
2868
|
dev: {
|
|
2869
2869
|
hmr: !0,
|
|
2870
2870
|
liveReload: !0,
|
|
@@ -2913,7 +2913,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2913
2913
|
scriptLoading: 'defer',
|
|
2914
2914
|
implementation: 'js'
|
|
2915
2915
|
},
|
|
2916
|
-
resolve: (swcHelpersPath || (swcHelpersPath = (0, external_node_path_.dirname)(
|
|
2916
|
+
resolve: (swcHelpersPath || (swcHelpersPath = (0, external_node_path_.dirname)(vendors_require.resolve('@swc/helpers/package.json'))), {
|
|
2917
2917
|
alias: {
|
|
2918
2918
|
'@swc/helpers': swcHelpersPath
|
|
2919
2919
|
},
|
|
@@ -2992,12 +2992,10 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2992
2992
|
enable: !1
|
|
2993
2993
|
}
|
|
2994
2994
|
},
|
|
2995
|
+
splitChunks: {},
|
|
2995
2996
|
performance: {
|
|
2996
2997
|
printFileSize: !0,
|
|
2997
|
-
removeConsole: !1
|
|
2998
|
-
chunkSplit: {
|
|
2999
|
-
strategy: 'split-by-experience'
|
|
3000
|
-
}
|
|
2998
|
+
removeConsole: !1
|
|
3001
2999
|
},
|
|
3002
3000
|
environments: {},
|
|
3003
3001
|
logLevel: 'info'
|
|
@@ -3177,7 +3175,7 @@ function getHTMLPathByEntry(entryName, config) {
|
|
|
3177
3175
|
return prefix.startsWith('/') && src_logger.warn(`${picocolors_default().dim('[rsbuild:config]')} Absolute path is not recommended at ${picocolors_default().yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), external_node_path_.posix.join(prefix, filename).replace(/^\/+/, '');
|
|
3178
3176
|
}
|
|
3179
3177
|
let mapProcessAssetsStage = (stage)=>{
|
|
3180
|
-
let { Compilation } =
|
|
3178
|
+
let { Compilation } = core_rspack;
|
|
3181
3179
|
switch(stage){
|
|
3182
3180
|
case 'additional':
|
|
3183
3181
|
return Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL;
|
|
@@ -3258,7 +3256,7 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3258
3256
|
compilation.hooks.childCompiler.tap(pluginName, (childCompiler)=>{
|
|
3259
3257
|
childCompiler.__rsbuildTransformer = transformer;
|
|
3260
3258
|
});
|
|
3261
|
-
let { sources } =
|
|
3259
|
+
let { sources } = core_rspack;
|
|
3262
3260
|
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns)(!descriptor.targets || descriptor.targets.includes(target)) && (!descriptor.environments || descriptor.environments.includes(environment.name)) && (!pluginEnvironment || isEnvironmentMatch(pluginEnvironment, environment.name)) && compilation.hooks.processAssets.tapPromise({
|
|
3263
3261
|
name: pluginName,
|
|
3264
3262
|
stage: mapProcessAssetsStage(descriptor.stage)
|
|
@@ -3446,7 +3444,7 @@ function createPublicContext(context) {
|
|
|
3446
3444
|
async function createContext(options, userConfig) {
|
|
3447
3445
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3448
3446
|
return {
|
|
3449
|
-
version: "2.0.0-
|
|
3447
|
+
version: "2.0.0-beta.0",
|
|
3450
3448
|
rootPath,
|
|
3451
3449
|
distPath: '',
|
|
3452
3450
|
cachePath,
|
|
@@ -3625,20 +3623,11 @@ let configChain_CHAIN_ID = {
|
|
|
3625
3623
|
SVELTE: 'svelte'
|
|
3626
3624
|
},
|
|
3627
3625
|
ONE_OF: {
|
|
3628
|
-
JS_MAIN: 'js
|
|
3626
|
+
JS_MAIN: 'js',
|
|
3629
3627
|
JS_RAW: 'js-raw',
|
|
3630
|
-
CSS_MAIN: 'css
|
|
3628
|
+
CSS_MAIN: 'css',
|
|
3631
3629
|
CSS_RAW: 'css-raw',
|
|
3632
3630
|
CSS_INLINE: 'css-inline',
|
|
3633
|
-
LESS_MAIN: 'less-main',
|
|
3634
|
-
LESS_RAW: 'less-raw',
|
|
3635
|
-
LESS_INLINE: 'less-inline',
|
|
3636
|
-
SASS_MAIN: 'sass-main',
|
|
3637
|
-
SASS_RAW: 'sass-raw',
|
|
3638
|
-
SASS_INLINE: 'sass-inline',
|
|
3639
|
-
STYLUS_MAIN: 'stylus-main',
|
|
3640
|
-
STYLUS_RAW: 'stylus-raw',
|
|
3641
|
-
STYLUS_INLINE: 'stylus-inline',
|
|
3642
3631
|
SVG: 'svg',
|
|
3643
3632
|
SVG_RAW: 'svg-asset-raw',
|
|
3644
3633
|
SVG_URL: 'svg-asset-url',
|
|
@@ -3685,9 +3674,9 @@ let configChain_CHAIN_ID = {
|
|
|
3685
3674
|
JS: 'js',
|
|
3686
3675
|
CSS: 'css'
|
|
3687
3676
|
}
|
|
3688
|
-
}
|
|
3677
|
+
};
|
|
3689
3678
|
function pluginHelper_getHTMLPlugin(config) {
|
|
3690
|
-
return config?.html.implementation === 'native' ?
|
|
3679
|
+
return config?.html.implementation === 'native' ? core_rspack.HtmlRspackPlugin : (pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = requireCompiledPackage('html-rspack-plugin')), pluginHelper_htmlPlugin);
|
|
3691
3680
|
}
|
|
3692
3681
|
async function modifyRspackConfig(context, rspackConfig, chainUtils) {
|
|
3693
3682
|
src_logger.debug('applying modifyRspackConfig hook');
|
|
@@ -3743,7 +3732,7 @@ function getConfigUtils(getCurrentConfig, chainUtils) {
|
|
|
3743
3732
|
}
|
|
3744
3733
|
function getChainUtils(target, environment, environments) {
|
|
3745
3734
|
return {
|
|
3746
|
-
rspack:
|
|
3735
|
+
rspack: core_rspack,
|
|
3747
3736
|
environment,
|
|
3748
3737
|
environments,
|
|
3749
3738
|
env: process.env.NODE_ENV || '',
|
|
@@ -3766,7 +3755,7 @@ function validateRspackConfig(config) {
|
|
|
3766
3755
|
config.devServer && src_logger.warn(`${picocolors_default().dim('[rsbuild:config]')} Find invalid Rspack config: "${picocolors_default().yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
|
|
3767
3756
|
}
|
|
3768
3757
|
async function generateRspackConfig({ target, context, environmentName }) {
|
|
3769
|
-
let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } =
|
|
3758
|
+
let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = core_rspack, rspackConfig = (await modifyBundlerChain(context, {
|
|
3770
3759
|
...chainUtils,
|
|
3771
3760
|
bundler: {
|
|
3772
3761
|
BannerPlugin,
|
|
@@ -3816,13 +3805,13 @@ let createEnvironmentNotFoundError = (environments = [])=>{
|
|
|
3816
3805
|
};
|
|
3817
3806
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
3818
3807
|
var config, rootPath;
|
|
3819
|
-
let defaultConfig;
|
|
3808
|
+
let defaultConfig, host;
|
|
3820
3809
|
if (context.normalizedConfig) return context.normalizedConfig;
|
|
3821
3810
|
await initPlugins({
|
|
3822
3811
|
context,
|
|
3823
3812
|
pluginManager
|
|
3824
3813
|
}), await modifyRsbuildConfig(context);
|
|
3825
|
-
let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.publicDir = ((rootPath, publicDir)=>{
|
|
3814
|
+
let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.host = 'string' == typeof (host = config.server.host) ? host : !0 === host ? ALL_INTERFACES_IPV4 : LOCALHOST, config.server.publicDir = ((rootPath, publicDir)=>{
|
|
3826
3815
|
if (!1 === publicDir) return [];
|
|
3827
3816
|
let defaultConfig = {
|
|
3828
3817
|
name: (0, external_node_path_.join)(rootPath, 'public'),
|
|
@@ -3982,7 +3971,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
3982
3971
|
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
3983
3972
|
bundlerConfigs: rspackConfigs,
|
|
3984
3973
|
environments: context.environments
|
|
3985
|
-
}), (version =
|
|
3974
|
+
}), (version = core_rspack.rspackVersion).includes('-canary') && (version = version.split('-canary')[0]), !(!(version && /^[\d.]+$/.test(version)) || ((version1, version2)=>{
|
|
3986
3975
|
let parts1 = version1.split('.').map(Number), parts2 = version2.split('.').map(Number), len = Math.max(parts1.length, parts2.length);
|
|
3987
3976
|
for(let i = 0; i < len; i++){
|
|
3988
3977
|
let item1 = parts1[i] ?? 0, item2 = parts2[i] ?? 0;
|
|
@@ -3991,10 +3980,10 @@ async function createCompiler_createCompiler(options) {
|
|
|
3991
3980
|
}
|
|
3992
3981
|
return 0;
|
|
3993
3982
|
})(version, '1.5.0') >= 0)) throw Error(`${picocolors_default().dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors_default().green("1.5.0")}`);
|
|
3994
|
-
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ?
|
|
3983
|
+
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? core_rspack(rspackConfigs) : core_rspack(rspackConfigs[0]);
|
|
3995
3984
|
'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
|
|
3996
3985
|
let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
3997
|
-
isVersionLogged || (src_logger.debug(`using Rspack v${
|
|
3986
|
+
isVersionLogged || (src_logger.debug(`using Rspack v${core_rspack.rspackVersion}`), isVersionLogged = !0);
|
|
3998
3987
|
}, lazyModules = new Set();
|
|
3999
3988
|
compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
|
|
4000
3989
|
let log = args[0];
|
|
@@ -4104,7 +4093,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
4104
4093
|
context,
|
|
4105
4094
|
compiler,
|
|
4106
4095
|
bundlerConfigs: rspackConfigs,
|
|
4107
|
-
MultiStatsCtor:
|
|
4096
|
+
MultiStatsCtor: core_rspack.MultiStats
|
|
4108
4097
|
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
4109
4098
|
compiler,
|
|
4110
4099
|
environments: context.environments
|
|
@@ -4173,7 +4162,7 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
|
|
|
4173
4162
|
rspackConfigs,
|
|
4174
4163
|
compiler,
|
|
4175
4164
|
isWatch: !!watch,
|
|
4176
|
-
MultiStatsCtor:
|
|
4165
|
+
MultiStatsCtor: core_rspack.MultiStats
|
|
4177
4166
|
}), watch) {
|
|
4178
4167
|
let watchOptions = rspackConfigs.map((options)=>options.watchOptions || {});
|
|
4179
4168
|
return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
|
|
@@ -4246,7 +4235,7 @@ let chainStaticAssetRule = ({ emit, rule, maxSize, filename, assetType })=>{
|
|
|
4246
4235
|
let generatorOptions = {
|
|
4247
4236
|
filename
|
|
4248
4237
|
};
|
|
4249
|
-
emit || (generatorOptions.emit = !1), rule.oneOf(`${assetType}-asset-url`).type('asset/resource').resourceQuery(/^\?
|
|
4238
|
+
emit || (generatorOptions.emit = !1), rule.oneOf(`${assetType}-asset-url`).type('asset/resource').resourceQuery(/^\?url$/).set('generator', generatorOptions), rule.oneOf(`${assetType}-asset-inline`).type('asset/inline').resourceQuery(INLINE_QUERY_REGEX), rule.oneOf(`${assetType}-asset-raw`).type('asset/source').resourceQuery(RAW_QUERY_REGEX), rule.oneOf(`${assetType}-asset`).type('asset').parser({
|
|
4250
4239
|
dataUrlCondition: {
|
|
4251
4240
|
maxSize
|
|
4252
4241
|
}
|
|
@@ -4262,7 +4251,7 @@ function getRegExpForExts(exts) {
|
|
|
4262
4251
|
return RegExp(1 === normalizedExts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
|
|
4263
4252
|
}
|
|
4264
4253
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
4265
|
-
return cacheDirectory ? (0, external_node_path_.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_.join)(context.rootPath, cacheDirectory) : (0, external_node_path_.join)(context.cachePath,
|
|
4254
|
+
return cacheDirectory ? (0, external_node_path_.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_.join)(context.rootPath, cacheDirectory) : (0, external_node_path_.join)(context.cachePath, 'rspack');
|
|
4266
4255
|
}
|
|
4267
4256
|
async function getBuildDependencies(context, config, environmentContext, additionalDependencies) {
|
|
4268
4257
|
let rootPackageJson = (0, external_node_path_.join)(context.rootPath, 'package.json'), browserslistConfig = (0, external_node_path_.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
|
|
@@ -4700,7 +4689,7 @@ class RsbuildHtmlPlugin {
|
|
|
4700
4689
|
} catch (error) {
|
|
4701
4690
|
return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${picocolors_default().dim('[rsbuild:html]')} Failed to read the favicon file at ${picocolors_default().yellow(inputFilename)}.`), null;
|
|
4702
4691
|
}
|
|
4703
|
-
let source = new
|
|
4692
|
+
let source = new core_rspack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_.default.posix.join(faviconDistPath, name);
|
|
4704
4693
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
4705
4694
|
}, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
|
|
4706
4695
|
let href = favicon;
|
|
@@ -5236,10 +5225,7 @@ function pluginModuleFederation() {
|
|
|
5236
5225
|
config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port && !config.dev.client?.port && (config.dev.client ||= {}, config.dev.client.port = config.server.port), userConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === config.server?.base && (config.dev.assetPrefix = !0);
|
|
5237
5226
|
}
|
|
5238
5227
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
5239
|
-
config.moduleFederation?.options && (config.
|
|
5240
|
-
...config.performance.chunkSplit,
|
|
5241
|
-
strategy: 'custom'
|
|
5242
|
-
}), config.source.include = [
|
|
5228
|
+
config.moduleFederation?.options && (config.source.include = [
|
|
5243
5229
|
...config.source.include || [],
|
|
5244
5230
|
/@module-federation[\\/]/
|
|
5245
5231
|
]);
|
|
@@ -5247,7 +5233,7 @@ function pluginModuleFederation() {
|
|
|
5247
5233
|
let { config } = environment;
|
|
5248
5234
|
if (!config.moduleFederation?.options || 'web' !== target) return;
|
|
5249
5235
|
let { options } = config.moduleFederation;
|
|
5250
|
-
chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(
|
|
5236
|
+
chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(core_rspack.container.ModuleFederationPlugin, [
|
|
5251
5237
|
options
|
|
5252
5238
|
]), options.name && !chain.output.get('uniqueName') && chain.output.set('uniqueName', options.name);
|
|
5253
5239
|
});
|
|
@@ -5266,7 +5252,6 @@ function getPublicPath({ isDev, config, context }) {
|
|
|
5266
5252
|
let defaultPort = server.port ?? 3000;
|
|
5267
5253
|
return formatPublicPath(replacePortPlaceholder(publicPath, isDev ? context.devServer?.port ?? defaultPort : defaultPort));
|
|
5268
5254
|
}
|
|
5269
|
-
let resolve_require = (0, external_node_module_.createRequire)(import.meta.url);
|
|
5270
5255
|
function applyAlias({ chain, config, rootPath }) {
|
|
5271
5256
|
let mergedAlias = reduceConfigs({
|
|
5272
5257
|
initial: {},
|
|
@@ -5279,14 +5264,14 @@ function applyAlias({ chain, config, rootPath }) {
|
|
|
5279
5264
|
continue;
|
|
5280
5265
|
}
|
|
5281
5266
|
try {
|
|
5282
|
-
pkgPath = (0, external_node_path_.dirname)(
|
|
5267
|
+
pkgPath = (0, external_node_path_.dirname)(vendors_require.resolve(`${pkgName}/package.json`, {
|
|
5283
5268
|
paths: [
|
|
5284
5269
|
rootPath
|
|
5285
5270
|
]
|
|
5286
5271
|
}));
|
|
5287
5272
|
} catch {}
|
|
5288
5273
|
if (!pkgPath) try {
|
|
5289
|
-
pkgPath =
|
|
5274
|
+
pkgPath = vendors_require.resolve(pkgName, {
|
|
5290
5275
|
paths: [
|
|
5291
5276
|
rootPath
|
|
5292
5277
|
]
|
|
@@ -5416,7 +5401,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
5416
5401
|
rel,
|
|
5417
5402
|
...option
|
|
5418
5403
|
}
|
|
5419
|
-
}))
|
|
5404
|
+
}));
|
|
5420
5405
|
function resolveLayer(value) {
|
|
5421
5406
|
return "OVERVIEW" === value ? 'info' : "ALL" === value ? 'trace' : value;
|
|
5422
5407
|
}
|
|
@@ -5433,7 +5418,7 @@ async function applyProfile(root, filterValue, traceLayer = 'perfetto', traceOut
|
|
|
5433
5418
|
traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
|
|
5434
5419
|
}
|
|
5435
5420
|
let filter = resolveLayer(filterValue);
|
|
5436
|
-
return await ensureFileDir(traceOutput), await
|
|
5421
|
+
return await ensureFileDir(traceOutput), await core_rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
|
|
5437
5422
|
}
|
|
5438
5423
|
function getForceSplittingGroups(forceSplitting, strategy) {
|
|
5439
5424
|
let cacheGroups = {};
|
|
@@ -5449,6 +5434,56 @@ function getForceSplittingGroups(forceSplitting, strategy) {
|
|
|
5449
5434
|
};
|
|
5450
5435
|
return cacheGroups;
|
|
5451
5436
|
}
|
|
5437
|
+
function resolveDefaultPreset(config) {
|
|
5438
|
+
let { polyfill } = config.output;
|
|
5439
|
+
return 'entry' === polyfill || 'usage' === polyfill ? {
|
|
5440
|
+
cacheGroups: {
|
|
5441
|
+
'lib-polyfill': {
|
|
5442
|
+
name: 'lib-polyfill',
|
|
5443
|
+
test: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/,
|
|
5444
|
+
priority: 0
|
|
5445
|
+
}
|
|
5446
|
+
}
|
|
5447
|
+
} : {};
|
|
5448
|
+
}
|
|
5449
|
+
function resolvePerPackagePreset() {
|
|
5450
|
+
return {
|
|
5451
|
+
minSize: 0,
|
|
5452
|
+
maxInitialRequests: 1 / 0,
|
|
5453
|
+
cacheGroups: {
|
|
5454
|
+
vendors: {
|
|
5455
|
+
priority: -9,
|
|
5456
|
+
test: NODE_MODULES_REGEX,
|
|
5457
|
+
name: (module)=>module ? getPackageNameFromModulePath(module.context) : void 0
|
|
5458
|
+
}
|
|
5459
|
+
}
|
|
5460
|
+
};
|
|
5461
|
+
}
|
|
5462
|
+
function resolveSingleVendorPreset() {
|
|
5463
|
+
return {
|
|
5464
|
+
cacheGroups: {
|
|
5465
|
+
singleVendor: {
|
|
5466
|
+
test: NODE_MODULES_REGEX,
|
|
5467
|
+
priority: 0,
|
|
5468
|
+
chunks: 'all',
|
|
5469
|
+
name: 'vendor',
|
|
5470
|
+
enforce: !0
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
};
|
|
5474
|
+
}
|
|
5475
|
+
function splitByExperience(ctx) {
|
|
5476
|
+
let { override, config, forceSplittingGroups } = ctx;
|
|
5477
|
+
return {
|
|
5478
|
+
...getDefaultSplitChunksForWeb(config),
|
|
5479
|
+
...override,
|
|
5480
|
+
cacheGroups: {
|
|
5481
|
+
...resolveDefaultPreset(config)?.cacheGroups,
|
|
5482
|
+
...forceSplittingGroups,
|
|
5483
|
+
...override.cacheGroups
|
|
5484
|
+
}
|
|
5485
|
+
};
|
|
5486
|
+
}
|
|
5452
5487
|
let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
|
|
5453
5488
|
function getPackageNameFromModulePath(modulePath) {
|
|
5454
5489
|
let handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
|
|
@@ -5460,98 +5495,93 @@ function getPackageNameFromModulePath(modulePath) {
|
|
|
5460
5495
|
name
|
|
5461
5496
|
].filter(Boolean).join('.');
|
|
5462
5497
|
}
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
name: key
|
|
5474
|
-
};
|
|
5498
|
+
function splitByModule(ctx) {
|
|
5499
|
+
let { config, override, forceSplittingGroups } = ctx, perPackageOptions = resolvePerPackagePreset();
|
|
5500
|
+
return {
|
|
5501
|
+
...getDefaultSplitChunksForWeb(config),
|
|
5502
|
+
...perPackageOptions,
|
|
5503
|
+
...override,
|
|
5504
|
+
cacheGroups: {
|
|
5505
|
+
...forceSplittingGroups,
|
|
5506
|
+
...perPackageOptions.cacheGroups,
|
|
5507
|
+
...override.cacheGroups
|
|
5475
5508
|
}
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
...
|
|
5513
|
-
cacheGroups
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
}
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
}
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
...forceSplittingGroups,
|
|
5550
|
-
...override.cacheGroups
|
|
5551
|
-
}
|
|
5552
|
-
};
|
|
5509
|
+
};
|
|
5510
|
+
}
|
|
5511
|
+
function splitBySize(ctx) {
|
|
5512
|
+
let { override, forceSplittingGroups, config } = ctx, { minSize = 0, maxSize = 1 / 0 } = config.performance.chunkSplit;
|
|
5513
|
+
return {
|
|
5514
|
+
...getDefaultSplitChunksForWeb(config),
|
|
5515
|
+
minSize,
|
|
5516
|
+
maxSize,
|
|
5517
|
+
...override,
|
|
5518
|
+
cacheGroups: {
|
|
5519
|
+
...forceSplittingGroups,
|
|
5520
|
+
...override.cacheGroups
|
|
5521
|
+
}
|
|
5522
|
+
};
|
|
5523
|
+
}
|
|
5524
|
+
function splitCustom(ctx) {
|
|
5525
|
+
let { config, override, forceSplittingGroups } = ctx;
|
|
5526
|
+
return {
|
|
5527
|
+
...getDefaultSplitChunksForWeb(config),
|
|
5528
|
+
...override,
|
|
5529
|
+
cacheGroups: {
|
|
5530
|
+
...forceSplittingGroups,
|
|
5531
|
+
...override.cacheGroups
|
|
5532
|
+
}
|
|
5533
|
+
};
|
|
5534
|
+
}
|
|
5535
|
+
function allInOne(_ctx) {
|
|
5536
|
+
return !1;
|
|
5537
|
+
}
|
|
5538
|
+
function singleVendor(ctx) {
|
|
5539
|
+
let { config, override, forceSplittingGroups } = ctx;
|
|
5540
|
+
return {
|
|
5541
|
+
...getDefaultSplitChunksForWeb(config),
|
|
5542
|
+
...override,
|
|
5543
|
+
cacheGroups: {
|
|
5544
|
+
...resolveSingleVendorPreset().cacheGroups,
|
|
5545
|
+
...forceSplittingGroups,
|
|
5546
|
+
...override.cacheGroups
|
|
5547
|
+
}
|
|
5548
|
+
};
|
|
5549
|
+
}
|
|
5550
|
+
let getDefaultSplitChunksForWeb = (config)=>({
|
|
5551
|
+
chunks: config.moduleFederation?.options?.exposes ? 'async' : 'all'
|
|
5552
|
+
});
|
|
5553
|
+
function makeLegacySplitChunksOptions(chunkSplit, config, rootPath) {
|
|
5554
|
+
let forceSplittingGroups = {};
|
|
5555
|
+
chunkSplit.forceSplitting && (forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting, chunkSplit.strategy));
|
|
5556
|
+
let override = 'custom' === chunkSplit.strategy ? chunkSplit.splitChunks ?? chunkSplit.override : chunkSplit.override;
|
|
5557
|
+
return ({
|
|
5558
|
+
'all-in-one': allInOne,
|
|
5559
|
+
'split-by-experience': splitByExperience,
|
|
5560
|
+
'split-by-module': splitByModule,
|
|
5561
|
+
'split-by-size': splitBySize,
|
|
5562
|
+
'single-vendor': singleVendor,
|
|
5563
|
+
custom: splitCustom
|
|
5564
|
+
})[chunkSplit.strategy || 'split-by-experience']({
|
|
5565
|
+
config,
|
|
5566
|
+
rootPath,
|
|
5567
|
+
override: override || {},
|
|
5568
|
+
forceSplittingGroups
|
|
5569
|
+
});
|
|
5570
|
+
}
|
|
5571
|
+
function getSplitChunksByPreset(config, preset) {
|
|
5572
|
+
if (!preset) return {};
|
|
5573
|
+
switch(preset){
|
|
5574
|
+
case 'default':
|
|
5575
|
+
return resolveDefaultPreset(config);
|
|
5576
|
+
case 'single-vendor':
|
|
5577
|
+
return resolveSingleVendorPreset();
|
|
5578
|
+
case 'per-package':
|
|
5579
|
+
return resolvePerPackagePreset();
|
|
5580
|
+
default:
|
|
5581
|
+
throw Error(`[rsbuild] Unknown splitChunks preset: ${preset}`);
|
|
5553
5582
|
}
|
|
5554
|
-
}
|
|
5583
|
+
}
|
|
5584
|
+
let builtinSwcLoaderName = 'builtin:swc-loader';
|
|
5555
5585
|
function applyScriptCondition({ rule, isDev, config, rsbuildTarget }) {
|
|
5556
5586
|
for (let condition of (rule.include.add({
|
|
5557
5587
|
not: NODE_MODULES_REGEX
|
|
@@ -5588,7 +5618,7 @@ function getDefaultSwcConfig({ browserslist, cacheRoot, config, isProd }) {
|
|
|
5588
5618
|
function applyCoreJs(swcConfig, polyfillMode, rootPath) {
|
|
5589
5619
|
let coreJsPath = ((rootPath)=>{
|
|
5590
5620
|
try {
|
|
5591
|
-
return
|
|
5621
|
+
return vendors_require.resolve('core-js/package.json', {
|
|
5592
5622
|
paths: [
|
|
5593
5623
|
rootPath,
|
|
5594
5624
|
import.meta.dirname
|
|
@@ -5992,7 +6022,7 @@ init(
|
|
|
5992
6022
|
${JSON.stringify(config.dev.client.logLevel)}
|
|
5993
6023
|
)
|
|
5994
6024
|
`;
|
|
5995
|
-
new
|
|
6025
|
+
new core_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
|
|
5996
6026
|
name: void 0
|
|
5997
6027
|
}).apply(compiler);
|
|
5998
6028
|
}
|
|
@@ -6230,10 +6260,7 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
|
|
|
6230
6260
|
fullStack && (log1 += fullStack);
|
|
6231
6261
|
}
|
|
6232
6262
|
}
|
|
6233
|
-
return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${picocolors_default().yellow(
|
|
6234
|
-
- To access \`process.env.*\`, define them in a \`.env\` file with the \`PUBLIC_\` prefix.
|
|
6235
|
-
- Or configure them via \`source.define\`.
|
|
6236
|
-
- Alternatively, install \`@rsbuild/plugin-node-polyfill\` to polyfill Node.js globals.`)}` : log;
|
|
6263
|
+
return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${picocolors_default().yellow(" - `process` is a Node.js global and not available in browsers.\n - To access `process.env.*`, define them in a `.env` file with the `PUBLIC_` prefix.\n - Or configure them via `source.define`.\n - Alternatively, install `@rsbuild/plugin-node-polyfill` to polyfill Node.js globals.")}` : log;
|
|
6237
6264
|
}, styles = {
|
|
6238
6265
|
1: 'font-weight:bold',
|
|
6239
6266
|
2: 'opacity:0.5',
|
|
@@ -6755,7 +6782,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServerA
|
|
|
6755
6782
|
let { compress } = server;
|
|
6756
6783
|
if (compress && middlewares.push(gzipMiddleware_gzipMiddleware('object' == typeof compress ? compress : void 0)), 'dev' === context.action && buildManager) {
|
|
6757
6784
|
let { compiler } = buildManager;
|
|
6758
|
-
(compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.push(
|
|
6785
|
+
(compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.push(core_rspack.lazyCompilationMiddleware(compiler));
|
|
6759
6786
|
}
|
|
6760
6787
|
server.base && '/' !== server.base && middlewares.push(getBaseUrlMiddleware({
|
|
6761
6788
|
base: server.base
|
|
@@ -6971,7 +6998,7 @@ class BasicRunner {
|
|
|
6971
6998
|
});
|
|
6972
6999
|
}
|
|
6973
7000
|
}
|
|
6974
|
-
let
|
|
7001
|
+
let cjs_define = (...args)=>{
|
|
6975
7002
|
args.pop()();
|
|
6976
7003
|
};
|
|
6977
7004
|
class CommonJsRunner extends BasicRunner {
|
|
@@ -7013,16 +7040,16 @@ class CommonJsRunner extends BasicRunner {
|
|
|
7013
7040
|
}
|
|
7014
7041
|
createMissRequirer() {
|
|
7015
7042
|
return (_currentDirectory, modulePath, _context = {})=>{
|
|
7016
|
-
let resolvedPath =
|
|
7043
|
+
let resolvedPath = vendors_require.resolve(modulePath, {
|
|
7017
7044
|
paths: [
|
|
7018
7045
|
_currentDirectory
|
|
7019
7046
|
]
|
|
7020
7047
|
});
|
|
7021
|
-
return
|
|
7048
|
+
return vendors_require(resolvedPath.startsWith('node:') ? resolvedPath.slice(5) : resolvedPath);
|
|
7022
7049
|
};
|
|
7023
7050
|
}
|
|
7024
7051
|
createCjsRequirer() {
|
|
7025
|
-
let requireCache = Object.create(null), vm =
|
|
7052
|
+
let requireCache = Object.create(null), vm = vendors_require('node:vm');
|
|
7026
7053
|
return (currentDirectory, modulePath, context = {})=>{
|
|
7027
7054
|
let file = context.file || this.getFile(modulePath, currentDirectory);
|
|
7028
7055
|
if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
|
|
@@ -7043,7 +7070,6 @@ class CommonJsRunner extends BasicRunner {
|
|
|
7043
7070
|
};
|
|
7044
7071
|
}
|
|
7045
7072
|
}
|
|
7046
|
-
let esm_require = (0, external_node_module_.createRequire)(import.meta.url);
|
|
7047
7073
|
class EsmRunner extends CommonJsRunner {
|
|
7048
7074
|
createRunner() {
|
|
7049
7075
|
super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
|
|
@@ -7060,14 +7086,14 @@ class EsmRunner extends CommonJsRunner {
|
|
|
7060
7086
|
});
|
|
7061
7087
|
}
|
|
7062
7088
|
createEsmRequirer() {
|
|
7063
|
-
let esmCache = new Map(), esmIdentifier = this._options.name, vm =
|
|
7089
|
+
let esmCache = new Map(), esmIdentifier = this._options.name, vm = vendors_require('node:vm');
|
|
7064
7090
|
return (currentDirectory, modulePath, context = {})=>{
|
|
7065
7091
|
if (!vm.SourceTextModule) throw Error(`${picocolors_default().dim('[rsbuild:runner]')} Running ESM bundle needs add Node.js option ${picocolors_default().yellow('--experimental-vm-modules')}.`);
|
|
7066
7092
|
let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
|
|
7067
7093
|
if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
|
|
7068
7094
|
let esm = esmCache.get(file.path);
|
|
7069
7095
|
return (esm || (esm = new vm.SourceTextModule(file.content, {
|
|
7070
|
-
identifier:
|
|
7096
|
+
identifier: file.path,
|
|
7071
7097
|
url: `${(0, external_node_url_.pathToFileURL)(file.path).href}?${esmIdentifier}`,
|
|
7072
7098
|
initializeImportMeta: (meta, _)=>{
|
|
7073
7099
|
meta.url = (0, external_node_url_.pathToFileURL)(file.path).href;
|
|
@@ -7076,7 +7102,7 @@ class EsmRunner extends CommonJsRunner {
|
|
|
7076
7102
|
esmMode: 1
|
|
7077
7103
|
}), module.context)
|
|
7078
7104
|
}), esmCache.set(file.path, esm)), 2 === context.esmMode) ? esm : (async ()=>{
|
|
7079
|
-
if (await esm.link(async (specifier, referencingModule)=>asModule(await _require(external_node_path_.default.dirname(referencingModule.identifier
|
|
7105
|
+
if (await esm.link(async (specifier, referencingModule)=>asModule(await _require(external_node_path_.default.dirname(referencingModule.identifier ?? (0, external_node_url_.fileURLToPath)(referencingModule.url)), specifier, {
|
|
7080
7106
|
esmMode: 2
|
|
7081
7107
|
}), referencingModule.context, !0)), await esm.evaluate(), 1 === context.esmMode) return esm;
|
|
7082
7108
|
let ns = esm.namespace;
|
|
@@ -8117,16 +8143,16 @@ try {
|
|
|
8117
8143
|
cssRule.test(CSS_REGEX).dependency({
|
|
8118
8144
|
not: 'url'
|
|
8119
8145
|
});
|
|
8120
|
-
let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).
|
|
8146
|
+
let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).resourceQuery(INLINE_QUERY_REGEX);
|
|
8121
8147
|
cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
|
|
8122
|
-
let mainRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN)
|
|
8148
|
+
let mainRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN), emitCss = config.output.emitCss ?? 'web' === target;
|
|
8123
8149
|
if (emitCss) if (config.output.injectStyles) {
|
|
8124
8150
|
let styleLoaderOptions = reduceConfigs({
|
|
8125
8151
|
initial: {},
|
|
8126
8152
|
config: config.tools.styleLoader
|
|
8127
8153
|
});
|
|
8128
8154
|
mainRule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
|
|
8129
|
-
} else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin ||
|
|
8155
|
+
} else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || core_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
|
|
8130
8156
|
else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(dirname, 'ignoreCssLoader.mjs'));
|
|
8131
8157
|
let importLoaders = {
|
|
8132
8158
|
normal: 0,
|
|
@@ -8214,7 +8240,7 @@ try {
|
|
|
8214
8240
|
let isStringExport = 'string' === cssLoaderOptions.exportType;
|
|
8215
8241
|
if (isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
|
|
8216
8242
|
let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
|
|
8217
|
-
chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin ||
|
|
8243
|
+
chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || core_rspack.CssExtractRspackPlugin, [
|
|
8218
8244
|
{
|
|
8219
8245
|
filename: isCssFilenameFn ? (...args)=>{
|
|
8220
8246
|
let name = cssFilename(...args);
|
|
@@ -8348,29 +8374,34 @@ try {
|
|
|
8348
8374
|
{
|
|
8349
8375
|
name: 'rsbuild:split-chunks',
|
|
8350
8376
|
setup (api) {
|
|
8351
|
-
api.modifyBundlerChain(
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8377
|
+
api.modifyBundlerChain((chain, { environment, isServer, isWebWorker })=>{
|
|
8378
|
+
let { config } = environment, { splitChunks } = config;
|
|
8379
|
+
if (isWebWorker && chain.module.parser.merge({
|
|
8380
|
+
javascript: {
|
|
8381
|
+
dynamicImportMode: 'eager'
|
|
8382
|
+
}
|
|
8383
|
+
}), isServer || isWebWorker) {
|
|
8384
|
+
if (!1 === splitChunks || 0 === Object.keys(splitChunks).length) chain.optimization.splitChunks(!1);
|
|
8385
|
+
else {
|
|
8386
|
+
let { preset, ...rest } = splitChunks;
|
|
8387
|
+
chain.optimization.splitChunks({
|
|
8388
|
+
...getSplitChunksByPreset(config, preset),
|
|
8389
|
+
...rest
|
|
8390
|
+
});
|
|
8391
|
+
}
|
|
8358
8392
|
return;
|
|
8359
8393
|
}
|
|
8360
|
-
let {
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
polyfill: config.output.polyfill
|
|
8372
|
-
});
|
|
8373
|
-
chain.optimization.splitChunks(splitChunksOptions);
|
|
8394
|
+
let { chunkSplit } = config.performance;
|
|
8395
|
+
if (chunkSplit && !1 !== splitChunks && 0 === Object.keys(splitChunks).length) return void chain.optimization.splitChunks(makeLegacySplitChunksOptions(chunkSplit, config, api.context.rootPath));
|
|
8396
|
+
if (chunkSplit && src_logger.warn('[rsbuild:config] Both `performance.chunkSplit` and `splitChunks` are set. The `performance.chunkSplit` option is deprecated and will not work. Use `splitChunks` instead.'), !1 === splitChunks) chain.optimization.splitChunks(!1);
|
|
8397
|
+
else {
|
|
8398
|
+
let { preset = 'default', ...rest } = splitChunks;
|
|
8399
|
+
chain.optimization.splitChunks({
|
|
8400
|
+
...getDefaultSplitChunksForWeb(config),
|
|
8401
|
+
...getSplitChunksByPreset(config, preset),
|
|
8402
|
+
...rest
|
|
8403
|
+
});
|
|
8404
|
+
}
|
|
8374
8405
|
});
|
|
8375
8406
|
}
|
|
8376
8407
|
},
|
|
@@ -8461,7 +8492,7 @@ try {
|
|
|
8461
8492
|
for (let config of bundlerConfigs)if (config.plugins?.some((plugin)=>isRsdoctorPlugin(plugin))) return;
|
|
8462
8493
|
let packageName = '@rsdoctor/rspack-plugin';
|
|
8463
8494
|
try {
|
|
8464
|
-
packagePath =
|
|
8495
|
+
packagePath = vendors_require.resolve(packageName, {
|
|
8465
8496
|
paths: [
|
|
8466
8497
|
api.context.rootPath
|
|
8467
8498
|
]
|
|
@@ -8603,7 +8634,7 @@ try {
|
|
|
8603
8634
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
8604
8635
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
8605
8636
|
if (!1 === manifest) return;
|
|
8606
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.
|
|
8637
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
8607
8638
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
8608
8639
|
let pluginOptions = {
|
|
8609
8640
|
fileName: manifestOptions.filename,
|
|
@@ -8687,7 +8718,7 @@ try {
|
|
|
8687
8718
|
api.onBeforeBuild(async ({ isFirstCompile })=>{
|
|
8688
8719
|
isFirstCompile && await onStart();
|
|
8689
8720
|
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
8690
|
-
traceOutput && (
|
|
8721
|
+
traceOutput && (core_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${picocolors_default().cyan(traceOutput)}`));
|
|
8691
8722
|
});
|
|
8692
8723
|
}
|
|
8693
8724
|
},
|
|
@@ -8742,7 +8773,7 @@ try {
|
|
|
8742
8773
|
let nonce = nonces[index], environment = environmentList.find((item)=>item.index === index);
|
|
8743
8774
|
if (!Object.keys(environment?.htmlPaths ?? {}).length || !nonce) return;
|
|
8744
8775
|
let injectCode = createVirtualModule(`__webpack_nonce__ = "${nonce}";`);
|
|
8745
|
-
new
|
|
8776
|
+
new core_rspack.EntryPlugin(compiler.context, injectCode, {
|
|
8746
8777
|
name: void 0
|
|
8747
8778
|
}).apply(compiler);
|
|
8748
8779
|
});
|
|
@@ -8978,7 +9009,6 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
8978
9009
|
moduleCache: !1,
|
|
8979
9010
|
interopDefault: !0,
|
|
8980
9011
|
nativeModules: [
|
|
8981
|
-
'@rspack/core',
|
|
8982
9012
|
"typescript"
|
|
8983
9013
|
]
|
|
8984
9014
|
});
|
|
@@ -9014,7 +9044,7 @@ let commonOpts = {}, init_loadConfig = async (root)=>{
|
|
|
9014
9044
|
envMode: commonOpts.envMode,
|
|
9015
9045
|
loader: commonOpts.configLoader
|
|
9016
9046
|
});
|
|
9017
|
-
return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.logLevel && (config.logLevel = commonOpts.logLevel), commonOpts.open && !config.server?.open && (config.server.open = commonOpts.open), commonOpts.host && (config.server.host =
|
|
9047
|
+
return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.logLevel && (config.logLevel = commonOpts.logLevel), commonOpts.open && !config.server?.open && (config.server.open = commonOpts.open), void 0 !== commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
|
|
9018
9048
|
...config.dev.watchFiles ? helpers_castArray(config.dev.watchFiles) : [],
|
|
9019
9049
|
{
|
|
9020
9050
|
paths: filePath,
|
|
@@ -9112,7 +9142,7 @@ let applyServerOptions = (command)=>{
|
|
|
9112
9142
|
};
|
|
9113
9143
|
function setupCommands() {
|
|
9114
9144
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9115
|
-
cli.version("2.0.0-
|
|
9145
|
+
cli.version("2.0.0-beta.0"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
9116
9146
|
default: 'auto'
|
|
9117
9147
|
}).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
9118
9148
|
type: [
|
|
@@ -9181,7 +9211,7 @@ function initNodeEnv() {
|
|
|
9181
9211
|
}
|
|
9182
9212
|
function showGreeting() {
|
|
9183
9213
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9184
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-
|
|
9214
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.0\n`);
|
|
9185
9215
|
}
|
|
9186
9216
|
function setupLogLevel() {
|
|
9187
9217
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9202,5 +9232,5 @@ function runCLI() {
|
|
|
9202
9232
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
9203
9233
|
}
|
|
9204
9234
|
}
|
|
9205
|
-
let src_version = "2.0.0-
|
|
9206
|
-
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_os_type, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_os, node_process,
|
|
9235
|
+
let src_version = "2.0.0-beta.0";
|
|
9236
|
+
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_os_type, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_os, node_process, runCLI, src_logger as logger, src_version as version };
|