@rsbuild/core 2.0.2 → 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,16 +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',
2844
+ 'dev.client.overlay.errors',
2845
+ 'dev.client.overlay.runtime',
2832
2846
  'provider',
2833
2847
  'customLogger'
2834
- ]), mergeConfig_merge = (x, y, path = '')=>{
2848
+ ]), merge = (x, y, path = '')=>{
2835
2849
  if (((key)=>{
2836
2850
  if (key.startsWith('environments.')) {
2837
2851
  let realKey = key.split('.').slice(2).join('.');
@@ -2864,7 +2878,7 @@ let OVERRIDE_PATHS = new Set([
2864
2878
  ...Object.keys(y)
2865
2879
  ])){
2866
2880
  let childPath = path ? `${path}.${key}` : key;
2867
- merged[key] = mergeConfig_merge(x[key], y[key], childPath);
2881
+ merged[key] = merge(x[key], y[key], childPath);
2868
2882
  }
2869
2883
  return merged;
2870
2884
  }, normalizeConfigStructure = (config)=>{
@@ -2884,7 +2898,7 @@ let OVERRIDE_PATHS = new Set([
2884
2898
  ]), normalizedConfig.dev = dev), normalizedConfig;
2885
2899
  }, mergeRsbuildConfig = (...originalConfigs)=>{
2886
2900
  let configs = originalConfigs.filter((config)=>void 0 !== config).map(normalizeConfigStructure);
2887
- 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), {});
2888
2902
  }, defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
2889
2903
  dev: {
2890
2904
  hmr: !0,
@@ -3467,7 +3481,7 @@ function createPublicContext(context) {
3467
3481
  async function createContext(options, userConfig, logger) {
3468
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;
3469
3483
  return {
3470
- version: "2.0.2",
3484
+ version: "2.0.4",
3471
3485
  rootPath,
3472
3486
  distPath: '',
3473
3487
  cachePath,
@@ -3624,6 +3638,84 @@ function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assi
3624
3638
  mergeFn
3625
3639
  }), initial) : config ?? initial;
3626
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
+ }
3627
3719
  async function modifyBundlerChain(context, utils) {
3628
3720
  context.logger.debug('applying modifyBundlerChain hook');
3629
3721
  let rspackChain = new RspackChain(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
@@ -3711,7 +3803,7 @@ let configChain_CHAIN_ID = {
3711
3803
  }
3712
3804
  };
3713
3805
  function pluginHelper_getHTMLPlugin(config) {
3714
- 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);
3715
3807
  }
