@rsbuild/core 2.0.3 → 2.0.4

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.
@@ -1,16 +1,16 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 715: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- const loader = __nccwpck_require__(709);
4
+ 346: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ const loader = __nccwpck_require__(480);
6
6
  module.exports = loader.default;
7
7
  },
8
- 709: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
+ 480: (__unused_webpack_module, exports, __nccwpck_require__) => {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports["default"] = void 0;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(928));
12
- var _utils = __nccwpck_require__(736);
13
- var _options = _interopRequireDefault(__nccwpck_require__(119));
12
+ var _utils = __nccwpck_require__(521);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(726));
14
14
  function _interopRequireDefault(obj) {
15
15
  return obj && obj.__esModule ? obj : { default: obj };
16
16
  }
@@ -95,7 +95,7 @@
95
95
  };
96
96
  var _default = (exports["default"] = loader);
97
97
  },
98
- 962: (module) => {
98
+ 347: (module) => {
99
99
  function isEqualLocals(a, b, isNamedExport) {
100
100
  if ((!a && b) || (a && !b)) {
101
101
  return false;
@@ -121,7 +121,7 @@
121
121
  }
122
122
  module.exports = isEqualLocals;
123
123
  },
124
- 736: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
+ 521: (__unused_webpack_module, exports, __nccwpck_require__) => {
125
125
  Object.defineProperty(exports, "__esModule", { value: true });
126
126
  exports.getExportLazyStyleCode = getExportLazyStyleCode;
127
127
  exports.getExportStyleCode = getExportStyleCode;
@@ -142,7 +142,7 @@
142
142
  exports.getdomAPI = getdomAPI;
143
143
  exports.stringifyRequest = stringifyRequest;
144
144
  var _path = _interopRequireDefault(__nccwpck_require__(928));
145
- var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(962));
145
+ var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(347));
146
146
  function _interopRequireDefault(obj) {
147
147
  return obj && obj.__esModule ? obj : { default: obj };
148
148
  }
@@ -337,7 +337,7 @@
337
337
  928: (module) => {
338
338
  module.exports = require("path");
339
339
  },
340
- 119: (module) => {
340
+ 726: (module) => {
341
341
  module.exports = JSON.parse(
342
342
  '{"title":"Style Loader options","type":"object","properties":{"injectType":{"description":"Allows to setup how styles will be injected into DOM.","link":"https://github.com/webpack-contrib/style-loader#injecttype","enum":["styleTag","singletonStyleTag","autoStyleTag","lazyStyleTag","lazySingletonStyleTag","lazyAutoStyleTag","linkTag"]},"attributes":{"description":"Adds custom attributes to tag.","link":"https://github.com/webpack-contrib/style-loader#attributes","type":"object"},"insert":{"description":"Inserts `<style>`/`<link>` at the given position.","link":"https://github.com/webpack-contrib/style-loader#insert","type":"string"},"base":{"description":"Sets module ID base for DLLPlugin.","link":"https://github.com/webpack-contrib/style-loader#base","type":"number"},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"styleTagTransform":{"description":"Transform tag and css when insert \'style\' tag into the DOM","link":"https://github.com/webpack-contrib/style-loader#styleTagTransform","type":"string"}},"additionalProperties":false}',
343
343
  );
@@ -365,6 +365,6 @@
365
365
  }
366
366
  if (typeof __nccwpck_require__ !== "undefined")
367
367
  __nccwpck_require__.ab = __dirname + "/";
368
- var __webpack_exports__ = __nccwpck_require__(715);
368
+ var __webpack_exports__ = __nccwpck_require__(346);
369
369
  module.exports = __webpack_exports__;
370
370
  })();
package/dist/753.js CHANGED
@@ -384,8 +384,8 @@ __webpack_require__.add({
384
384
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
385
385
  }
386
386
  },
387
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
388
- let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
387
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
388
+ let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/req.js");
389
389
  async function processResult(ctx, result) {
390
390
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
391
391
  default: obj
@@ -458,8 +458,8 @@ __webpack_require__.add({
458
458
  });
459
459
  };
460
460
  },
