@rsbuild/core 1.3.6 → 1.3.8

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.js CHANGED
@@ -854,7 +854,7 @@ var EsmMode, __webpack_modules__ = {
854
854
  return k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : +(v1 > v2);
855
855
  }
856
856
  if (entriesA.sort(cmp), entriesB.sort(cmp), entriesA.length !== entriesB.length) return !1;
857
- for(var i = 0; i < entriesA.length; i++)if (entriesA[i][0] !== entriesB[i][0] || (null === (_a = entriesA[i][1]) || void 0 === _a ? void 0 : _a.toString()) !== (null === (_b = entriesB[i][1]) || void 0 === _b ? void 0 : _b.toString())) return !1;
857
+ for(var i = 0; i < entriesA.length; i++)if (entriesA[i][0] !== entriesB[i][0] || (null == (_a = entriesA[i][1]) ? void 0 : _a.toString()) !== (null == (_b = entriesB[i][1]) ? void 0 : _b.toString())) return !1;
858
858
  return !0;
859
859
  };
860
860
  },
@@ -1020,9 +1020,9 @@ let getCompiledPath = (packageName)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b
1020
1020
  }, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep ? filepath : filepath.replace(/\\/g, '/'), isFileSync = (filePath)=>{
1021
1021
  try {
1022
1022
  var _fs_statSync;
1023
- return null === (_fs_statSync = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.statSync(filePath, {
1023
+ return null == (_fs_statSync = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.statSync(filePath, {
1024
1024
  throwIfNoEntry: !1
1025
- })) || void 0 === _fs_statSync ? void 0 : _fs_statSync.isFile();
1025
+ })) ? void 0 : _fs_statSync.isFile();
1026
1026
  } catch (_) {
1027
1027
  return !1;
1028
1028
  }
@@ -1038,10 +1038,7 @@ async function isFileExists(file) {
1038
1038
  }
1039
1039
  async function fileExistsByCompilation({ inputFileSystem }, filePath) {
1040
1040
  return new Promise((resolve)=>{
1041
- if (!inputFileSystem) {
1042
- resolve(!1);
1043
- return;
1044
- }
1041
+ if (!inputFileSystem) return void resolve(!1);
1045
1042
  inputFileSystem.stat(filePath, (err, stats)=>{
1046
1043
  err ? resolve(!1) : resolve(!!(null == stats ? void 0 : stats.isFile()));
1047
1044
  });
@@ -1179,16 +1176,16 @@ function formatMessage(stats, verbose) {
1179
1176
  function formatStatsMessages(stats, verbose) {
1180
1177
  var _stats_errors, _stats_warnings;
1181
1178
  return {
1182
- errors: (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [],
1183
- warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
1179
+ errors: (null == (_stats_errors = stats.errors) ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [],
1180
+ warnings: (null == (_stats_warnings = stats.warnings) ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
1184
1181
  };
1185
1182
  }
1186
1183
  let getAllStatsErrors = (statsData)=>{
1187
1184
  var _statsData_errors, _statsData_children;
1188
- return statsData.errorsCount && (null === (_statsData_errors = statsData.errors) || void 0 === _statsData_errors ? void 0 : _statsData_errors.length) === 0 ? null === (_statsData_children = statsData.children) || void 0 === _statsData_children ? void 0 : _statsData_children.reduce((errors, curr)=>errors.concat(curr.errors || []), []) : statsData.errors;
1185
+ return statsData.errorsCount && (null == (_statsData_errors = statsData.errors) ? void 0 : _statsData_errors.length) === 0 ? null == (_statsData_children = statsData.children) ? void 0 : _statsData_children.reduce((errors, curr)=>errors.concat(curr.errors || []), []) : statsData.errors;
1189
1186
  }, getAllStatsWarnings = (statsData)=>{
1190
1187
  var _statsData_warnings, _statsData_children;
1191
- return statsData.warningsCount && (null === (_statsData_warnings = statsData.warnings) || void 0 === _statsData_warnings ? void 0 : _statsData_warnings.length) === 0 ? null === (_statsData_children = statsData.children) || void 0 === _statsData_children ? void 0 : _statsData_children.reduce((warnings, curr)=>warnings.concat(curr.warnings || []), []) : statsData.warnings;
1188
+ return statsData.warningsCount && (null == (_statsData_warnings = statsData.warnings) ? void 0 : _statsData_warnings.length) === 0 ? null == (_statsData_children = statsData.children) ? void 0 : _statsData_children.reduce((warnings, curr)=>warnings.concat(curr.warnings || []), []) : statsData.warnings;
1192
1189
  };
1193
1190
  function getStatsOptions(compiler) {
1194
1191
  if (helpers_isMultiCompiler(compiler)) return {
@@ -1580,7 +1577,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1580
1577
  }), withDefaultConfig = async (rootPath, config)=>{
1581
1578
  var _merged_server, _config_dev, _config_output;
1582
1579
  let merged = mergeRsbuildConfig(createDefaultConfig(), config);
1583
- if (merged.root ||= rootPath, merged.source ||= {}, (null === (_merged_server = merged.server) || void 0 === _merged_server ? void 0 : _merged_server.base) && ((null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.assetPrefix) === void 0 && (merged.dev ||= {}, merged.dev.assetPrefix = merged.server.base), (null === (_config_output = config.output) || void 0 === _config_output ? void 0 : _config_output.assetPrefix) === void 0 && (merged.output ||= {}, merged.output.assetPrefix = merged.server.base)), !merged.source.tsconfigPath) {
1580
+ if (merged.root ||= rootPath, merged.source ||= {}, (null == (_merged_server = merged.server) ? void 0 : _merged_server.base) && ((null == (_config_dev = config.dev) ? void 0 : _config_dev.assetPrefix) === void 0 && (merged.dev ||= {}, merged.dev.assetPrefix = merged.server.base), (null == (_config_output = config.output) ? void 0 : _config_output.assetPrefix) === void 0 && (merged.output ||= {}, merged.output.assetPrefix = merged.server.base)), !merged.source.tsconfigPath) {
1584
1581
  let tsconfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'tsconfig.json');
1585
1582
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
1586
1583
  }
@@ -1785,7 +1782,7 @@ async function initPlugins({ getPluginAPI, pluginManager }) {
1785
1782
  for (let plugin of plugins){
1786
1783
  var _removedPlugins_plugin_environment, _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL;
1787
1784
  let isGlobalPlugin = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL' === plugin.environment;
1788
- if ((null === (_removedPlugins_plugin_environment = removedPlugins[plugin.environment]) || void 0 === _removedPlugins_plugin_environment ? void 0 : _removedPlugins_plugin_environment.includes(plugin.instance.name)) || !isGlobalPlugin && (null === (_removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL = removedPlugins[RSBUILD_ALL_ENVIRONMENT_SYMBOL]) || void 0 === _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL ? void 0 : _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL.includes(plugin.instance.name))) continue;
1785
+ if ((null == (_removedPlugins_plugin_environment = removedPlugins[plugin.environment]) ? void 0 : _removedPlugins_plugin_environment.includes(plugin.instance.name)) || !isGlobalPlugin && (null == (_removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL = removedPlugins[RSBUILD_ALL_ENVIRONMENT_SYMBOL]) ? void 0 : _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL.includes(plugin.instance.name))) continue;
1789
1786
  let { instance, environment } = plugin;
1790
1787
  await instance.setup(getPluginAPI(environment));
1791
1788
  }
@@ -2101,7 +2098,7 @@ async function updateEnvironmentContext(context, configs) {
2101
2098
  name,
2102
2099
  distPath: function(cwd, config) {
2103
2100
  var _config_output_distPath, _config_output;
2104
- return getAbsolutePath(cwd, (null === (_config_output = config.output) || void 0 === _config_output || null === (_config_output_distPath = _config_output.distPath) || void 0 === _config_output_distPath ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2101
+ return getAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2105
2102
  }(context.rootPath, config),
2106
2103
  entry,
2107
2104
  browserslist,
@@ -2118,7 +2115,7 @@ async function updateEnvironmentContext(context, configs) {
2118
2115
  async function createContext(options, userConfig) {
2119
2116
  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;
2120
2117
  return {
2121
- version: "1.3.6",
2118
+ version: "1.3.8",
2122
2119
  rootPath,
2123
2120
  distPath: '',
2124
2121
  cachePath,
@@ -2264,7 +2261,7 @@ async function modifyBundlerChain(context, utils) {
2264
2261
  utils
2265
2262
  ]
2266
2263
  });
2267
- if (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.bundlerChain) for (let item of castArray(utils.environment.config.tools.bundlerChain))await item(modifiedBundlerChain, utils);
2264
+ if (null == (_utils_environment_config_tools = utils.environment.config.tools) ? void 0 : _utils_environment_config_tools.bundlerChain) for (let item of castArray(utils.environment.config.tools.bundlerChain))await item(modifiedBundlerChain, utils);
2268
2265
  return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify bundler chain done'), modifiedBundlerChain;
2269
2266
  }
2270
2267
  let configChain_CHAIN_ID = {
@@ -2439,7 +2436,7 @@ let configChain_CHAIN_ID = {
2439
2436
  }
2440
2437
  }), isUseAnalyzer = (config)=>{
2441
2438
  var _config_performance;
2442
- return process.env.BUNDLE_ANALYZE || (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.bundleAnalyze);
2439
+ return process.env.BUNDLE_ANALYZE || (null == (_config_performance = config.performance) ? void 0 : _config_performance.bundleAnalyze);
2443
2440
  };
2444
2441
  async function validateWebpackCache(cacheDirectory, buildDependencies) {
2445
2442
  let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cacheDirectory, 'buildDependencies.json');
@@ -2469,7 +2466,7 @@ async function getBuildDependencies(context, config, environmentContext, userBui
2469
2466
  let { tsconfigPath } = environmentContext;
2470
2467
  tsconfigPath && (buildDependencies.tsconfig = [
2471
2468
  tsconfigPath
2472
- ]), (null === (_config__privateMeta = config._privateMeta) || void 0 === _config__privateMeta ? void 0 : _config__privateMeta.configFilePath) && (buildDependencies.rsbuildConfig = [
2469
+ ]), (null == (_config__privateMeta = config._privateMeta) ? void 0 : _config__privateMeta.configFilePath) && (buildDependencies.rsbuildConfig = [
2473
2470
  config._privateMeta.configFilePath
2474
2471
  ]), await isFileExists(browserslistConfig) && (buildDependencies.browserslistrc = [
2475
2472
  browserslistConfig
@@ -2551,7 +2548,7 @@ let pluginCache = ()=>({
2551
2548
  return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
2552
2549
  path: distPath,
2553
2550
  keep
2554
- } : void (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current dist path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(distPath)}`)) : !0 === enable ? {
2551
+ } : (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`), void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current dist path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(distPath)}`)) : !0 === enable ? {
2555
2552
  path: distPath,
2556
2553
  keep
2557
2554
  } : void 0;
@@ -2717,7 +2714,7 @@ async function loadUserPostcssrc(root, postcssrcCache) {
2717
2714
  if (cached) return clonePostCSSConfig(await cached);
2718
2715
  let { default: postcssrc } = await import("../compiled/postcss-load-config/index.js"), promise = postcssrc({}, root).catch((err)=>{
2719
2716
  var _err_message;
2720
- if (null === (_err_message = err.message) || void 0 === _err_message ? void 0 : _err_message.includes('No PostCSS Config found')) return {};
2717
+ if (null == (_err_message = err.message) ? void 0 : _err_message.includes('No PostCSS Config found')) return {};
2721
2718
  throw err;
2722
2719
  });
2723
2720
  return postcssrcCache.set(root, promise), promise.then((config)=>(postcssrcCache.set(root, config), clonePostCSSConfig(config)));
@@ -2815,7 +2812,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2815
2812
  root: api.context.rootPath,
2816
2813
  postcssrcCache
2817
2814
  });
2818
- if ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions || null === (_postcssLoaderOptions_postcssOptions_plugins = _postcssLoaderOptions_postcssOptions.plugins) || void 0 === _postcssLoaderOptions_postcssOptions_plugins ? void 0 : _postcssLoaderOptions_postcssOptions_plugins.length)) {
2815
+ if ('function' == typeof postcssLoaderOptions.postcssOptions || (null == (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || null == (_postcssLoaderOptions_postcssOptions_plugins = _postcssLoaderOptions_postcssOptions.plugins) ? void 0 : _postcssLoaderOptions_postcssOptions_plugins.length)) {
2819
2816
  importLoaders++;
2820
2817
  let postcssLoaderPath = getCompiledPath('postcss-loader');
2821
2818
  updateRules((rule)=>{
@@ -2879,10 +2876,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2879
2876
  let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
2880
2877
  pathKey && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`[rsbuild:config] The "source.define" option includes an object with the key ${JSON.stringify(pathKey)} under "process.env", indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`));
2881
2878
  };
2882
- if ('object' == typeof value) {
2883
- check(value);
2884
- return;
2885
- }
2879
+ if ('object' == typeof value) return check(value);
2886
2880
  if ('string' == typeof value) try {
2887
2881
  check(JSON.parse(value));
2888
2882
  } catch (error) {}
@@ -3071,7 +3065,7 @@ let VOID_TAGS = [
3071
3065
  ...override
3072
3066
  })), applyTagConfig = (data, tagConfig, compilationHash, entryName)=>{
3073
3067
  var _tagConfig_tags;
3074
- if (!(null === (_tagConfig_tags = tagConfig.tags) || void 0 === _tagConfig_tags ? void 0 : _tagConfig_tags.length)) return data;
3068
+ if (!(null == (_tagConfig_tags = tagConfig.tags) ? void 0 : _tagConfig_tags.length)) return data;
3075
3069
  let fromInjectTags = (tags)=>{
3076
3070
  let ret = [];
3077
3071
  for (let tag of tags){
@@ -3154,10 +3148,10 @@ class RsbuildHtmlPlugin {
3154
3148
  compiler.hooks.compilation.tap(this.name, (compilation)=>{
3155
3149
  getHTMLPlugin().getCompilationHooks(compilation).alterAssetTagGroups.tapPromise(this.name, async (data)=>{
3156
3150
  var _data_plugin_options, _data_plugin_options1;
3157
- let entryName = null === (_data_plugin_options = data.plugin.options) || void 0 === _data_plugin_options ? void 0 : _data_plugin_options.entryName;
3151
+ let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
3158
3152
  if (!entryName) return data;
3159
3153
  let { headTags, bodyTags } = data, { favicon, tagConfig, templateContent } = this.options[entryName];
3160
- hasTitle(templateContent) || addTitleTag(headTags, null === (_data_plugin_options1 = data.plugin.options) || void 0 === _data_plugin_options1 ? void 0 : _data_plugin_options1.title), favicon && await addFavicon(headTags, favicon, compilation, data.publicPath);
3154
+ hasTitle(templateContent) || addTitleTag(headTags, null == (_data_plugin_options1 = data.plugin.options) ? void 0 : _data_plugin_options1.title), favicon && await addFavicon(headTags, favicon, compilation, data.publicPath);
3161
3155
  let tags = {
3162
3156
  headTags: headTags.map(formatBasicTag),
3163
3157
  bodyTags: bodyTags.map(formatBasicTag)
@@ -3326,7 +3320,7 @@ let getTagConfig = (config)=>{
3326
3320
  let formattedCrossorigin = !0 === crossorigin ? 'anonymous' : crossorigin;
3327
3321
  for (let tag of allTags){
3328
3322
  var _tag_attrs, _tag_attrs1;
3329
- ("script" === tag.tag && (null === (_tag_attrs = tag.attrs) || void 0 === _tag_attrs ? void 0 : _tag_attrs.src) || 'link' === tag.tag && (null === (_tag_attrs1 = tag.attrs) || void 0 === _tag_attrs1 ? void 0 : _tag_attrs1.rel) === 'stylesheet') && (tag.attrs.crossorigin ??= formattedCrossorigin);
3323
+ ("script" === tag.tag && (null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.src) || 'link' === tag.tag && (null == (_tag_attrs1 = tag.attrs) ? void 0 : _tag_attrs1.rel) === 'stylesheet') && (tag.attrs.crossorigin ??= formattedCrossorigin);
3330
3324
  }
3331
3325
  }
3332
3326
  return {
@@ -3357,7 +3351,7 @@ let pluginInlineChunk = ()=>({
3357
3351
  let inlinedAssets = new Set(), getInlinedScriptTag = (publicPath, tag, compilation, scriptTests, config)=>{
3358
3352
  var _tag_attrs;
3359
3353
  let { assets } = compilation;
3360
- if (!((null === (_tag_attrs = tag.attrs) || void 0 === _tag_attrs ? void 0 : _tag_attrs.src) && 'string' == typeof tag.attrs.src)) return tag;
3354
+ if (!((null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.src) && 'string' == typeof tag.attrs.src)) return tag;
3361
3355
  let { src, ...otherAttrs } = tag.attrs, scriptName = publicPath ? src.replace(publicPath, '') : src, asset = assets[scriptName];
3362
3356
  if (null == asset) return tag;
3363
3357
  let source = asset.source().toString();
@@ -3379,7 +3373,7 @@ let pluginInlineChunk = ()=>({
3379
3373
  }, getInlinedCSSTag = (publicPath, tag, compilation, styleTests, config)=>{
3380
3374
  var _tag_attrs;
3381
3375
  let { assets } = compilation;
3382
- if (!((null === (_tag_attrs = tag.attrs) || void 0 === _tag_attrs ? void 0 : _tag_attrs.href) && 'string' == typeof tag.attrs.href)) return tag;
3376
+ if (!((null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.href) && 'string' == typeof tag.attrs.href)) return tag;
3383
3377
  let linkName = publicPath ? tag.attrs.href.replace(publicPath, '') : tag.attrs.href, asset = assets[linkName];
3384
3378
  if (null == asset) return tag;
3385
3379
  let source = asset.source().toString();
@@ -3458,7 +3452,7 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
3458
3452
  }
3459
3453
  let entryManifest = {};
3460
3454
  assets.size && (entryManifest.assets = Array.from(assets));
3461
- let htmlPath = null === (_files_find = files.find((f)=>f.name === htmlPaths[name])) || void 0 === _files_find ? void 0 : _files_find.path;
3455
+ let htmlPath = null == (_files_find = files.find((f)=>f.name === htmlPaths[name])) ? void 0 : _files_find.path;
3462
3456
  htmlPath && (entryManifest.html = [
3463
3457
  htmlPath
3464
3458
  ]), initialJS.length && (entryManifest.initial = {
@@ -3620,7 +3614,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3620
3614
  ];
3621
3615
  if (nonce) for (let tag of allTags){
3622
3616
  var _tag_attrs, _tag_attrs1;
3623
- ("script" === tag.tag || 'style' === tag.tag || 'link' === tag.tag && (null === (_tag_attrs = tag.attrs) || void 0 === _tag_attrs ? void 0 : _tag_attrs.rel) === 'preload' && (null === (_tag_attrs1 = tag.attrs) || void 0 === _tag_attrs1 ? void 0 : _tag_attrs1.as) === "script") && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
3617
+ ("script" === tag.tag || 'style' === tag.tag || 'link' === tag.tag && (null == (_tag_attrs = tag.attrs) ? void 0 : _tag_attrs.rel) === 'preload' && (null == (_tag_attrs1 = tag.attrs) ? void 0 : _tag_attrs1.as) === "script") && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
3624
3618
  }
3625
3619
  return {
3626
3620
  headTags,
@@ -3701,10 +3695,10 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3701
3695
  if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3702
3696
  return port;
3703
3697
  }, getServerConfig = async ({ config })=>{
3704
- let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
3698
+ let { host, port: originalPort, strictPort } = config.server, port = await getPort({
3705
3699
  host,
3706
3700
  port: originalPort,
3707
- strictPort: config.server.strictPort || !1
3701
+ strictPort
3708
3702
  }), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`using port ${port}.`)}` : void 0;
3709
3703
  return {
3710
3704
  port,
@@ -3856,14 +3850,15 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3856
3850
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3857
3851
  let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3858
3852
  var _context_devServer, _context_devServer1, _context_devServer2;
3859
- let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX, port = (null === (_context_devServer = context.devServer) || void 0 === _context_devServer ? void 0 : _context_devServer.port) || server.port || 3000;
3853
+ let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3860
3854
  if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3861
3855
  else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3862
3856
  else if (!0 === dev.assetPrefix) {
3863
- let protocol = (null === (_context_devServer1 = context.devServer) || void 0 === _context_devServer1 ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null === (_context_devServer2 = context.devServer) || void 0 === _context_devServer2 ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3857
+ let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3864
3858
  publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3865
3859
  }
3866
- return formatPublicPath(replacePortPlaceholder(publicPath, port));
3860
+ let defaultPort = server.port ?? 3000;
3861
+ return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3867
3862
  }({
3868
3863
  config,
3869
3864
  isProd,
@@ -3897,7 +3892,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3897
3892
  var _rsbuildConfig_performance, _config_performance;
3898
3893
  let applyBundleAnalyzeConfig = (config)=>{
3899
3894
  var _config_performance;
3900
- (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.bundleAnalyze) ? config.performance.bundleAnalyze = {
3895
+ (null == (_config_performance = config.performance) ? void 0 : _config_performance.bundleAnalyze) ? config.performance.bundleAnalyze = {
3901
3896
  generateStatsFile: !0,
3902
3897
  ...config.performance.bundleAnalyze || {}
3903
3898
  } : (config.performance ??= {}, config.performance.bundleAnalyze = {
@@ -3905,8 +3900,8 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3905
3900
  generateStatsFile: !0
3906
3901
  });
3907
3902
  };
3908
- if (null === (_rsbuildConfig_performance = rsbuildConfig.performance) || void 0 === _rsbuildConfig_performance ? void 0 : _rsbuildConfig_performance.profile) applyBundleAnalyzeConfig(rsbuildConfig);
3909
- else if (rsbuildConfig.environments) for (let config of Object.values(rsbuildConfig.environments))(null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.profile) && applyBundleAnalyzeConfig(config);
3903
+ if (null == (_rsbuildConfig_performance = rsbuildConfig.performance) ? void 0 : _rsbuildConfig_performance.profile) applyBundleAnalyzeConfig(rsbuildConfig);
3904
+ else if (rsbuildConfig.environments) for (let config of Object.values(rsbuildConfig.environments))(null == (_config_performance = config.performance) ? void 0 : _config_performance.profile) && applyBundleAnalyzeConfig(config);
3910
3905
  }
3911
3906
  }), api.modifyBundlerChain((chain, { environment })=>{
3912
3907
  let { config } = environment, { profile } = config.performance;
@@ -4026,10 +4021,10 @@ class HtmlPreloadOrPrefetchPlugin {
4026
4021
  if ('all-assets' === includeType) {
4027
4022
  var _compilation_assetsInfo;
4028
4023
  let licenseAssets = [
4029
- ...(null === (_compilation_assetsInfo = compilation.assetsInfo) || void 0 === _compilation_assetsInfo ? void 0 : _compilation_assetsInfo.values()) || []
4024
+ ...(null == (_compilation_assetsInfo = compilation.assetsInfo) ? void 0 : _compilation_assetsInfo.values()) || []
4030
4025
  ].map((info)=>{
4031
4026
  var _info_related;
4032
- return null !== (_info_related = info.related) && void 0 !== _info_related && !!_info_related.license && info.related.license;
4027
+ return null != (_info_related = info.related) && !!_info_related.license && info.related.license;
4033
4028
  }).filter(Boolean);
4034
4029
  return [
4035
4030
  {
@@ -4084,14 +4079,11 @@ class HtmlPreloadOrPrefetchPlugin {
4084
4079
  }
4085
4080
  return links;
4086
4081
  }(this.options, this.type, compilation, htmlPluginData, this.HTMLCount), htmlPluginData)), getHTMLPlugin().getHooks(compilation).alterAssetTags.tap(`HTML${upperFirst(this.type)}Plugin`, (htmlPluginData)=>{
4087
- if (this.resourceHints) {
4088
- var resourceHints, scripts;
4089
- htmlPluginData.assetTags.styles = [
4090
- ...this.options.dedupe ? (resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))) : this.resourceHints,
4091
- ...htmlPluginData.assetTags.styles
4092
- ];
4093
- }
4094
- return htmlPluginData;
4082
+ var resourceHints, scripts;
4083
+ return this.resourceHints && (htmlPluginData.assetTags.styles = [
4084
+ ...this.options.dedupe ? (resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))) : this.resourceHints,
4085
+ ...htmlPluginData.assetTags.styles
4086
+ ]), htmlPluginData;
4095
4087
  });
4096
4088
  });
4097
4089
  }
@@ -4152,11 +4144,11 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4152
4144
  if ('true' !== process.env.RSDOCTOR) return;
4153
4145
  let isRspack = 'rspack' === api.context.bundlerType, pluginName = isRspack ? 'RsdoctorRspackPlugin' : 'RsdoctorWebpackPlugin', isRsdoctorPlugin = (plugin)=>{
4154
4146
  var _plugin_constructor;
4155
- return (null == plugin ? void 0 : plugin.isRsdoctorPlugin) === !0 || (null == plugin || null === (_plugin_constructor = plugin.constructor) || void 0 === _plugin_constructor ? void 0 : _plugin_constructor.name) === pluginName;
4147
+ return (null == plugin ? void 0 : plugin.isRsdoctorPlugin) === !0 || (null == plugin || null == (_plugin_constructor = plugin.constructor) ? void 0 : _plugin_constructor.name) === pluginName;
4156
4148
  };
4157
4149
  for (let config of bundlerConfigs){
4158
4150
  var _config_plugins;
4159
- if (null === (_config_plugins = config.plugins) || void 0 === _config_plugins ? void 0 : _config_plugins.some((plugin)=>isRsdoctorPlugin(plugin))) return;
4151
+ if (null == (_config_plugins = config.plugins) ? void 0 : _config_plugins.some((plugin)=>isRsdoctorPlugin(plugin))) return;
4160
4152
  }
4161
4153
  let packageName = isRspack ? '@rsdoctor/rspack-plugin' : '@rsdoctor/webpack-plugin';
4162
4154
  try {
@@ -4184,10 +4176,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4184
4176
  }
4185
4177
  }), stopProfiler = (output, profileSession)=>{
4186
4178
  profileSession && profileSession.post('Profiler.stop', (error, param)=>{
4187
- if (error) {
4188
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to generate JavaScript CPU profile:', error);
4189
- return;
4190
- }
4179
+ if (error) return void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to generate JavaScript CPU profile:', error);
4191
4180
  __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.writeFileSync(output, JSON.stringify(param.profile));
4192
4181
  });
4193
4182
  }, pluginRspackProfile = ()=>({
@@ -4196,7 +4185,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4196
4185
  var _process_env_RSPACK_PROFILE;
4197
4186
  let profileSession;
4198
4187
  if ('webpack' === api.context.bundlerType) return;
4199
- let RSPACK_PROFILE = null === (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) || void 0 === _process_env_RSPACK_PROFILE ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
4188
+ let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
4200
4189
  if (!RSPACK_PROFILE) return;
4201
4190
  let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), enableLogging = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('LOGGING'), onStart = async ()=>{
4202
4191
  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');
@@ -4230,7 +4219,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4230
4219
  if (config.server.open) {
4231
4220
  var _api_context_devServer;
4232
4221
  open_open({
4233
- https: null === (_api_context_devServer = api.context.devServer) || void 0 === _api_context_devServer ? void 0 : _api_context_devServer.https,
4222
+ https: null == (_api_context_devServer = api.context.devServer) ? void 0 : _api_context_devServer.https,
4234
4223
  port,
4235
4224
  routes,
4236
4225
  config
@@ -4369,7 +4358,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4369
4358
  return;
4370
4359
  }
4371
4360
  let { config } = environment, defaultConfig = {
4372
- chunks: (null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation || null === (_config_moduleFederation_options = _config_moduleFederation.options) || void 0 === _config_moduleFederation_options ? void 0 : _config_moduleFederation_options.exposes) ? 'async' : 'all',
4361
+ chunks: (null == (_config_moduleFederation = config.moduleFederation) || null == (_config_moduleFederation_options = _config_moduleFederation.options) ? void 0 : _config_moduleFederation_options.exposes) ? 'async' : 'all',
4373
4362
  cacheGroups: {}
4374
4363
  };
4375
4364
  'webpack' === api.context.bundlerType && (defaultConfig.enforceSizeThreshold = 50000);
@@ -4531,21 +4520,15 @@ let reduceTransformImportConfig = (options)=>{
4531
4520
  api.modifyBundlerChain({
4532
4521
  order: 'pre',
4533
4522
  handler: async (chain, { target, environment })=>{
4534
- if ('node' === target) {
4535
- chain.target('node');
4536
- return;
4537
- }
4523
+ if ('node' === target) return void chain.target('node');
4538
4524
  let { browserslist } = environment, isDefaultBrowserslist = browserslist.join(',') === DEFAULT_WEB_BROWSERSLIST.join(',');
4539
- if ('web-worker' === target) {
4540
- chain.target(isDefaultBrowserslist ? [
4541
- 'webworker',
4542
- 'es2017'
4543
- ] : [
4544
- 'webworker',
4545
- 'es5'
4546
- ]);
4547
- return;
4548
- }
4525
+ if ('web-worker' === target) return void chain.target(isDefaultBrowserslist ? [
4526
+ 'webworker',
4527
+ 'es2017'
4528
+ ] : [
4529
+ 'webworker',
4530
+ 'es5'
4531
+ ]);
4549
4532
  let esQuery = isDefaultBrowserslist ? 'es2017' : `browserslist:${browserslist.join(',')}`;
4550
4533
  chain.target([
4551
4534
  'web',
@@ -4617,7 +4600,7 @@ async function modifyRspackConfig(context, rspackConfig, chainUtils) {
4617
4600
  rspackConfig,
4618
4601
  utils
4619
4602
  ]
4620
- }), (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.rspack) && (currentConfig = await reduceConfigsAsyncWithContext({
4603
+ }), (null == (_utils_environment_config_tools = utils.environment.config.tools) ? void 0 : _utils_environment_config_tools.rspack) && (currentConfig = await reduceConfigsAsyncWithContext({
4621
4604
  initial: currentConfig,
4622
4605
  config: utils.environment.config.tools.rspack,
4623
4606
  ctx: utils,
@@ -4768,7 +4751,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4768
4751
  getPluginAPI: context.getPluginAPI,
4769
4752
  pluginManager
4770
4753
  }), await modifyRsbuildConfig(context);
4771
- let normalizeBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizeBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizeBaseConfig;
4754
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4772
4755
  for (let [name, config] of Object.entries(mergedEnvironments)){
4773
4756
  let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4774
4757
  environments[name] = {
@@ -4781,7 +4764,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4781
4764
  };
4782
4765
  }
4783
4766
  context.normalizedConfig = {
4784
- ...normalizeBaseConfig,
4767
+ ...normalizedBaseConfig,
4785
4768
  environments
4786
4769
  }, await updateEnvironmentContext(context, environments);
4787
4770
  let distPaths = Object.values(context.environments).map((item)=>item.distPath);
@@ -4837,7 +4820,7 @@ let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODU
4837
4820
  envMode: commonOpts.envMode,
4838
4821
  loader: commonOpts.configLoader
4839
4822
  });
4840
- return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server.open = commonOpts.open), commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
4823
+ return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null == (_config_server = config.server) ? void 0 : _config_server.open) || (config.server.open = commonOpts.open), commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
4841
4824
  ...config.dev.watchFiles ? castArray(config.dev.watchFiles) : [],
4842
4825
  {
4843
4826
  paths: filePath,
@@ -4861,7 +4844,7 @@ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
4861
4844
  var _config_dev;
4862
4845
  if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
4863
4846
  let files = [], config = rsbuild.getNormalizedConfig();
4864
- if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
4847
+ if (null == (_config_dev = config.dev) ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
4865
4848
  if ('reload-server' !== watchFilesConfig.type) continue;
4866
4849
  let paths = castArray(watchFilesConfig.paths);
4867
4850
  watchFilesConfig.options ? watchFilesForRestart({
@@ -5040,10 +5023,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5040
5023
  for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
5041
5024
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(message);
5042
5025
  }
5043
- for (let shortcut of shortcuts)if (input === shortcut.key) {
5044
- shortcut.action();
5045
- return;
5046
- }
5026
+ for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
5047
5027
  }), ()=>{
5048
5028
  rl.close();
5049
5029
  };
@@ -5166,7 +5146,7 @@ class SocketServer {
5166
5146
  let { default: ws } = await import("../compiled/ws/index.js");
5167
5147
  this.wsServer = new ws.Server({
5168
5148
  noServer: !0,
5169
- path: null === (_this_options_client = this.options.client) || void 0 === _this_options_client ? void 0 : _this_options_client.path
5149
+ path: null == (_this_options_client = this.options.client) ? void 0 : _this_options_client.path
5170
5150
  }), this.wsServer.on('error', (err)=>{
5171
5151
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
5172
5152
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
@@ -5491,17 +5471,14 @@ class CompilationManager {
5491
5471
  let { devConfig, serverConfig, publicPaths } = this, clientPaths = function(devConfig) {
5492
5472
  var _devConfig_client;
5493
5473
  let clientPaths = [];
5494
- return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilationManager_require.resolve('@rsbuild/core/client/hmr')), (null === (_devConfig_client = devConfig.client) || void 0 === _devConfig_client ? void 0 : _devConfig_client.overlay) && clientPaths.push(`${compilationManager_require.resolve('@rsbuild/core/client/overlay')}`)), clientPaths;
5474
+ return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilationManager_require.resolve('@rsbuild/core/client/hmr')), (null == (_devConfig_client = devConfig.client) ? void 0 : _devConfig_client.overlay) && clientPaths.push(`${compilationManager_require.resolve('@rsbuild/core/client/overlay')}`)), clientPaths;
5495
5475
  }(devConfig), middleware = await getCompilationMiddleware(this.compiler, {
5496
5476
  callbacks: {
5497
5477
  onInvalid: (compilationId, fileName)=>{
5498
- if ('string' == typeof fileName && HTML_REGEX.test(fileName)) {
5499
- this.socketServer.sockWrite({
5500
- type: 'static-changed',
5501
- compilationId
5502
- });
5503
- return;
5504
- }
5478
+ if ('string' == typeof fileName && HTML_REGEX.test(fileName)) return void this.socketServer.sockWrite({
5479
+ type: 'static-changed',
5480
+ compilationId
5481
+ });
5505
5482
  this.socketServer.sockWrite({
5506
5483
  type: 'invalid',
5507
5484
  compilationId
@@ -5534,10 +5511,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5534
5511
  return void 0 === size || Number(size) > 1024;
5535
5512
  }, gzipMiddleware = ({ level = __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__.default.constants.Z_BEST_SPEED } = {})=>(req, res, next)=>{
5536
5513
  let gzip, writeHeadStatus, accept = req.headers['accept-encoding'], encoding = 'string' == typeof accept && ENCODING_REGEX.test(accept);
5537
- if ('HEAD' === req.method || !encoding) {
5538
- next();
5539
- return;
5540
- }
5514
+ if ('HEAD' === req.method || !encoding) return void next();
5541
5515
  let started = !1, { end, write, on, writeHead } = res, listeners = [], start = ()=>{
5542
5516
  if (!started) {
5543
5517
  if (started = !0, shouldCompress(res)) for (let listener of (res.setHeader('Content-Encoding', 'gzip'), res.removeHeader('Content-Length'), (gzip = __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__.default.createGzip({
@@ -5609,7 +5583,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5609
5583
  }), res.end();
5610
5584
  return;
5611
5585
  }
5612
- if (null === (_req_headers_accept = req.headers.accept) || void 0 === _req_headers_accept ? void 0 : _req_headers_accept.includes('text/html')) {
5586
+ if (null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('text/html')) {
5613
5587
  res.writeHead(404, {
5614
5588
  'Content-Type': 'text/html'
5615
5589
  }), res.end(`The server is configured with a base URL of ${base} - did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
@@ -5743,7 +5717,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5743
5717
  next();
5744
5718
  }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5745
5719
  let { compiler } = compilationManager;
5746
- middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5720
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5747
5721
  }
5748
5722
  if (server.proxy) {
5749
5723
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
@@ -5760,7 +5734,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5760
5734
  environments
5761
5735
  })), compilationManager && (middlewares.push(compilationManager.middleware), upgradeEvents.push(compilationManager.socketServer.upgrade), middlewares.push((req, res, next)=>{
5762
5736
  var _req_url;
5763
- (null === (_req_url = req.url) || void 0 === _req_url ? void 0 : _req_url.endsWith('.hot-update.json')) && 'OPTIONS' !== req.method ? (res.statusCode = 404, res.end()) : next();
5737
+ (null == (_req_url = req.url) ? void 0 : _req_url.endsWith('.hot-update.json')) && 'OPTIONS' !== req.method ? (res.statusCode = 404, res.end()) : next();
5764
5738
  })), compilationManager && middlewares.push(getHtmlCompletionMiddleware({
5765
5739
  compilationManager,
5766
5740
  distPath: context.distPath
@@ -5945,7 +5919,7 @@ class EsmRunner extends CommonJsRunner {
5945
5919
  createRunner() {
5946
5920
  var _this__options_compilerOptions_experiments;
5947
5921
  super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
5948
- let outputModule = null === (_this__options_compilerOptions_experiments = this._options.compilerOptions.experiments) || void 0 === _this__options_compilerOptions_experiments ? void 0 : _this__options_compilerOptions_experiments.outputModule;
5922
+ let outputModule = null == (_this__options_compilerOptions_experiments = this._options.compilerOptions.experiments) ? void 0 : _this__options_compilerOptions_experiments.outputModule;
5949
5923
  this.requirers.set('entry', (currentDirectory, modulePath, context)=>{
5950
5924
  let file = this.getFile(modulePath, currentDirectory);
5951
5925
  return file ? outputModule && !file.path.endsWith('.cjs') ? this.requirers.get('esm')(currentDirectory, modulePath, {
@@ -6019,7 +5993,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6019
5993
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6020
5994
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6021
5995
  var _chunk_names;
6022
- return chunk.entry && (null === (_chunk_names = chunk.names) || void 0 === _chunk_names ? void 0 : _chunk_names.includes(String(entryChunkName)));
5996
+ return chunk.entry && (null == (_chunk_names = chunk.names) ? void 0 : _chunk_names.includes(String(entryChunkName)));
6023
5997
  });
6024
5998
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6025
5999
  }, []);
@@ -6303,7 +6277,7 @@ async function createCompiler_createCompiler(options) {
6303
6277
  }, hasErrors = stats.hasErrors();
6304
6278
  if (!hasErrors) {
6305
6279
  var _statsJson_children;
6306
- isMultiCompiler && (null === (_statsJson_children = statsJson.children) || void 0 === _statsJson_children ? void 0 : _statsJson_children.length) ? statsJson.children.forEach((c, index)=>{
6280
+ isMultiCompiler && (null == (_statsJson_children = statsJson.children) ? void 0 : _statsJson_children.length) ? statsJson.children.forEach((c, index)=>{
6307
6281
  printTime(c, index);
6308
6282
  }) : printTime(statsJson, 0);
6309
6283
  }
@@ -6613,11 +6587,11 @@ async function applyDefaultPlugins(pluginManager, context) {
6613
6587
  let { moduleFederation } = config;
6614
6588
  if (api.isPluginExists('rsbuild:module-federation-enhanced') && (config.server ||= {}, config.server.cors = !0), (null == moduleFederation ? void 0 : moduleFederation.options) && moduleFederation.options.exposes) {
6615
6589
  var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
6616
- config.dev ||= {}, config.server ||= {}, config.server.cors = !0, (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.port) && !(null === (_config_dev_client = config.dev.client) || void 0 === _config_dev_client ? void 0 : _config_dev_client.port) && (config.dev.client ||= {}, config.dev.client.port = config.server.port), (null === (_originalConfig_dev = api.getRsbuildConfig('original').dev) || void 0 === _originalConfig_dev ? void 0 : _originalConfig_dev.assetPrefix) === void 0 && config.dev.assetPrefix === (null === (_config_server1 = config.server) || void 0 === _config_server1 ? void 0 : _config_server1.base) && (config.dev.assetPrefix = !0);
6590
+ config.dev ||= {}, config.server ||= {}, config.server.cors = !0, (null == (_config_server = config.server) ? void 0 : _config_server.port) && !(null == (_config_dev_client = config.dev.client) ? void 0 : _config_dev_client.port) && (config.dev.client ||= {}, config.dev.client.port = config.server.port), (null == (_originalConfig_dev = api.getRsbuildConfig('original').dev) ? void 0 : _originalConfig_dev.assetPrefix) === void 0 && config.dev.assetPrefix === (null == (_config_server1 = config.server) ? void 0 : _config_server1.base) && (config.dev.assetPrefix = !0);
6617
6591
  }
6618
6592
  }), api.modifyEnvironmentConfig((config)=>{
6619
6593
  var _config_moduleFederation, _config_performance_chunkSplit, _config_performance;
6620
- (null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation ? void 0 : _config_moduleFederation.options) && ((null === (_config_performance = config.performance) || void 0 === _config_performance || null === (_config_performance_chunkSplit = _config_performance.chunkSplit) || void 0 === _config_performance_chunkSplit ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience' && (config.performance.chunkSplit = {
6594
+ (null == (_config_moduleFederation = config.moduleFederation) ? void 0 : _config_moduleFederation.options) && ((null == (_config_performance = config.performance) || null == (_config_performance_chunkSplit = _config_performance.chunkSplit) ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience' && (config.performance.chunkSplit = {
6621
6595
  ...config.performance.chunkSplit,
6622
6596
  strategy: 'custom'
6623
6597
  }), config.source.include = [
@@ -6627,7 +6601,7 @@ async function applyDefaultPlugins(pluginManager, context) {
6627
6601
  }), api.modifyBundlerChain(async (chain, { CHAIN_ID, target, environment })=>{
6628
6602
  var _config_moduleFederation;
6629
6603
  let { config } = environment;
6630
- if (!(null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation ? void 0 : _config_moduleFederation.options) || 'web' !== target) return;
6604
+ if (!(null == (_config_moduleFederation = config.moduleFederation) ? void 0 : _config_moduleFederation.options) || 'web' !== target) return;
6631
6605
  let { options } = config.moduleFederation;
6632
6606
  chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.container.ModuleFederationPlugin, [
6633
6607
  options
@@ -6657,7 +6631,7 @@ async function createRsbuild(options = {}) {
6657
6631
  paths: envs1.filePaths,
6658
6632
  type: 'reload-server'
6659
6633
  }
6660
- ], null === (_config_performance = config1.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache))) {
6634
+ ], null == (_config_performance = config1.performance) ? void 0 : _config_performance.buildCache))) {
6661
6635
  let { buildCache } = config1.performance;
6662
6636
  !0 === buildCache ? config1.performance.buildCache = {
6663
6637
  buildDependencies: envs1.filePaths
@@ -7316,11 +7290,11 @@ async function runCLI() {
7316
7290
  }
7317
7291
  process.title = 'rsbuild-node';
7318
7292
  let { npm_execpath } = process.env;
7319
- (!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.6\n`);
7293
+ (!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.8\n`);
7320
7294
  try {
7321
7295
  !function() {
7322
7296
  let cli = cac_dist('rsbuild');
7323
- cli.help(), cli.version("1.3.6"), applyCommonOptions(cli);
7297
+ cli.help(), cli.version("1.3.8"), applyCommonOptions(cli);
7324
7298
  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');
7325
7299
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7326
7300
  try {
@@ -7371,6 +7345,6 @@ async function runCLI() {
7371
7345
  __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);
7372
7346
  }
7373
7347
  }
7374
- let src_version = "1.3.6";
7348
+ let src_version = "1.3.8";
7375
7349
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7376
7350
  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 };