3716
3808
  async function modifyRspackConfig(context, rspackConfig, chainUtils) {
3717
3809
  context.logger.debug('applying modifyRspackConfig hook');
@@ -3739,10 +3831,7 @@ async function modifyRspackConfig(context, rspackConfig, chainUtils) {
3739
3831
  function getConfigUtils(getCurrentConfig, chainUtils) {
3740
3832
  return {
3741
3833
  ...chainUtils,
3742
- mergeConfig: (...args)=>{
3743
- let { merge } = requireCompiledPackage('webpack-merge');
3744
- return merge(...args);
3745
- },
3834
+ mergeConfig: dist_merge,
3746
3835
  addRules (rules) {
3747
3836
  let config = getCurrentConfig(), ruleArr = helpers_castArray(rules);
3748
3837
  config.module || (config.module = {}), config.module.rules || (config.module.rules = []), config.module.rules.unshift(...ruleArr);
@@ -4263,7 +4352,7 @@ let chainStaticAssetRule = ({ emit, rule, maxSize, filename, assetType })=>{
4263
4352
  let generatorOptions = {
4264
4353
  filename
4265
4354
  };
4266
- 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({
4267
4356
  dataUrlCondition: {
4268
4357
  maxSize
4269
4358
  }
@@ -4378,7 +4467,7 @@ function parseMinifyOptions(config) {
4378
4467
  cssOptions: minify.cssOptions
4379
4468
  };
4380
4469
  }
4381
- 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");
4382
4471
  var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
4383
4472
  function getLightningCSSLoaderOptions(config, targets, minify) {
4384
4473
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
@@ -5695,6 +5784,7 @@ function applySwcDecoratorConfig(swcConfig, config) {
5695
5784
  throw Error(`${color.dim('[rsbuild:swc]')} Unknown decorators version: ${color.yellow(version)}`);
5696
5785
  }
5697
5786
  }
5787
+ let isRuntimeOverlayEnabled = (overlay)=>'object' == typeof overlay && (!0 === overlay.runtime || 'function' == typeof overlay.runtime);
5698
5788
  async function getLocalhostResolvedAddress() {
5699
5789
  let { promises: dns } = await import("node:dns"), [defaultLookup, explicitLookup] = await Promise.all([
5700
5790
  dns.lookup(LOCALHOST),
@@ -6042,6 +6132,8 @@ let noop = ()=>{}, normalizeLiveReload = (liveReload)=>'boolean' == typeof liveR
6042
6132
  html: !1 !== liveReload.html
6043
6133
  }, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
6044
6134
  function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort }) {
6135
+ var overlay;
6136
+ let overlay1;
6045
6137
  if (!((compiler)=>{
6046
6138
  let { target } = compiler.options;
6047
6139
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
@@ -6051,7 +6143,7 @@ function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort })
6051
6143
  };
6052
6144
  '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
6053
6145
  let hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
6054
- ${config.dev.client.overlay ? `import '${toPosixPath(join(CLIENT_PATH, 'overlay.js'))}';` : ''}
6146
+ ${!0 === (overlay1 = overlay = config.dev.client.overlay) || 'object' == typeof overlay1 && !1 !== overlay1.errors || isRuntimeOverlayEnabled(overlay) ? `import '${toPosixPath(join(CLIENT_PATH, 'overlay.js'))}';` : ''}
6055
6147
  init(
6056
6148
  '${token}',
6057
6149
  ${JSON.stringify(clientConfig)},
@@ -6221,7 +6313,7 @@ function parseNode(line) {
6221
6313
  column: parts[4] ? +parts[4] : null
6222
6314
  } : null;
6223
6315
  }
6224
- let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName), parseFrame = async (frame, fs, context, cachedTraceMap)=>{
6316
+ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName), isRspackRuntimeStack = (value)=>!!value && (value.includes('__webpack_require__') || value.startsWith('webpack/runtime/')), parseFrame = async (frame, fs, context, cachedTraceMap)=>{
6225
6317
  let { file, column, lineNumber } = frame, sourceMapInfo = await getFileFromUrl(`${file}.map`, fs, context);
6226
6318
  if (!sourceMapInfo || 'errorCode' in sourceMapInfo) return;
6227
6319
  let { TraceMap, originalPositionFor } = await import("./trace-mapping.js"), sourceMapPath = sourceMapInfo.filename;
@@ -6265,22 +6357,31 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
6265
6357
  let { file, lineNumber, column } = frame;
6266
6358
  if (file) return null !== lineNumber ? null !== column ? `${file}:${lineNumber}:${column}` : `${file}:${lineNumber}` : file;
6267
6359
  }, formatFullStack = async (stackFrames, context, fs, cachedTraceMap)=>{
6268
- let result = '';
6360
+ let formattedFrames = [];
6269
6361
  for (let frame of stackFrames){
6270
- let parsedFrame = await parseFrame(frame, fs, context, cachedTraceMap), { methodName } = frame, parts = [];
6362
+ let location, parsedFrame = await parseFrame(frame, fs, context, cachedTraceMap), { methodName } = frame, parts = [];
6271
6363
  isValidMethodName(methodName) && parts.push(methodName);
6272
6364
  let parsed = !1;
6273
6365
  if (parsedFrame) {
6274
6366
  let { sourceMapPath, originalPosition } = parsedFrame, originalLocation = formatOriginalLocation(sourceMapPath, originalPosition, context);
6275
- originalLocation && (parts.push(originalLocation), parsed = !0);
6367
+ originalLocation && (location = originalLocation, parts.push(originalLocation), parsed = !0);
6276
6368
  }
6277
6369
  if (!parsed && isVerbose(context.logger)) {
6278
6370
  let frameString = formatFrameLocation(frame);
6279
- frameString && parts.push(frameString);
6371
+ frameString && (location = frameString, parts.push(frameString));
6372
+ }
6373
+ let [first, second] = parts;
6374
+ if (first) {
6375
+ let isRspackRuntime = isRspackRuntimeStack(methodName) || isRspackRuntimeStack(location);
6376
+ formattedFrames.push({
6377
+ text: second ? `\n at ${first} (${second})` : `\n at ${first}`,
6378
+ isRspackRuntime,
6379
+ hasLocation: void 0 !== location
6380
+ });
6280
6381
  }
6281
- parts[0] && (result += `\n at ${parts[0]}`), parts[1] && (result += ` (${parts[1]})`);
6282
6382
  }
6283
- return result;
6383
+ let shouldFilterRspackRuntime = formattedFrames.some((frame)=>!frame.isRspackRuntime && frame.hasLocation);
6384
+ return formattedFrames.filter((frame)=>!(shouldFilterRspackRuntime && frame.isRspackRuntime)).map((frame)=>frame.text).join('');
6284
6385
  }, formatBrowserErrorLog = async (message, context, fs, stackTrace, stackFrames, cachedTraceMap)=>{
6285
6386
  var log;
6286
6387
  let log1 = color.red(message);
@@ -6418,7 +6519,12 @@ class SocketServer {
6418
6519
  });
6419
6520
  }
6420
6521
  sendError(errors, token) {
6421
- let { rootPath } = this.context, formattedErrors = errors.map((item)=>formatStatsError(item, rootPath, 'error', this.context.logger)), html = formattedErrors.map((error)=>convertLinksInHtml(ansiHTML(escapeHtml(error)), rootPath)).join('\n\n').trim();
6522
+ let { rootPath } = this.context, formattedErrors = errors.map((item)=>formatStatsError(item, rootPath, 'error', this.context.logger)), environment = this.getEnvironmentByToken(token), overlay = environment?.config.dev.client.overlay, overlayErrors = formattedErrors;
6523
+ if (overlay && 'object' == typeof overlay && 'function' == typeof overlay.errors) {
6524
+ let { errors: filter } = overlay;
6525
+ overlayErrors = formattedErrors.filter((error)=>filter(Error(error)));
6526
+ }
6527
+ let html = overlayErrors.map((error)=>convertLinksInHtml(ansiHTML(escapeHtml(error)), rootPath)).join('\n\n').trim();
6422
6528
  this.sendMessage({
6423
6529
  type: 'errors',
6424
6530
  data: {
@@ -6468,7 +6574,14 @@ class SocketServer {
6468
6574
  let { browserLogs, client } = environment.config.dev;
6469
6575
  if ('client-error' === payload.type && !context.buildState.hasErrors && browserLogs) {
6470
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);
6471
- if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), this.context.logger.error(`${color.cyan('[browser]')} ${log}`)), 'object' == typeof client.overlay && client.overlay.runtime) {
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)) {
6472
6585
  let resolvedLog = 'full' === stackTrace ? log : await formatBrowserErrorLog(payload.message, context, outputFs, 'full', stackFrames, cachedTraceMap);
6473
6586
  this.sendMessage({
6474
6587
  type: 'resolved-client-error',
@@ -7665,30 +7778,47 @@ function applyDefaultPlugins(pluginManager, context) {
7665
7778
  {
7666
7779
  name: 'rsbuild:source-map',
7667
7780
  setup (api) {
7781
+ let normalizeExtractOptions = (extract = {})=>{
7782
+ let hasLegacyJs = 'js' in extract, hasFlatFields = [
7783
+ 'test',
7784
+ 'include',
7785
+ 'exclude'
7786
+ ].some((key)=>void 0 !== extract[key]);
7787
+ if (!1 === extract.js) return !1;
7788
+ if (hasLegacyJs && !hasFlatFields) {
7789
+ var target;
7790
+ let legacyJs = !!(target = extract.js) && (!0 === target ? {} : {
7791
+ include: target.include?.map(normalizeRuleConditionPath),
7792
+ exclude: target.exclude?.map(normalizeRuleConditionPath)
7793
+ });
7794
+ return !!legacyJs && {
7795
+ name: 'source-map-extract-js',
7796
+ test: JS_REGEX,
7797
+ target: legacyJs
7798
+ };
7799
+ }
7800
+ let { test, include, exclude } = extract;
7801
+ return {
7802
+ name: 'source-map-extract',
7803
+ test: test ?? JS_REGEX,
7804
+ target: {
7805
+ include: include?.map(normalizeRuleConditionPath),
7806
+ exclude: exclude?.map(normalizeRuleConditionPath)
7807
+ }
7808
+ };
7809
+ };
7668
7810
  api.modifyBundlerChain({
7669
7811
  order: 'pre',
7670
7812
  handler: (chain, { environment })=>{
7671
7813
  let extractConfig = ((config)=>{
7672
- var target;
7673
7814
  let { sourceMap } = config.output;
7674
- if ('object' != typeof sourceMap || !sourceMap.extract) return !1;
7675
- if (!0 === sourceMap.extract) return {
7676
- js: {}
7677
- };
7678
- let js = !!(target = sourceMap.extract.js) && (!0 === target ? {} : {
7679
- include: target.include?.map(normalizeRuleConditionPath),
7680
- exclude: target.exclude?.map(normalizeRuleConditionPath)
7681
- });
7682
- return !!js && {
7683
- js
7684
- };
7815
+ return 'object' == typeof sourceMap && !!sourceMap.extract && (!0 === sourceMap.extract ? normalizeExtractOptions() : 'object' == typeof sourceMap.extract && normalizeExtractOptions(sourceMap.extract));
7685
7816
  })(environment.config);
7686
- extractConfig && ((chain, name, test, target)=>{
7687
- if (!target) return;
7688
- let rule = chain.module.rule(name).test(test).set('extractSourceMap', !0), { include, exclude } = target;
7817
+ extractConfig && ((chain, extractConfig)=>{
7818
+ let { name, test, target } = extractConfig, rule = chain.module.rule(name).test(test).set('extractSourceMap', !0), { include, exclude } = target;
7689
7819
  if (include) for (let condition of include)rule.include.add(condition);
7690
7820
  if (exclude) for (let condition of exclude)rule.exclude.add(condition);
7691
- })(chain, 'source-map-extract-js', JS_REGEX, extractConfig.js);
7821
+ })(chain, extractConfig);
7692
7822
  }
7693
7823
  }), api.modifyBundlerChain((chain, { rspack, environment, isDev, target })=>{
7694
7824
  let { config } = environment, devtool = ((config)=>{
@@ -8225,7 +8355,7 @@ try {
8225
8355
  cssRule.test(CSS_REGEX).dependency({
8226
8356
  not: 'url'
8227
8357
  });
8228
- 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);
8229
8359
  urlRule.use(CHAIN_ID.USE.CSS_URL).loader(node_path.join(dirname, 'cssUrlLoader.mjs'));
8230
8360
  let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).resourceQuery(INLINE_QUERY_REGEX);
8231
8361
  cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
@@ -8707,7 +8837,7 @@ try {
8707
8837
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8708
8838
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8709
8839
  if (!1 === manifest) return;
8710
- 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/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'));
8711
8841
  manifestFilenames.set(environment.name, manifestOptions.filename);
8712
8842
  let pluginOptions = {
8713
8843
  fileName: manifestOptions.filename,
@@ -9221,7 +9351,7 @@ let applyServerOptions = (command)=>{
9221
9351
  };
9222
9352
  function setupCommands() {
9223
9353
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9224
- cli.version("2.0.2"), 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)', {
9225
9355
  default: 'auto'
9226
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', {
9227
9357
  type: [
@@ -9298,7 +9428,7 @@ function initNodeEnv() {
9298
9428
  }
9299
9429
  function showGreeting() {
9300
9430
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9301
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.2\n`);
9431
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.4\n`);
9302
9432
  }
9303
9433
  function setupLogLevel() {
9304
9434
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9319,5 +9449,5 @@ function runCLI() {
9319
9449
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9320
9450
  }
9321
9451
  }
9322
- let src_version = "2.0.2";
9452
+ let src_version = "2.0.4";
9323
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();
@@ -74,7 +87,9 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
74
87
  clearBuildErrors();
75
88
  hasBuildErrors = true;
76
89
  for (const error of text)logger.error(error);
77
- if (createOverlay) createOverlay('Build failed', html);
90
+ const { overlay } = config;
91
+ if (createOverlay && (true === overlay || 'object' == typeof overlay && false !== overlay.errors)) if (html) createOverlay('Build failed', html);
92
+ else null == clearOverlay || clearOverlay();
78
93
  }
79
94
  function handleResolvedClientError({ id, message }) {
80
95
  if (!createOverlay || hasBuildErrors) return;
@@ -181,13 +196,14 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
181
196
  connect(true);
182
197
  }
183
198
  }
184
- function sendError(message, stack) {
199
+ function sendError(message, error) {
185
200
  const id = `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
186
201
  const messageInfo = {
187
202
  type: 'client-error',
188
203
  id,
189
204
  message,
190
- stack
205
+ name: getErrorField(error, 'name'),
206
+ stack: getErrorField(error, 'stack')
191
207
  };
192
208
  clientErrors.push({
193
209
  id
@@ -197,17 +213,15 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
197
213
  }
198
214
  function onUnhandledRejection({ reason }) {
199
215
  let message;
200
- let stack;
201
- if (reason instanceof Error) {
202
- message = reason.name ? `${reason.name}: ${reason.message}` : reason.message;
203
- stack = reason.stack;
204
- } 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;
205
219
  else try {
206
220
  message = JSON.stringify(reason);
207
221
  } catch (unused) {
208
222
  return;
209
223
  }
210
- sendError(`Uncaught (in promise) ${message}`, stack);
224
+ sendError(`Uncaught (in promise) ${message}`, reason);
211
225
  }
212
226
  function connect(fallback = false) {
213
227
  if (0 === reconnectCount) logger.info('[rsbuild] WebSocket connecting...');
@@ -241,7 +255,7 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
241
255
  }
242
256
  if (browserLogs && "u" > typeof window) {
243
257
  window.addEventListener('error', ({ message, error })=>{
244
- sendError(message, error instanceof Error ? error.stack : void 0);
258
+ sendError(message, error);
245
259
  });
246
260
  window.addEventListener('unhandledrejection', onUnhandledRejection);
247
261
  }