461
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
462
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
461
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
462
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/req.js");
463
463
  module.exports = async function options(config, file) {
464
464
  if (config.parser && 'string' == typeof config.parser) try {
465
465
  config.parser = await req(config.parser, file);
@@ -479,8 +479,8 @@ __webpack_require__.add({
479
479
  return config;
480
480
  };
481
481
  },
482
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
483
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
482
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
483
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/req.js");
484
484
  async function load(plugin, options, file) {
485
485
  try {
486
486
  if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
@@ -496,7 +496,7 @@ __webpack_require__.add({
496
496
  }), list;
497
497
  };
498
498
  },
499
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
499
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
500
500
  let tsx, jiti;
501
501
  var __filename = __rspack_fileURLToPath(import.meta.url);
502
502
  let { createRequire } = __webpack_require__("node:module?1bcb"), { pathToFileURL } = __webpack_require__("node:url?b4ec"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
@@ -1211,7 +1211,7 @@ let isDeno = "u" > typeof Deno, isWindows = 'win32' === process.platform, ROOT_D
1211
1211
  node: [
1212
1212
  'node >= 20'
1213
1213
  ]
1214
- }, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /[?&]raw(?:&|=|$)/, INLINE_QUERY_REGEX = /[?&]inline(?:&|=|$)/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
1214
+ }, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /[?&]raw(?:&|=|$)/, INLINE_QUERY_REGEX = /[?&]inline(?:&|=|$)/, URL_QUERY_REGEX = /[?&]url(?:&|=|$)/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
1215
1215
  'woff',
1216
1216
  'woff2',
1217
1217
  'eot',
@@ -2271,7 +2271,7 @@ class RspackChain extends ChainedMap {
2271
2271
  ]);
2272
2272
  }
2273
2273
  }
2274
- let vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), cjs_0 = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
2274
+ let vendors_require = createRequire(import.meta.url), cjs_0 = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
2275
2275
  var cjs_0_default = __webpack_require__.n(cjs_0);
