@rsbuild/core 1.3.12 → 1.3.14

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,19 +1,19 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 2019: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 9377: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(6797);
5
+ const loader = __nccwpck_require__(1667);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(3288).defaultGetLocalIdent;
8
+ __nccwpck_require__(9230).defaultGetLocalIdent;
9
9
  },
10
- 6797: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 1667: (__unused_webpack_module, exports, __nccwpck_require__) => {
11
11
  "use strict";
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports["default"] = loader;
14
14
  var _postcss = _interopRequireDefault(__nccwpck_require__(9409));
15
- var _plugins = __nccwpck_require__(5922);
16
- var _utils = __nccwpck_require__(3288);
15
+ var _plugins = __nccwpck_require__(6800);
16
+ var _utils = __nccwpck_require__(9230);
17
17
  function _interopRequireDefault(obj) {
18
18
  return obj && obj.__esModule ? obj : { default: obj };
19
19
  }
@@ -236,7 +236,7 @@
236
236
  callback(null, `${importCode}${moduleCode}${exportCode}`);
237
237
  }
238
238
  },
239
- 5922: (__unused_webpack_module, exports, __nccwpck_require__) => {
239
+ 6800: (__unused_webpack_module, exports, __nccwpck_require__) => {
240
240
  "use strict";
241
241
  Object.defineProperty(exports, "__esModule", { value: true });
242
242
  Object.defineProperty(exports, "icssParser", {
@@ -257,21 +257,21 @@
257
257
  return _postcssUrlParser.default;
258
258
  },
259
259
  });
260
- var _postcssImportParser = _interopRequireDefault(__nccwpck_require__(1));
261
- var _postcssIcssParser = _interopRequireDefault(
262
- __nccwpck_require__(6712),
260
+ var _postcssImportParser = _interopRequireDefault(
261
+ __nccwpck_require__(5715),
263
262
  );
264
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(5295));
263
+ var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(126));
264
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(3737));
265
265
  function _interopRequireDefault(obj) {
266
266
  return obj && obj.__esModule ? obj : { default: obj };
267
267
  }
268
268
  },