2276
2276
  let setNodeEnv = (env)=>{
2277
2277
  process.env.NODE_ENV = env;
@@ -2279,14 +2279,23 @@ let setNodeEnv = (env)=>{
2279
2279
  arr
2280
2280
  ], cloneDeep = (value)=>null == value ? value : cjs_0_default()({}, value, {
2281
2281
  isMergeableObject: isPlainObject
2282
- });
2282
+ }), DEFAULT_FILENAME_HASH = 'contenthash:10';
2283
2283
  function getFilename(config, type, isProd, isServer) {
2284
- let { filename, filenameHash } = config.output, defaultHash = '[contenthash:10]', getHash = ()=>'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? `.${defaultHash}` : '';
2284
+ let { filename, filenameHash } = config.output, hashConfig = 'boolean' == typeof filenameHash ? {
2285
+ enable: filenameHash,
2286
+ format: DEFAULT_FILENAME_HASH
2287
+ } : 'string' == typeof filenameHash ? {
2288
+ enable: !!filenameHash,
2289
+ format: filenameHash || DEFAULT_FILENAME_HASH
2290
+ } : {
2291
+ enable: filenameHash.enable ?? !0,
2292
+ format: filenameHash.format ?? DEFAULT_FILENAME_HASH
2293
+ }, hashTemplate = `[${hashConfig.format}]`, getHash = ()=>!1 !== hashConfig.enable ? `.${hashTemplate}` : '', getJsCssHash = (flag)=>'always' === hashConfig.enable || !0 === hashConfig.enable && flag ? `.${hashTemplate}` : '';
2285
2294
  switch(type){
2286
2295
  case 'js':
2287
- return filename.js ?? `[name]${isProd && !isServer ? getHash() : ''}.js`;
2296
+ return filename.js ?? `[name]${getJsCssHash(isProd && !isServer)}.js`;
2288
2297
  case 'css':
2289
- return filename.css ?? `[name]${isProd ? getHash() : ''}.css`;
2298
+ return filename.css ?? `[name]${getJsCssHash(isProd)}.css`;
2290
2299
  case 'svg':
2291
2300
  return filename.svg ?? `[name]${getHash()}.svg`;
2292
2301
  case 'font':
@@ -2298,10 +2307,7 @@ function getFilename(config, type, isProd, isServer) {
2298
2307
  case 'assets':
2299
2308
  return filename.assets ?? `[name]${getHash()}[ext]`;
2300
2309
  case 'wasm':
2301
- {
2302
- let hash = 'string' == typeof filenameHash ? `[${filenameHash}]` : defaultHash;
2303
- return filename.wasm ?? `${hash}.module.wasm`;
2304
- }
2310
+ return filename.wasm ?? `${hashTemplate}.module.wasm`;
2305
2311
  case 'html':
2306
2312
  if (filename.html) return filename.html;
2307
2313
  return 'flat' === config.html.outputStructure ? '[name].html' : '[name]/index.html';
@@ -2822,17 +2828,24 @@ let OVERRIDE_PATHS = new Set([
2822
2828
  'output.inlineScripts',
2823
2829
  'output.inlineStyles',
2824
2830
  'output.cssModules.auto',
2831
+ 'output.manifest.filter',
2832
+ 'output.manifest.generate',
2825
2833
  'output.overrideBrowserslist',
2834
+ 'performance.printFileSize.exclude',
2835
+ 'performance.printFileSize.include',
2836
+ 'performance.printFileSize.total',
2826
2837
  'server.open',
2838
+ 'server.compress.filter',
2827
2839
  'server.printUrls',
2828
2840
  'resolve.extensions',
2829
2841
  'resolve.conditionNames',
2830
2842
  'resolve.mainFields',
2831
2843
  'dev.writeToDisk',
2832
2844
  'dev.client.overlay.errors',
2845
+ 'dev.client.overlay.runtime',
2833
2846
  'provider',
2834
2847
  'customLogger'
2835
- ]), mergeConfig_merge = (x, y, path = '')=>{
2848
+ ]), merge = (x, y, path = '')=>{
2836
2849
  if (((key)=>{
2837
2850
  if (key.startsWith('environments.')) {
2838
2851
  let realKey = key.split('.').slice(2).join('.');
@@ -2865,7 +2878,7 @@ let OVERRIDE_PATHS = new Set([
2865
2878
  ...Object.keys(y)
2866
2879
  ])){
2867
2880
  let childPath = path ? `${path}.${key}` : key;
2868
- merged[key] = mergeConfig_merge(x[key], y[key], childPath);
2881
+ merged[key] = merge(x[key], y[key], childPath);
2869
2882
  }
2870
2883
  return merged;
2871
2884
  }, normalizeConfigStructure = (config)=>{
@@ -2885,7 +2898,7 @@ let OVERRIDE_PATHS = new Set([
2885
2898
  ]), normalizedConfig.dev = dev), normalizedConfig;
2886
2899
  }, mergeRsbuildConfig = (...originalConfigs)=>{
2887
2900
  let configs = originalConfigs.filter((config)=>void 0 !== config).map(normalizeConfigStructure);
2888
- 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), {});
2901
+ return 2 === configs.length ? merge(configs[0], configs[1]) : 1 === configs.length ? configs[0] : 0 === configs.length ? {} : configs.reduce((result, config)=>merge(result, config), {});
2889
2902
  }, defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
2890
2903
  dev: {
2891
2904
  hmr: !0,
@@ -3468,7 +3481,7 @@ function createPublicContext(context) {
3468
3481
  async function createContext(options, userConfig, logger) {
3469
3482
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3470
3483
  return {
3471
- version: "2.0.3",
3484
+ version: "2.0.4",
3472
3485
  rootPath,
3473
3486
  distPath: '',
3474
3487
  cachePath,
@@ -3625,6 +3638,84 @@ function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assi
3625
3638
  mergeFn
3626
3639
  }), initial) : config ?? initial;
3627
3640
  }
3641
+ function mergeTo(a, b, customizer) {
3642
+ let ret = {};
3643
+ return Object.keys(a).concat(Object.keys(b)).forEach((k)=>{
3644
+ let v = customizer(a[k], b[k], k);
3645
+ ret[k] = void 0 === v ? a[k] : v;
3646
+ }), ret;
3647
+ }
3648
+ let merge_with = function mergeWith(objects, customizer) {
3649
+ let [first, ...rest] = objects, ret = first;
3650
+ return rest.forEach((a)=>{
3651
+ ret = mergeTo(ret, a, customizer);
3652
+ }), ret;
3653
+ };
3654
+ function isRegex(o) {
3655
+ return o instanceof RegExp;
3656
+ }
3657
+ function rspack_merge_dist_isPlainObject(value) {
3658
+ if ('[object Object]' !== Object.prototype.toString.call(value)) return !1;
3659
+ let proto = Object.getPrototypeOf(value);
3660
+ if (null === proto) return !0;
3661
+ let baseProto = proto;
3662
+ for(; null !== Object.getPrototypeOf(baseProto);)baseProto = Object.getPrototypeOf(baseProto);
3663
+ return proto === baseProto;
3664
+ }
3665
+ function isUndefined(value) {
3666
+ return void 0 === value;
3667
+ }
3668
+ function isPromiseLike(value) {
3669
+ return null !== value && ('object' == typeof value || 'function' == typeof value) && 'function' == typeof value.then;
3670
+ }
3671
+ let isArray = Array.isArray;
3672
+ function joinArrays({ customizeArray, customizeObject, key } = {}) {
3673
+ return function _joinArrays(a, b, k) {
3674
+ let newKey = key ? `${key}.${k}` : k;
3675
+ return 'function' == typeof a && 'function' == typeof b ? (...args)=>_joinArrays(a(...args), b(...args), k) : isArray(a) && isArray(b) ? customizeArray && customizeArray(a, b, newKey) || [
3676
+ ...a,
3677
+ ...b
3678
+ ] : isRegex(b) ? b : rspack_merge_dist_isPlainObject(a) && rspack_merge_dist_isPlainObject(b) ? customizeObject && customizeObject(a, b, newKey) || merge_with([
3679
+ a,
3680
+ b
3681
+ ], joinArrays({
3682
+ customizeArray,
3683
+ customizeObject,
3684
+ key: newKey
3685
+ })) : rspack_merge_dist_isPlainObject(b) ? merge_with([
3686
+ {},
3687
+ b
3688
+ ], joinArrays({
3689
+ customizeArray,
3690
+ customizeObject,
3691
+ key: newKey
3692
+ })) : isArray(b) ? [
3693
+ ...b
3694
+ ] : b;
3695
+ };
3696
+ }
3697
+ function dist_merge(firstConfiguration, ...configurations) {
3698
+ return mergeWithCustomize({})(firstConfiguration, ...configurations);
3699
+ }
3700
+ function mergeWithCustomize(options) {
3701
+ return function(firstConfiguration, ...configurations) {
3702
+ if (isUndefined(firstConfiguration) || configurations.some(isUndefined)) throw TypeError('Merging undefined is not supported');
3703
+ if (isPromiseLike(firstConfiguration)) throw TypeError('Promises are not supported');
3704
+ if (!firstConfiguration) return {};
3705
+ if (0 === configurations.length) {
3706
+ if (Array.isArray(firstConfiguration)) {
3707
+ if (0 === firstConfiguration.length) return {};
3708
+ if (firstConfiguration.some(isUndefined)) throw TypeError('Merging undefined is not supported');
3709
+ if (isPromiseLike(firstConfiguration[0])) throw TypeError('Promises are not supported');
3710
+ return merge_with(firstConfiguration, joinArrays(options));
3711
+ }
3712
+ return firstConfiguration;
3713
+ }
3714
+ return merge_with([
3715
+ firstConfiguration
3716
+ ].concat(configurations), joinArrays(options));
3717
+ };
3718
+ }
3628
3719
  async function modifyBundlerChain(context, utils) {
3629
3720
  context.logger.debug('applying modifyBundlerChain hook');
3630
3721
  let rspackChain = new RspackChain(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
@@ -3712,7 +3803,7 @@ let configChain_CHAIN_ID = {
3712
3803
  }
3713
3804
  };
3714
3805
  function pluginHelper_getHTMLPlugin(config) {
3715
- return config?.html.implementation === 'native' ? core_rspack.HtmlRspackPlugin : (pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = requireCompiledPackage('html-rspack-plugin')), pluginHelper_htmlPlugin);
3806
+ return config?.html.implementation === 'native' ? core_rspack.HtmlRspackPlugin : (pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = vendors_require(`${COMPILED_PATH}/html-rspack-plugin/index.js`)), pluginHelper_htmlPlugin);
3716
3807
  }
3717
3808
  async function modifyRspackConfig(context, rspackConfig, chainUtils) {
3718
3809
  context.logger.debug('applying modifyRspackConfig hook');
@@ -3740,10 +3831,7 @@ async function modifyRspackConfig(context, rspackConfig, chainUtils) {
3740
3831
  function getConfigUtils(getCurrentConfig, chainUtils) {
3741
3832
  return {
3742
3833
  ...chainUtils,
3743
- mergeConfig: (...args)=>{
3744
- let { merge } = requireCompiledPackage('webpack-merge');
3745
- return merge(...args);
3746
- },
3834
+ mergeConfig: dist_merge,
3747
3835
  addRules (rules) {
3748
3836
  let config = getCurrentConfig(), ruleArr = helpers_castArray(rules);
3749
3837
  config.module || (config.module = {}), config.module.rules || (config.module.rules = []), config.module.rules.unshift(...ruleArr);
@@ -4264,7 +4352,7 @@ let chainStaticAssetRule = ({ emit, rule, maxSize, filename, assetType })=>{
4264
4352
  let generatorOptions = {
4265
4353
  filename
4266
4354
  };
4267
- 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({
4355
+ emit || (generatorOptions.emit = !1), rule.oneOf(`${assetType}-asset-url`).type('asset/resource').resourceQuery(URL_QUERY_REGEX).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({
4268
4356
  dataUrlCondition: {
4269
4357
  maxSize
4270
4358
  }
@@ -4379,7 +4467,7 @@ function parseMinifyOptions(config) {
4379
4467
  cssOptions: minify.cssOptions
4380
4468
  };
4381
4469
  }
4382
- let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
4470
+ let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.13/node_modules/postcss-load-config/src/index.js");
4383
4471
  var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
4384
4472
  function getLightningCSSLoaderOptions(config, targets, minify) {
4385
4473
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
@@ -5696,7 +5784,7 @@ function applySwcDecoratorConfig(swcConfig, config) {
5696
5784
  throw Error(`${color.dim('[rsbuild:swc]')} Unknown decorators version: ${color.yellow(version)}`);
5697
5785
  }
5698
5786
  }
5699
- let isRuntimeOverlayEnabled = (overlay)=>'object' == typeof overlay && !0 === overlay.runtime;
5787
+ let isRuntimeOverlayEnabled = (overlay)=>'object' == typeof overlay && (!0 === overlay.runtime || 'function' == typeof overlay.runtime);
5700
5788
  async function getLocalhostResolvedAddress() {
5701
5789
  let { promises: dns } = await import("node:dns"), [defaultLookup, explicitLookup] = await Promise.all([
5702
5790
  dns.lookup(LOCALHOST),
@@ -6486,7 +6574,14 @@ class SocketServer {
6486
6574
  let { browserLogs, client } = environment.config.dev;
6487
6575
  if ('client-error' === payload.type && !context.buildState.hasErrors && browserLogs) {
6488
6576
  let stackTrace = isObject(browserLogs) && browserLogs.stackTrace || DEFAULT_STACK_TRACE, outputFs = this.getOutputFileSystem(), stackFrames = payload.stack ? stack_trace_parser_esm_parse(payload.stack) : null, cachedTraceMap = new Map(), log = await formatBrowserErrorLog(payload.message, context, outputFs, stackTrace, stackFrames, cachedTraceMap);
6489
- if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), this.context.logger.error(`${color.cyan('[browser]')} ${log}`)), isRuntimeOverlayEnabled(client.overlay)) {
6577
+ if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), this.context.logger.error(`${color.cyan('[browser]')} ${log}`)), ((overlay, payload)=>{
6578
+ if (!isRuntimeOverlayEnabled(overlay)) return !1;
6579
+ if ('object' == typeof overlay && 'function' == typeof overlay.runtime) {
6580
+ let error;
6581
+ return overlay.runtime((error = Error(payload.message), payload.name && (error.name = payload.name), payload.stack && (error.stack = payload.stack), error));
6582
+ }
6583
+ return !0;
6584
+ })(client.overlay, payload)) {
6490
6585
  let resolvedLog = 'full' === stackTrace ? log : await formatBrowserErrorLog(payload.message, context, outputFs, 'full', stackFrames, cachedTraceMap);
6491
6586
  this.sendMessage({
6492
6587
  type: 'resolved-client-error',
@@ -8260,7 +8355,7 @@ try {
8260
8355
  cssRule.test(CSS_REGEX).dependency({
8261
8356
  not: 'url'
8262
8357
  });
8263
- let urlRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_URL).resourceQuery(/^\?url$/);
8358
+ let urlRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_URL).resourceQuery(URL_QUERY_REGEX);
8264
8359
  urlRule.use(CHAIN_ID.USE.CSS_URL).loader(node_path.join(dirname, 'cssUrlLoader.mjs'));
8265
8360
  let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).resourceQuery(INLINE_QUERY_REGEX);
8266
8361
  cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
@@ -8742,7 +8837,7 @@ try {
8742
8837
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8743
8838
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8744
8839
  if (!1 === manifest) return;
8745
- 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.1/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8840
+ 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.2/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8746
8841
  manifestFilenames.set(environment.name, manifestOptions.filename);
8747
8842
  let pluginOptions = {
8748
8843
  fileName: manifestOptions.filename,
@@ -9256,7 +9351,7 @@ let applyServerOptions = (command)=>{
9256
9351
  };
9257
9352
  function setupCommands() {
9258
9353
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9259
- cli.version("2.0.3"), 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)', {
9354
+ cli.version("2.0.4"), 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)', {
9260
9355
  default: 'auto'
9261
9356
  }).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', {
9262
9357
  type: [
@@ -9333,7 +9428,7 @@ function initNodeEnv() {
9333
9428
  }
9334
9429
  function showGreeting() {
9335
9430
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9336
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.3\n`);
9431
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.4\n`);
9337
9432
  }
9338
9433
  function setupLogLevel() {
9339
9434
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9354,5 +9449,5 @@ function runCLI() {
9354
9449
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9355
9450
  }
9356
9451
  }
9357
- let src_version = "2.0.3";
9452
+ let src_version = "2.0.4";
9358
9453
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
@@ -1,6 +1,19 @@
1
1
  import { logger } from "./797.js";
2
2
  let createOverlay;
3
3
  let clearOverlay;
4
+ const getErrorField = (error, field)=>{
5
+ if (error instanceof Error) {
6
+ const value = error[field];
7
+ return void 0 === value ? void 0 : String(value);
8
+ }
9
+ };
10
+ const formatErrorLikeMessage = (error)=>{
11
+ if (!(error instanceof Error)) return;
12
+ const message = getErrorField(error, 'message');
13
+ if (void 0 === message) return;
14
+ const name = getErrorField(error, 'name');
15
+ return name ? `${name}: ${message}` : message;
16
+ };
4
17
  function setupCustomHMRListeners(customListenersMap) {
5
18
  __webpack_require__.i.push(({ module })=>{
6
19
  const newListeners = new Map();
@@ -183,13 +196,14 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
183
196
  connect(true);
184
197
  }
185
198
  }
186
- function sendError(message, stack) {
199
+ function sendError(message, error) {
187
200
  const id = `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
188
201
  const messageInfo = {
189
202
  type: 'client-error',
190
203
  id,
191
204
  message,
192
- stack
205
+ name: getErrorField(error, 'name'),
206
+ stack: getErrorField(error, 'stack')
193
207
  };
194
208
  clientErrors.push({
195
209
  id
@@ -199,17 +213,15 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
199
213
  }
200
214
  function onUnhandledRejection({ reason }) {
201
215
  let message;
202
- let stack;
203
- if (reason instanceof Error) {
204
- message = reason.name ? `${reason.name}: ${reason.message}` : reason.message;
205
- stack = reason.stack;
206
- } else if ('string' == typeof reason) message = reason;
216
+ const errorMessage = formatErrorLikeMessage(reason);
217
+ if (void 0 !== errorMessage) message = errorMessage;
218
+ else if ('string' == typeof reason) message = reason;
207
219
  else try {
208
220
  message = JSON.stringify(reason);
209
221
  } catch (unused) {
210
222
  return;
211
223
  }
212
- sendError(`Uncaught (in promise) ${message}`, stack);
224
+ sendError(`Uncaught (in promise) ${message}`, reason);
213
225
  }
214
226
  function connect(fallback = false) {
215
227
  if (0 === reconnectCount) logger.info('[rsbuild] WebSocket connecting...');
@@ -243,7 +255,7 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
243
255
  }
244
256
  if (browserLogs && "u" > typeof window) {
245
257
  window.addEventListener('error', ({ message, error })=>{
246
- sendError(message, error instanceof Error ? error.stack : void 0);
258
+ sendError(message, error);
247
259
  });
248
260
  window.addEventListener('unhandledrejection', onUnhandledRejection);
249
261
  }