269
- 6712: (__unused_webpack_module, exports, __nccwpck_require__) => {
269
+ 126: (__unused_webpack_module, exports, __nccwpck_require__) => {
270
270
  "use strict";
271
271
  Object.defineProperty(exports, "__esModule", { value: true });
272
272
  exports["default"] = void 0;
273
273
  var _icssUtils = __nccwpck_require__(4531);
274
- var _utils = __nccwpck_require__(3288);
274
+ var _utils = __nccwpck_require__(9230);
275
275
  const plugin = (options = {}) => ({
276
276
  postcssPlugin: "postcss-icss-parser",
277
277
  async OnceExit(root) {
@@ -370,14 +370,14 @@
370
370
  plugin.postcss = true;
371
371
  var _default = (exports["default"] = plugin);
372
372
  },
373
- 1: (__unused_webpack_module, exports, __nccwpck_require__) => {
373
+ 5715: (__unused_webpack_module, exports, __nccwpck_require__) => {
374
374
  "use strict";
375
375
  Object.defineProperty(exports, "__esModule", { value: true });
376
376
  exports["default"] = void 0;
377
377
  var _postcssValueParser = _interopRequireDefault(
378
378
  __nccwpck_require__(2948),
379
379
  );
380
- var _utils = __nccwpck_require__(3288);
380
+ var _utils = __nccwpck_require__(9230);
381
381
  function _interopRequireDefault(obj) {
382
382
  return obj && obj.__esModule ? obj : { default: obj };
383
383
  }
@@ -682,14 +682,14 @@
682
682
  plugin.postcss = true;
683
683
  var _default = (exports["default"] = plugin);
684
684
  },
685
- 5295: (__unused_webpack_module, exports, __nccwpck_require__) => {
685
+ 3737: (__unused_webpack_module, exports, __nccwpck_require__) => {
686
686
  "use strict";
687
687
  Object.defineProperty(exports, "__esModule", { value: true });
688
688
  exports["default"] = void 0;
689
689
  var _postcssValueParser = _interopRequireDefault(
690
690
  __nccwpck_require__(2948),
691
691
  );
692
- var _utils = __nccwpck_require__(3288);
692
+ var _utils = __nccwpck_require__(9230);
693
693
  function _interopRequireDefault(obj) {
694
694
  return obj && obj.__esModule ? obj : { default: obj };
695
695
  }
@@ -1032,7 +1032,7 @@
1032
1032
  plugin.postcss = true;
1033
1033
  var _default = (exports["default"] = plugin);
1034
1034
  },
1035
- 3288: (__unused_webpack_module, exports, __nccwpck_require__) => {
1035
+ 9230: (__unused_webpack_module, exports, __nccwpck_require__) => {
1036
1036
  "use strict";
1037
1037
  Object.defineProperty(exports, "__esModule", { value: true });
1038
1038
  exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
@@ -8096,6 +8096,6 @@
8096
8096
  }
8097
8097
  if (typeof __nccwpck_require__ !== "undefined")
8098
8098
  __nccwpck_require__.ab = __dirname + "/";
8099
- var __webpack_exports__ = __nccwpck_require__(2019);
8099
+ var __webpack_exports__ = __nccwpck_require__(9377);
8100
8100
  module.exports = __webpack_exports__;
8101
8101
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 150: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 725: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(543);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(318);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -304,7 +304,7 @@
304
304
  }
305
305
  module.exports = { CachedChildCompilation };
306
306
  },
307
- 543: (module) => {
307
+ 318: (module) => {
308
308
  "use strict";
309
309
  class HtmlWebpackChildCompiler {
310
310
  constructor(templates) {
@@ -473,7 +473,7 @@
473
473
  }
474
474
  module.exports = { HtmlWebpackChildCompiler };
475
475
  },
476
- 525: (module) => {
476
+ 910: (module) => {
477
477
  "use strict";
478
478
  module.exports = {};
479
479
  module.exports.none = (chunks) => chunks;
@@ -492,7 +492,7 @@
492
492
  };
493
493
  module.exports.auto = module.exports.none;
494
494
  },
495
- 628: (module) => {
495
+ 185: (module) => {
496
496
  "use strict";
497
497
  module.exports = function (err) {
498
498
  return {
@@ -513,7 +513,7 @@
513
513
  };
514
514
  };
515
515
  },
516
- 491: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 312: (module, __unused_webpack_exports, __nccwpck_require__) => {
517
517
  "use strict";
518
518
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
519
519
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -539,7 +539,7 @@
539
539
  }
540
540
  module.exports = { getHtmlRspackPluginHooks };
541
541
  },
542
- 690: (module) => {
542
+ 333: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 867: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 192: (module, __unused_webpack_exports, __nccwpck_require__) => {
611
611
  "use strict";
612
612
  const promisify = __nccwpck_require__(23).promisify;
613
613
  const vm = __nccwpck_require__(154);
614
614
  const fs = __nccwpck_require__(896);
615
615
  const path = __nccwpck_require__(928);
616
- const { CachedChildCompilation } = __nccwpck_require__(150);
616
+ const { CachedChildCompilation } = __nccwpck_require__(725);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(690);
619
- const prettyError = __nccwpck_require__(628);
620
- const chunkSorter = __nccwpck_require__(525);
618
+ __nccwpck_require__(333);
619
+ const prettyError = __nccwpck_require__(185);
620
+ const chunkSorter = __nccwpck_require__(910);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(491).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(312).getHtmlRspackPluginHooks;
623
623
  class HtmlRspackPlugin {
624
624
  constructor(userOptions = {}) {
625
625
  this.version = HtmlRspackPlugin.version;
@@ -1586,6 +1586,6 @@
1586
1586
  }
1587
1587
  if (typeof __nccwpck_require__ !== "undefined")
1588
1588
  __nccwpck_require__.ab = __dirname + "/";
1589
- var __webpack_exports__ = __nccwpck_require__(867);
1589
+ var __webpack_exports__ = __nccwpck_require__(192);
1590
1590
  module.exports = __webpack_exports__;
1591
1591
  })();
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 744: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(742)["default"];
4
+ 631: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(513)["default"];
6
6
  },
7
- 742: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 513: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(928));
12
- var _utils = __nccwpck_require__(991);
12
+ var _utils = __nccwpck_require__(876);
13
13
  function _interopRequireDefault(obj) {
14
14
  return obj && obj.__esModule ? obj : { default: obj };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 991: (module, exports, __nccwpck_require__) => {
182
+ 876: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -716,6 +716,6 @@
716
716
  })();
717
717
  if (typeof __nccwpck_require__ !== "undefined")
718
718
  __nccwpck_require__.ab = __dirname + "/";
719
- var __webpack_exports__ = __nccwpck_require__(744);
719
+ var __webpack_exports__ = __nccwpck_require__(631);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 492: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 685: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.transformFiles =
7
7
  exports.reduceChunk =
@@ -120,7 +120,7 @@
120
120
  .map(standardizeFilePaths);
121
121
  exports.transformFiles = transformFiles;
122
122
  },
123
- 597: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 440: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
124
  Object.defineProperty(exports, "__esModule", { value: true });
125
125
  exports.normalModuleLoaderHook =
126
126
  exports.getCompilerHooks =
@@ -130,7 +130,7 @@
130
130
  const fs_1 = __nccwpck_require__(896);
131
131
  const path_1 = __nccwpck_require__(928);
132
132
  const lite_tapable_1 = __nccwpck_require__(408);
133
- const helpers_1 = __nccwpck_require__(492);
133
+ const helpers_1 = __nccwpck_require__(685);
134
134
  const compilerHookMap = new WeakMap();
135
135
  const getCompilerHooks = (compiler) => {
136
136
  let hooks = compilerHookMap.get(compiler);
@@ -312,7 +312,7 @@
312
312
  exports.getCompilerHooks =
313
313
  void 0;
314
314
  const path_1 = __nccwpck_require__(928);
315
- const hooks_1 = __nccwpck_require__(597);
315
+ const hooks_1 = __nccwpck_require__(440);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
package/dist/index.cjs CHANGED
@@ -1339,7 +1339,7 @@ for(var __webpack_i__ in (()=>{
1339
1339
  }, verbose);
1340
1340
  return {
1341
1341
  message: function(errors) {
1342
- let title = index_js_default().bold(index_js_default().red('Build error: '));
1342
+ let title = index_js_default().bold(index_js_default().red(errors.length > 1 ? 'Build errors: ' : 'Build error: '));
1343
1343
  if (!errors.length) return `${title}\n${index_js_default().yellow("For more details, please setting 'stats.errors: true' ")}`;
1344
1344
  let text = `${errors.join('\n\n')}\n`;
1345
1345
  return `${title}\n${text}`;
@@ -1352,7 +1352,7 @@ for(var __webpack_i__ in (()=>{
1352
1352
  warnings: getAllStatsWarnings(statsData)
1353
1353
  }, verbose);
1354
1354
  if (warnings.length) {
1355
- let title = index_js_default().bold(index_js_default().yellow('Compile warning: \n'));
1355
+ let title = index_js_default().bold(index_js_default().yellow(warnings.length > 1 ? 'Build warnings: \n' : 'Build warning: \n'));
1356
1356
  return {
1357
1357
  message: `${title}${warnings.join('\n\n')}\n`,
1358
1358
  level: 'warning'
@@ -2258,7 +2258,7 @@ for(var __webpack_i__ in (()=>{
2258
2258
  async function createContext(options, userConfig) {
2259
2259
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
2260
2260
  return {
2261
- version: "1.3.12",
2261
+ version: "1.3.14",
2262
2262
  rootPath,
2263
2263
  distPath: '',
2264
2264
  cachePath,
@@ -3060,8 +3060,8 @@ for(var __webpack_i__ in (()=>{
3060
3060
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
3061
3061
  }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
3062
3062
  async function printFileSizes(options, stats, rootPath, environmentName) {
3063
- let logs = [];
3064
- if (!1 === options.detail && !1 === options.total) return logs;
3063
+ let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
3064
+ if (!showTotal && !showDetail) return logs;
3065
3065
  let formatAsset = async (asset, distPath, distFolder)=>{
3066
3066
  let fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
3067
3067
  return {
@@ -3075,7 +3075,7 @@ for(var __webpack_i__ in (()=>{
3075
3075
  }, getAssets = async ()=>{
3076
3076
  let distPath = stats.compilation.outputOptions.path;
3077
3077
  if (!distPath) return [];
3078
- let origin = stats.toJson({
3078
+ let filteredAssets = (stats.toJson({
3079
3079
  all: !1,
3080
3080
  assets: !0,
3081
3081
  cachedAssets: !0,
@@ -3084,7 +3084,7 @@ for(var __webpack_i__ in (()=>{
3084
3084
  groupAssetsByChunk: !1,
3085
3085
  groupAssetsByExtension: !1,
3086
3086
  groupAssetsByEmitStatus: !1
3087
- }), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
3087
+ }).assets || []).filter((asset)=>{
3088
3088
  let assetInfo = {
3089
3089
  name: asset.name,
3090
3090
  size: asset.size
@@ -3095,10 +3095,12 @@ for(var __webpack_i__ in (()=>{
3095
3095
  }, assets = await getAssets();
3096
3096
  if (0 === assets.length) return logs;
3097
3097
  logs.push(''), assets.sort((a, b)=>a.size - b.size);
3098
- let fileHeader = `File (${environmentName})`, maxFileLength = Math.max(...assets.map((a)=>(a.folder + external_node_path_default().sep + a.name).length), fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length));
3099
- if (!1 !== options.detail) {
3100
- let showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
3101
- logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
3098
+ let totalSize = 0, totalGzipSize = 0;
3099
+ for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
3100
+ let fileHeader = showDetail ? `File (${environmentName})` : '', totalSizeLabel = showTotal ? showDetail ? 'Total:' : `Total size (${environmentName}):` : '', totalSizeStr = showTotal ? calcFileSize(totalSize) : '';
3101
+ if (showDetail) {
3102
+ let maxFileLength = Math.max(...assets.map((a)=>(a.folder + external_node_path_default().sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
3103
+ for (let asset of (logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
3102
3104
  let lengths = [
3103
3105
  maxFileLength,
3104
3106
  maxSizeLength
@@ -3112,22 +3114,26 @@ for(var __webpack_i__ in (()=>{
3112
3114
  return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
3113
3115
  }, ' ');
3114
3116
  return index_js_default().blue(headerRow);
3115
- }(maxFileLength, maxSizeLength, fileHeader, showGzipHeader));
3116
- }
3117
- let totalSize = 0, totalGzipSize = 0;
3118
- for (let asset of assets){
3119
- let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
3120
- if (totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size), !1 !== options.detail) {
3117
+ }(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
3118
+ let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
3121
3119
  sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
3122
3120
  let fileNameLabel = index_js_default().dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
3123
3121
  fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
3124
3122
  let log = ` ${fileNameLabel} ${sizeLabel}`;
3125
3123
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3126
3124
  }
3127
- }
3128
- if (!1 !== options.total && assets.length > 1) {
3129
- let totalSizeLabel = `${index_js_default().blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3130
- options.compressed && (log += index_js_default().dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), logs.push(log);
3125
+ if (showTotal) {
3126
+ logs.push('');
3127
+ let log = ' ';
3128
+ if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
3129
+ let colorFn = getAssetColor(totalGzipSize / assets.length);
3130
+ log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
3131
+ }
3132
+ logs.push(log);
3133
+ }
3134
+ } else if (showTotal) {
3135
+ let log = ` ${index_js_default().magenta(totalSizeLabel)} ${totalSizeStr}`;
3136
+ options.compressed && (log += index_js_default().green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
3131
3137
  }
3132
3138
  return logs.push(''), logs;
3133
3139
  }
@@ -3569,9 +3575,11 @@ for(var __webpack_i__ in (()=>{
3569
3575
  function recursiveChunkEntryNames(chunk) {
3570
3576
  let [...chunkGroups] = chunk.groupsIterable;
3571
3577
  return [
3572
- ...new Set(chunkGroups.flatMap((chunkGroup)=>(function recursiveChunkGroup(chunkGroup) {
3578
+ ...new Set(chunkGroups.flatMap((chunkGroup)=>(function recursiveChunkGroup(chunkGroup, visited = new Set()) {
3579
+ if (visited.has(chunkGroup)) return [];
3580
+ visited.add(chunkGroup);
3573
3581
  let parents = chunkGroup.getParents();
3574
- return parents.length ? parents.flatMap((chunkParent)=>recursiveChunkGroup(chunkParent)) : [
3582
+ return parents.length ? parents.flatMap((chunkParent)=>recursiveChunkGroup(chunkParent, visited)) : [
3575
3583
  chunkGroup.name
3576
3584
  ];
3577
3585
  })(chunkGroup)).filter((name)=>!!name))
@@ -5509,7 +5517,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5509
5517
  display: none;
5510
5518
  }
5511
5519
  .file-link,
5512
- .url-link {
5520
+ .url-link,
5521
+ .config-link {
5513
5522
  cursor: pointer;
5514
5523
  text-decoration: underline;
5515
5524
  text-underline-offset: 3px;
@@ -5526,6 +5535,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5526
5535
  .url-link {
5527
5536
  color: #eff986;
5528
5537
  }
5538
+ .config-link {
5539
+ color: inherit;
5540
+ text-decoration: none;
5541
+ }
5529
5542
  .close {
5530
5543
  position: absolute;
5531
5544
  top: 27px;
@@ -5579,7 +5592,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5579
5592
  <pre class="content">${htmlItems.join('\n\n').trim()}</pre>
5580
5593
  <footer class="footer">
5581
5594
  <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
5582
- <p>Disable overlay by setting Rsbuild's <span>dev.client.overlay</span> config to false.<p>
5595
+ <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.dev/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5583
5596
  </footer>
5584
5597
  </div>
5585
5598
  </div>
@@ -5868,6 +5881,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5868
5881
  return ret;
5869
5882
  }(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/http-proxy-middleware/index.js"));
5870
5883
  for (let opts of formattedOptions){
5884
+ let { onProxyRes } = opts;
5885
+ opts.onProxyRes = (proxyRes, _req, res)=>{
5886
+ onProxyRes && onProxyRes(proxyRes, _req, res), res.on('close', ()=>{
5887
+ res.writableEnded || proxyRes.destroy();
5888
+ });
5889
+ };
5871
5890
  let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
5872
5891
  let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
5873
5892
  !1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
@@ -5898,7 +5917,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5898
5917
  };
5899
5918
  }, applyDefaultMiddlewares = async ({ dev, middlewares, server, compilationManager, context, pwd, environments, postCallbacks })=>{
5900
5919
  let upgradeEvents = [];
5901
- if (server.compress && middlewares.push(gzipMiddleware()), server.cors) {
5920
+ if (server.cors) {
5902
5921
  let { default: corsMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/cors/index.js"));
5903
5922
  middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
5904
5923
  }
@@ -5906,14 +5925,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5906
5925
  if (headers && middlewares.push((_req, res, next)=>{
5907
5926
  for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
5908
5927
  next();
5909
- }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5910
- let { compiler } = compilationManager;
5911
- 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5912
- }
5913
- if (server.proxy) {
5928
+ }), server.proxy) {
5914
5929
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
5915
5930
  for (let middleware of (upgradeEvents.push(upgrade), proxyMiddlewares))middlewares.push(middleware);
5916
5931
  }
5932
+ if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5933
+ let { compiler } = compilationManager;
5934
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5935
+ }
5917
5936
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5918
5937
  base: server.base
5919
5938
  }));
@@ -6596,9 +6615,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6596
6615
  }
6597
6616
  async applyDefaultMiddlewares() {
6598
6617
  let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
6599
- if ('verbose' === rslog_index_js_namespaceObject.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
6600
- level: 6
6601
- })), cors) {
6618
+ if ('verbose' === rslog_index_js_namespaceObject.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), cors) {
6602
6619
  let { default: corsMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/cors/index.js"));
6603
6620
  this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
6604
6621
  }
@@ -6610,7 +6627,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6610
6627
  for (let middleware of middlewares)this.middlewares.use(middleware);
6611
6628
  this.app.on('upgrade', upgrade);
6612
6629
  }
6613
- if (base && '/' !== base && this.middlewares.use(getBaseMiddleware({
6630
+ if (compress && this.middlewares.use(gzipMiddleware({
6631
+ level: 6
6632
+ })), base && '/' !== base && this.middlewares.use(getBaseMiddleware({
6614
6633
  base
6615
6634
  })), await this.applyStaticAssetMiddleware(), historyApiFallback) {
6616
6635
  let { default: connectHistoryApiFallback } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect-history-api-fallback/index.js")), historyApiFallbackMiddleware = connectHistoryApiFallback(!0 === historyApiFallback ? {} : historyApiFallback);
@@ -7488,11 +7507,11 @@ ${section.body}` : section.body).join("\n\n"));
7488
7507
  }
7489
7508
  process.title = 'rsbuild-node';
7490
7509
  let { npm_execpath } = process.env;
7491
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.12\n`);
7510
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.14\n`);
7492
7511
  try {
7493
7512
  !function() {
7494
7513
  let cli = cac_dist('rsbuild');
7495
- cli.help(), cli.version("1.3.12"), applyCommonOptions(cli);
7514
+ cli.help(), cli.version("1.3.14"), applyCommonOptions(cli);
7496
7515
  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');
7497
7516
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7498
7517
  try {
@@ -7543,7 +7562,7 @@ ${section.body}` : section.body).join("\n\n"));
7543
7562
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7544
7563
  }
7545
7564
  }
7546
- let src_version = "1.3.12";
7565
+ let src_version = "1.3.14";
7547
7566
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
7548
7567
  "PLUGIN_CSS_NAME",
7549
7568
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -1207,7 +1207,7 @@ function formatStats(statsData, hasErrors) {
1207
1207
  }, verbose);
1208
1208
  return {
1209
1209
  message: function(errors) {
1210
- let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red('Build error: '));
1210
+ let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red(errors.length > 1 ? 'Build errors: ' : 'Build error: '));
1211
1211
  if (!errors.length) return `${title}\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow("For more details, please setting 'stats.errors: true' ")}`;
1212
1212
  let text = `${errors.join('\n\n')}\n`;
1213
1213
  return `${title}\n${text}`;
@@ -1220,7 +1220,7 @@ function formatStats(statsData, hasErrors) {
1220
1220
  warnings: getAllStatsWarnings(statsData)
1221
1221
  }, verbose);
1222
1222
  if (warnings.length) {
1223
- let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('Compile warning: \n'));
1223
+ let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(warnings.length > 1 ? 'Build warnings: \n' : 'Build warning: \n'));
1224
1224
  return {
1225
1225
  message: `${title}${warnings.join('\n\n')}\n`,
1226
1226
  level: 'warning'
@@ -2117,7 +2117,7 @@ async function updateEnvironmentContext(context, configs) {
2117
2117
  async function createContext(options, userConfig) {
2118
2118
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
2119
2119
  return {
2120
- version: "1.3.12",
2120
+ version: "1.3.14",
2121
2121
  rootPath,
2122
2122
  distPath: '',
2123
2123
  cachePath,
@@ -2916,8 +2916,8 @@ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset
2916
2916
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
2917
2917
  }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2918
2918
  async function printFileSizes(options, stats, rootPath, environmentName) {
2919
- let logs = [];
2920
- if (!1 === options.detail && !1 === options.total) return logs;
2919
+ let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
2920
+ if (!showTotal && !showDetail) return logs;
2921
2921
  let formatAsset = async (asset, distPath, distFolder)=>{
2922
2922
  let fileName = asset.name.split('?')[0], contents = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && isCompressible(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
2923
2923
  return {
@@ -2931,7 +2931,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
2931
2931
  }, getAssets = async ()=>{
2932
2932
  let distPath = stats.compilation.outputOptions.path;
2933
2933
  if (!distPath) return [];
2934
- let origin = stats.toJson({
2934
+ let filteredAssets = (stats.toJson({
2935
2935
  all: !1,
2936
2936
  assets: !0,
2937
2937
  cachedAssets: !0,
@@ -2940,7 +2940,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
2940
2940
  groupAssetsByChunk: !1,
2941
2941
  groupAssetsByExtension: !1,
2942
2942
  groupAssetsByEmitStatus: !1
2943
- }), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
2943
+ }).assets || []).filter((asset)=>{
2944
2944
  let assetInfo = {
2945
2945
  name: asset.name,
2946
2946
  size: asset.size
@@ -2951,10 +2951,12 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
2951
2951
  }, assets = await getAssets();
2952
2952
  if (0 === assets.length) return logs;
2953
2953
  logs.push(''), assets.sort((a, b)=>a.size - b.size);
2954
- let fileHeader = `File (${environmentName})`, maxFileLength = Math.max(...assets.map((a)=>(a.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + a.name).length), fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length));
2955
- if (!1 !== options.detail) {
2956
- let showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
2957
- logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
2954
+ let totalSize = 0, totalGzipSize = 0;
2955
+ for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
2956
+ let fileHeader = showDetail ? `File (${environmentName})` : '', totalSizeLabel = showTotal ? showDetail ? 'Total:' : `Total size (${environmentName}):` : '', totalSizeStr = showTotal ? calcFileSize(totalSize) : '';
2957
+ if (showDetail) {
2958
+ let maxFileLength = Math.max(...assets.map((a)=>(a.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
2959
+ for (let asset of (logs.push(function(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
2958
2960
  let lengths = [
2959
2961
  maxFileLength,
2960
2962
  maxSizeLength
@@ -2968,22 +2970,26 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
2968
2970
  return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
2969
2971
  }, ' ');
2970
2972
  return __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.blue(headerRow);
2971
- }(maxFileLength, maxSizeLength, fileHeader, showGzipHeader));
2972
- }
2973
- let totalSize = 0, totalGzipSize = 0;
2974
- for (let asset of assets){
2975
- let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
2976
- if (totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size), !1 !== options.detail) {
2973
+ }(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
2974
+ let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep + name).length, sizeLength = sizeLabel.length;
2977
2975
  sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
2978
2976
  let fileNameLabel = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(asset.folder + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.sep) + coloringAssetName(asset.name);
2979
2977
  fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
2980
2978
  let log = ` ${fileNameLabel} ${sizeLabel}`;
2981
2979
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
2982
2980
  }
2983
- }
2984
- if (!1 !== options.total && assets.length > 1) {
2985
- let totalSizeLabel = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
2986
- options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), logs.push(log);
2981
+ if (showTotal) {
2982
+ logs.push('');
2983
+ let log = ' ';
2984
+ if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
2985
+ let colorFn = getAssetColor(totalGzipSize / assets.length);
2986
+ log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
2987
+ }
2988
+ logs.push(log);
2989
+ }
2990
+ } else if (showTotal) {
2991
+ let log = ` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(totalSizeLabel)} ${totalSizeStr}`;
2992
+ options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
2987
2993
  }
2988
2994
  return logs.push(''), logs;
2989
2995
  }
@@ -3424,9 +3430,11 @@ let getInlineTests = (config)=>{
3424
3430
  function recursiveChunkEntryNames(chunk) {
3425
3431
  let [...chunkGroups] = chunk.groupsIterable;
3426
3432
  return [
3427
- ...new Set(chunkGroups.flatMap((chunkGroup)=>(function recursiveChunkGroup(chunkGroup) {
3433
+ ...new Set(chunkGroups.flatMap((chunkGroup)=>(function recursiveChunkGroup(chunkGroup, visited = new Set()) {
3434
+ if (visited.has(chunkGroup)) return [];
3435
+ visited.add(chunkGroup);
3428
3436
  let parents = chunkGroup.getParents();
3429
- return parents.length ? parents.flatMap((chunkParent)=>recursiveChunkGroup(chunkParent)) : [
3437
+ return parents.length ? parents.flatMap((chunkParent)=>recursiveChunkGroup(chunkParent, visited)) : [
3430
3438
  chunkGroup.name
3431
3439
  ];
3432
3440
  })(chunkGroup)).filter((name)=>!!name))
@@ -5351,7 +5359,8 @@ class SocketServer {
5351
5359
  display: none;
5352
5360
  }
5353
5361
  .file-link,
5354
- .url-link {
5362
+ .url-link,
5363
+ .config-link {
5355
5364
  cursor: pointer;
5356
5365
  text-decoration: underline;
5357
5366
  text-underline-offset: 3px;
@@ -5368,6 +5377,10 @@ class SocketServer {
5368
5377
  .url-link {
5369
5378
  color: #eff986;
5370
5379
  }
5380
+ .config-link {
5381
+ color: inherit;
5382
+ text-decoration: none;
5383
+ }
5371
5384
  .close {
5372
5385
  position: absolute;
5373
5386
  top: 27px;
@@ -5421,7 +5434,7 @@ class SocketServer {
5421
5434
  <pre class="content">${htmlItems.join('\n\n').trim()}</pre>
5422
5435
  <footer class="footer">
5423
5436
  <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
5424
- <p>Disable overlay by setting Rsbuild's <span>dev.client.overlay</span> config to false.<p>
5437
+ <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.dev/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5425
5438
  </footer>
5426
5439
  </div>
5427
5440
  </div>
@@ -5710,6 +5723,12 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5710
5723
  return ret;
5711
5724
  }(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
5712
5725
  for (let opts of formattedOptions){
5726
+ let { onProxyRes } = opts;
5727
+ opts.onProxyRes = (proxyRes, _req, res)=>{
5728
+ onProxyRes && onProxyRes(proxyRes, _req, res), res.on('close', ()=>{
5729
+ res.writableEnded || proxyRes.destroy();
5730
+ });
5731
+ };
5713
5732
  let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
5714
5733
  let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
5715
5734
  !1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
@@ -5740,7 +5759,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5740
5759
  };
5741
5760
  }, applyDefaultMiddlewares = async ({ dev, middlewares, server, compilationManager, context, pwd, environments, postCallbacks })=>{
5742
5761
  let upgradeEvents = [];
5743
- if (server.compress && middlewares.push(gzipMiddleware()), server.cors) {
5762
+ if (server.cors) {
5744
5763
  let { default: corsMiddleware } = await import("../compiled/cors/index.js");
5745
5764
  middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
5746
5765
  }
@@ -5748,14 +5767,14 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5748
5767
  if (headers && middlewares.push((_req, res, next)=>{
5749
5768
  for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
5750
5769
  next();
5751
- }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5752
- let { compiler } = compilationManager;
5753
- '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));
5754
- }
5755
- if (server.proxy) {
5770
+ }), server.proxy) {
5756
5771
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
5757
5772
  for (let middleware of (upgradeEvents.push(upgrade), proxyMiddlewares))middlewares.push(middleware);
5758
5773
  }
5774
+ if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5775
+ let { compiler } = compilationManager;
5776
+ '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));
5777
+ }
5759
5778
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5760
5779
  base: server.base
5761
5780
  }));
@@ -6433,9 +6452,7 @@ class RsbuildProdServer {
6433
6452
  }
6434
6453
  async applyDefaultMiddlewares() {
6435
6454
  let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
6436
- if ('verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
6437
- level: 6
6438
- })), cors) {
6455
+ if ('verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), cors) {
6439
6456
  let { default: corsMiddleware } = await import("../compiled/cors/index.js");
6440
6457
  this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
6441
6458
  }
@@ -6447,7 +6464,9 @@ class RsbuildProdServer {
6447
6464
  for (let middleware of middlewares)this.middlewares.use(middleware);
6448
6465
  this.app.on('upgrade', upgrade);
6449
6466
  }
6450
- if (base && '/' !== base && this.middlewares.use(getBaseMiddleware({
6467
+ if (compress && this.middlewares.use(gzipMiddleware({
6468
+ level: 6
6469
+ })), base && '/' !== base && this.middlewares.use(getBaseMiddleware({
6451
6470
  base
6452
6471
  })), await this.applyStaticAssetMiddleware(), historyApiFallback) {
6453
6472
  let { default: connectHistoryApiFallback } = await import("../compiled/connect-history-api-fallback/index.js"), historyApiFallbackMiddleware = connectHistoryApiFallback(!0 === historyApiFallback ? {} : historyApiFallback);
@@ -7323,11 +7342,11 @@ async function runCLI() {
7323
7342
  }
7324
7343
  process.title = 'rsbuild-node';
7325
7344
  let { npm_execpath } = process.env;
7326
- (!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.12\n`);
7345
+ (!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.14\n`);
7327
7346
  try {
7328
7347
  !function() {
7329
7348
  let cli = cac_dist('rsbuild');
7330
- cli.help(), cli.version("1.3.12"), applyCommonOptions(cli);
7349
+ cli.help(), cli.version("1.3.14"), applyCommonOptions(cli);
7331
7350
  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');
7332
7351
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7333
7352
  try {
@@ -7378,6 +7397,6 @@ async function runCLI() {
7378
7397
  __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);
7379
7398
  }
7380
7399
  }
7381
- let src_version = "1.3.12";
7400
+ let src_version = "1.3.14";
7382
7401
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7383
7402
  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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,17 +46,17 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.3.7",
49
+ "@rspack/core": "1.3.8",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.41.0",
53
53
  "jiti": "^2.4.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.6.6",
56
+ "@rslib/core": "0.6.7",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/cors": "^2.8.17",
59
- "@types/node": "^22.14.1",
59
+ "@types/node": "^22.15.2",
60
60
  "@types/on-finished": "2.3.4",
61
61
  "@types/webpack-bundle-analyzer": "4.7.0",
62
62
  "@types/ws": "^8.18.1",