@rsbuild/core 1.3.14 → 1.3.16

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
- 584: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 777: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const WebSocket = __nccwpck_require__(939);
6
- WebSocket.createWebSocketStream = __nccwpck_require__(410);
7
- WebSocket.Server = __nccwpck_require__(599);
8
- WebSocket.Receiver = __nccwpck_require__(443);
9
- WebSocket.Sender = __nccwpck_require__(799);
5
+ const WebSocket = __nccwpck_require__(590);
6
+ WebSocket.createWebSocketStream = __nccwpck_require__(605);
7
+ WebSocket.Server = __nccwpck_require__(920);
8
+ WebSocket.Receiver = __nccwpck_require__(196);
9
+ WebSocket.Sender = __nccwpck_require__(780);
10
10
  WebSocket.WebSocket = WebSocket;
11
11
  WebSocket.WebSocketServer = WebSocket.Server;
12
12
  module.exports = WebSocket;
13
13
  },
14
- 845: (module, __unused_webpack_exports, __nccwpck_require__) => {
14
+ 468: (module, __unused_webpack_exports, __nccwpck_require__) => {
15
15
  "use strict";
16
- const { EMPTY_BUFFER } = __nccwpck_require__(617);
16
+ const { EMPTY_BUFFER } = __nccwpck_require__(656);
17
17
  const FastBuffer = Buffer[Symbol.species];
18
18
  function concat(list, totalLength) {
19
19
  if (list.length === 0) return EMPTY_BUFFER;
@@ -87,7 +87,7 @@
87
87
  } catch (e) {}
88
88
  }
89
89
  },
90
- 617: (module) => {
90
+ 656: (module) => {
91
91
  "use strict";
92
92
  const BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
93
93
  const hasBlob = typeof Blob !== "undefined";
@@ -104,9 +104,9 @@
104
104
  NOOP: () => {},
105
105
  };
106
106
  },
107
- 504: (module, __unused_webpack_exports, __nccwpck_require__) => {
107
+ 24: (module, __unused_webpack_exports, __nccwpck_require__) => {
108
108
  "use strict";
109
- const { kForOnEventAttribute, kListener } = __nccwpck_require__(617);
109
+ const { kForOnEventAttribute, kListener } = __nccwpck_require__(656);
110
110
  const kCode = Symbol("kCode");
111
111
  const kData = Symbol("kData");
112
112
  const kError = Symbol("kError");
@@ -268,9 +268,9 @@
268
268
  }
269
269
  }
270
270
  },
271
- 881: (module, __unused_webpack_exports, __nccwpck_require__) => {
271
+ 992: (module, __unused_webpack_exports, __nccwpck_require__) => {
272
272
  "use strict";
273
- const { tokenChars } = __nccwpck_require__(521);
273
+ const { tokenChars } = __nccwpck_require__(674);
274
274
  function push(dest, name, elem) {
275
275
  if (dest[name] === undefined) dest[name] = [elem];
276
276
  else dest[name].push(elem);
@@ -426,7 +426,7 @@
426
426
  }
427
427
  module.exports = { format, parse };
428
428
  },
429
- 36: (module) => {
429
+ 13: (module) => {
430
430
  "use strict";
431
431
  const kDone = Symbol("kDone");
432
432
  const kRun = Symbol("kRun");
@@ -455,12 +455,12 @@
455
455
  }
456
456
  module.exports = Limiter;
457
457
  },
458
- 58: (module, __unused_webpack_exports, __nccwpck_require__) => {
458
+ 245: (module, __unused_webpack_exports, __nccwpck_require__) => {
459
459
  "use strict";
460
460
  const zlib = __nccwpck_require__(106);
461
- const bufferUtil = __nccwpck_require__(845);
462
- const Limiter = __nccwpck_require__(36);
463
- const { kStatusCode } = __nccwpck_require__(617);
461
+ const bufferUtil = __nccwpck_require__(468);
462
+ const Limiter = __nccwpck_require__(13);
463
+ const { kStatusCode } = __nccwpck_require__(656);
464
464
  const FastBuffer = Buffer[Symbol.species];
465
465
  const TRAILER = Buffer.from([0, 0, 255, 255]);
466
466
  const kPerMessageDeflate = Symbol("permessage-deflate");
@@ -776,18 +776,22 @@
776
776
  }
777
777
  function inflateOnError(err) {
778
778
  this[kPerMessageDeflate]._inflate = null;
779
+ if (this[kError]) {
780
+ this[kCallback](this[kError]);
781
+ return;
782
+ }
779
783
  err[kStatusCode] = 1007;
780
784
  this[kCallback](err);
781
785
  }
782
786
  },
783
- 443: (module, __unused_webpack_exports, __nccwpck_require__) => {
787
+ 196: (module, __unused_webpack_exports, __nccwpck_require__) => {
784
788
  "use strict";
785
789
  const { Writable } = __nccwpck_require__(203);
786
- const PerMessageDeflate = __nccwpck_require__(58);
790
+ const PerMessageDeflate = __nccwpck_require__(245);
787
791
  const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } =
788
- __nccwpck_require__(617);
789
- const { concat, toArrayBuffer, unmask } = __nccwpck_require__(845);
790
- const { isValidStatusCode, isValidUTF8 } = __nccwpck_require__(521);
792
+ __nccwpck_require__(656);
793
+ const { concat, toArrayBuffer, unmask } = __nccwpck_require__(468);
794
+ const { isValidStatusCode, isValidUTF8 } = __nccwpck_require__(674);
791
795
  const FastBuffer = Buffer[Symbol.species];
792
796
  const GET_INFO = 0;
793
797
  const GET_PAYLOAD_LENGTH_16 = 1;
@@ -1284,14 +1288,14 @@
1284
1288
  }
1285
1289
  module.exports = Receiver;
1286
1290
  },
1287
- 799: (module, __unused_webpack_exports, __nccwpck_require__) => {
1291
+ 780: (module, __unused_webpack_exports, __nccwpck_require__) => {
1288
1292
  "use strict";
1289
1293
  const { Duplex } = __nccwpck_require__(203);
1290
1294
  const { randomFillSync } = __nccwpck_require__(982);
1291
- const PerMessageDeflate = __nccwpck_require__(58);
1292
- const { EMPTY_BUFFER, kWebSocket, NOOP } = __nccwpck_require__(617);
1293
- const { isBlob, isValidStatusCode } = __nccwpck_require__(521);
1294
- const { mask: applyMask, toBuffer } = __nccwpck_require__(845);
1295
+ const PerMessageDeflate = __nccwpck_require__(245);
1296
+ const { EMPTY_BUFFER, kWebSocket, NOOP } = __nccwpck_require__(656);
1297
+ const { isBlob, isValidStatusCode } = __nccwpck_require__(674);
1298
+ const { mask: applyMask, toBuffer } = __nccwpck_require__(468);
1295
1299
  const kByteLength = Symbol("kByteLength");
1296
1300
  const maskBuffer = Buffer.alloc(4);
1297
1301
  const RANDOM_POOL_SIZE = 8 * 1024;
@@ -1660,9 +1664,9 @@
1660
1664
  sender.onerror(err);
1661
1665
  }
1662
1666
  },
1663
- 410: (module, __unused_webpack_exports, __nccwpck_require__) => {
1667
+ 605: (module, __unused_webpack_exports, __nccwpck_require__) => {
1664
1668
  "use strict";
1665
- const WebSocket = __nccwpck_require__(939);
1669
+ const WebSocket = __nccwpck_require__(590);
1666
1670
  const { Duplex } = __nccwpck_require__(203);
1667
1671
  function emitClose(stream) {
1668
1672
  stream.emit("close");
@@ -1757,9 +1761,9 @@
1757
1761
  }
1758
1762
  module.exports = createWebSocketStream;
1759
1763
  },
1760
- 474: (module, __unused_webpack_exports, __nccwpck_require__) => {
1764
+ 907: (module, __unused_webpack_exports, __nccwpck_require__) => {
1761
1765
  "use strict";
1762
- const { tokenChars } = __nccwpck_require__(521);
1766
+ const { tokenChars } = __nccwpck_require__(674);
1763
1767
  function parse(header) {
1764
1768
  const protocols = new Set();
1765
1769
  let start = -1;
@@ -1800,10 +1804,10 @@
1800
1804
  }
1801
1805
  module.exports = { parse };
1802
1806
  },
1803
- 521: (module, __unused_webpack_exports, __nccwpck_require__) => {
1807
+ 674: (module, __unused_webpack_exports, __nccwpck_require__) => {
1804
1808
  "use strict";
1805
1809
  const { isUtf8 } = __nccwpck_require__(181);
1806
- const { hasBlob } = __nccwpck_require__(617);
1810
+ const { hasBlob } = __nccwpck_require__(656);
1807
1811
  const tokenChars = [
1808
1812
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1809
1813
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
@@ -1897,17 +1901,17 @@
1897
1901
  } catch (e) {}
1898
1902
  }
1899
1903
  },
1900
- 599: (module, __unused_webpack_exports, __nccwpck_require__) => {
1904
+ 920: (module, __unused_webpack_exports, __nccwpck_require__) => {
1901
1905
  "use strict";
1902
1906
  const EventEmitter = __nccwpck_require__(434);
1903
1907
  const http = __nccwpck_require__(611);
1904
1908
  const { Duplex } = __nccwpck_require__(203);
1905
1909
  const { createHash } = __nccwpck_require__(982);
1906
- const extension = __nccwpck_require__(881);
1907
- const PerMessageDeflate = __nccwpck_require__(58);
1908
- const subprotocol = __nccwpck_require__(474);
1909
- const WebSocket = __nccwpck_require__(939);
1910
- const { GUID, kWebSocket } = __nccwpck_require__(617);
1910
+ const extension = __nccwpck_require__(992);
1911
+ const PerMessageDeflate = __nccwpck_require__(245);
1912
+ const subprotocol = __nccwpck_require__(907);
1913
+ const WebSocket = __nccwpck_require__(590);
1914
+ const { GUID, kWebSocket } = __nccwpck_require__(656);
1911
1915
  const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
1912
1916
  const RUNNING = 0;
1913
1917
  const CLOSING = 1;
@@ -2263,7 +2267,7 @@
2263
2267
  }
2264
2268
  }
2265
2269
  },
2266
- 939: (module, __unused_webpack_exports, __nccwpck_require__) => {
2270
+ 590: (module, __unused_webpack_exports, __nccwpck_require__) => {
2267
2271
  "use strict";
2268
2272
  const EventEmitter = __nccwpck_require__(434);
2269
2273
  const https = __nccwpck_require__(692);
@@ -2273,10 +2277,10 @@
2273
2277
  const { randomBytes, createHash } = __nccwpck_require__(982);
2274
2278
  const { Duplex, Readable } = __nccwpck_require__(203);
2275
2279
  const { URL } = __nccwpck_require__(16);
2276
- const PerMessageDeflate = __nccwpck_require__(58);
2277
- const Receiver = __nccwpck_require__(443);
2278
- const Sender = __nccwpck_require__(799);
2279
- const { isBlob } = __nccwpck_require__(521);
2280
+ const PerMessageDeflate = __nccwpck_require__(245);
2281
+ const Receiver = __nccwpck_require__(196);
2282
+ const Sender = __nccwpck_require__(780);
2283
+ const { isBlob } = __nccwpck_require__(674);
2280
2284
  const {
2281
2285
  BINARY_TYPES,
2282
2286
  EMPTY_BUFFER,
@@ -2286,12 +2290,12 @@
2286
2290
  kStatusCode,
2287
2291
  kWebSocket,
2288
2292
  NOOP,
2289
- } = __nccwpck_require__(617);
2293
+ } = __nccwpck_require__(656);
2290
2294
  const {
2291
2295
  EventTarget: { addEventListener, removeEventListener },
2292
- } = __nccwpck_require__(504);
2293
- const { format, parse } = __nccwpck_require__(881);
2294
- const { toBuffer } = __nccwpck_require__(845);
2296
+ } = __nccwpck_require__(24);
2297
+ const { format, parse } = __nccwpck_require__(992);
2298
+ const { toBuffer } = __nccwpck_require__(468);
2295
2299
  const closeTimeout = 30 * 1e3;
2296
2300
  const kAborted = Symbol("kAborted");
2297
2301
  const protocolVersions = [8, 13];
@@ -2673,7 +2677,7 @@
2673
2677
  if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
2674
2678
  invalidUrlMessage =
2675
2679
  'The URL\'s protocol must be one of "ws:", "wss:", ' +
2676
- '"http:", "https", or "ws+unix:"';
2680
+ '"http:", "https:", or "ws+unix:"';
2677
2681
  } else if (isIpcUrl && !parsedUrl.pathname) {
2678
2682
  invalidUrlMessage = "The URL's pathname is empty";
2679
2683
  } else if (parsedUrl.hash) {
@@ -3149,6 +3153,6 @@
3149
3153
  }
3150
3154
  if (typeof __nccwpck_require__ !== "undefined")
3151
3155
  __nccwpck_require__.ab = __dirname + "/";
3152
- var __webpack_exports__ = __nccwpck_require__(584);
3156
+ var __webpack_exports__ = __nccwpck_require__(777);
3153
3157
  module.exports = __webpack_exports__;
3154
3158
  })();
@@ -1 +1 @@
1
- {"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.18.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.18.2","license":"MIT","types":"index.d.ts","type":"commonjs"}
package/dist/index.cjs CHANGED
@@ -2251,14 +2251,14 @@ for(var __webpack_i__ in (()=>{
2251
2251
  };
2252
2252
  context.environments[name] = new Proxy(environmentContext, {
2253
2253
  get: (target, prop)=>target[prop],
2254
- set: (_, prop)=>(rslog_index_js_namespaceObject.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
2254
+ set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : rslog_index_js_namespaceObject.logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
2255
2255
  });
2256
2256
  }
2257
2257
  }
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.14",
2261
+ version: "1.3.16",
2262
2262
  rootPath,
2263
2263
  distPath: '',
2264
2264
  cachePath,
@@ -2277,6 +2277,7 @@ for(var __webpack_i__ in (()=>{
2277
2277
  onBeforeStartProdServer: createAsyncHook(),
2278
2278
  onAfterCreateCompiler: createAsyncHook(),
2279
2279
  onBeforeCreateCompiler: createAsyncHook(),
2280
+ modifyHTML: createEnvironmentAsyncHook(),
2280
2281
  modifyHTMLTags: createEnvironmentAsyncHook(),
2281
2282
  modifyRspackConfig: createEnvironmentAsyncHook(),
2282
2283
  modifyBundlerChain: createEnvironmentAsyncHook(),
@@ -2565,15 +2566,14 @@ for(var __webpack_i__ in (()=>{
2565
2566
  ]), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.infrastructureLogging({
2566
2567
  level: 'error'
2567
2568
  }), chain.watchOptions({
2568
- ignored: /[\\/](?:\.git|node_modules)[\\/]/,
2569
2569
  aggregateTimeout: 0
2570
2570
  }), chain.performance.hints(!1), chain.module.parser.merge({
2571
2571
  javascript: {
2572
2572
  exportsPresence: 'error'
2573
2573
  }
2574
- }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20', process.env.EXPERIMENTAL_RSPACK_INCREMENTAL && chain.experiments({
2574
+ }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20', 'rspack' === api.context.bundlerType && chain.experiments({
2575
2575
  ...chain.get('experiments'),
2576
- incremental: isDev
2576
+ incremental: !0
2577
2577
  });
2578
2578
  });
2579
2579
  }
@@ -3111,28 +3111,28 @@ for(var __webpack_i__ in (()=>{
3111
3111
  showGzipHeader && rowTypes.push('Gzip');
3112
3112
  let headerRow = rowTypes.reduce((prev, cur, index)=>{
3113
3113
  let length = lengths[index], curLabel = cur;
3114
- return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
3115
- }, ' ');
3114
+ return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
3115
+ }, '');
3116
3116
  return index_js_default().blue(headerRow);
3117
3117
  }(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
3118
3118
  let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
3119
3119
  sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
3120
3120
  let fileNameLabel = index_js_default().dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
3121
3121
  fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
3122
- let log = ` ${fileNameLabel} ${sizeLabel}`;
3123
- gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3122
+ let log = `${fileNameLabel} ${sizeLabel}`;
3123
+ gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3124
3124
  }
3125
3125
  if (showTotal) {
3126
3126
  logs.push('');
3127
- let log = ' ';
3128
- if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
3127
+ let log = '';
3128
+ if (log += ' '.repeat(maxFileLength - totalSizeLabel.length), log += index_js_default().magenta(totalSizeLabel), log += ` ${totalSizeStr}`, options.compressed) {
3129
3129
  let colorFn = getAssetColor(totalGzipSize / assets.length);
3130
- log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
3130
+ log += ' '.repeat(maxSizeLength - totalSizeStr.length), log += ` ${colorFn(calcFileSize(totalGzipSize))}`;
3131
3131
  }
3132
3132
  logs.push(log);
3133
3133
  }
3134
3134
  } else if (showTotal) {
3135
- let log = ` ${index_js_default().magenta(totalSizeLabel)} ${totalSizeStr}`;
3135
+ let log = `${index_js_default().magenta(totalSizeLabel)} ${totalSizeStr}`;
3136
3136
  options.compressed && (log += index_js_default().green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
3137
3137
  }
3138
3138
  return logs.push(''), logs;
@@ -3156,7 +3156,7 @@ for(var __webpack_i__ in (()=>{
3156
3156
  ...defaultConfig,
3157
3157
  ...printFileSize
3158
3158
  }, statsLogs = await printFileSizes(mergedConfig, multiStats[index], api.context.rootPath, environment.name);
3159
- logs.length && logs.push(index_js_default().dim(' -----')), logs.push(...statsLogs);
3159
+ logs.push(...statsLogs);
3160
3160
  })).catch((err)=>{
3161
3161
  rslog_index_js_namespaceObject.logger.warn('Failed to print file size.'), rslog_index_js_namespaceObject.logger.warn(err);
3162
3162
  }), rslog_index_js_namespaceObject.logger.log(logs.join('\n'));
@@ -3299,7 +3299,8 @@ for(var __webpack_i__ in (()=>{
3299
3299
  href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
3300
3300
  };
3301
3301
  compiler.hooks.compilation.tap(this.name, (compilation)=>{
3302
- getHTMLPlugin().getCompilationHooks(compilation).alterAssetTagGroups.tapPromise(this.name, async (data)=>{
3302
+ let hooks = getHTMLPlugin().getCompilationHooks(compilation);
3303
+ hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
3303
3304
  var _data_plugin_options, _data_plugin_options1;
3304
3305
  let entryName = null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.entryName;
3305
3306
  if (!entryName) return data;
@@ -3308,22 +3309,45 @@ for(var __webpack_i__ in (()=>{
3308
3309
  let tags = {
3309
3310
  headTags: headTags.map(formatBasicTag),
3310
3311
  bodyTags: bodyTags.map(formatBasicTag)
3311
- }, modified = this.modifyTagsFn ? await this.modifyTagsFn(tags, {
3312
- compiler,
3313
- compilation,
3314
- assetPrefix: data.publicPath,
3315
- filename: data.outputName,
3316
- environment: this.getEnvironment()
3317
- }) : tags;
3312
+ }, context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTMLTags.callChain({
3313
+ environment: environment.name,
3314
+ args: [
3315
+ tags,
3316
+ {
3317
+ compiler,
3318
+ compilation,
3319
+ assetPrefix: data.publicPath,
3320
+ filename: data.outputName,
3321
+ environment
3322
+ }
3323
+ ]
3324
+ });
3318
3325
  return Object.assign(data, {
3319
3326
  headTags: modified.headTags.map(fromBasicTag),
3320
3327
  bodyTags: modified.bodyTags.map(fromBasicTag)
3321
3328
  }), tagConfig && applyTagConfig(data, tagConfig, compilation.hash ?? '', entryName), data;
3329
+ }), hooks.beforeEmit.tapPromise(this.name, async (data)=>{
3330
+ let context = this.getContext(), environment = this.getEnvironment(), [modified] = await context.hooks.modifyHTML.callChain({
3331
+ environment: environment.name,
3332
+ args: [
3333
+ data.html,
3334
+ {
3335
+ compiler,
3336
+ compilation,
3337
+ filename: data.outputName,
3338
+ environment
3339
+ }
3340
+ ]
3341
+ });
3342
+ return {
3343
+ ...data,
3344
+ html: modified
3345
+ };
3322
3346
  });
3323
3347
  });
3324
3348
  }
3325
- constructor(options, getEnvironment, modifyTagsFn){
3326
- RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "modifyTagsFn", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.modifyTagsFn = modifyTagsFn, this.getEnvironment = getEnvironment;
3349
+ constructor(options, getEnvironment, getContext){
3350
+ RsbuildHtmlPlugin_define_property(this, "name", void 0), RsbuildHtmlPlugin_define_property(this, "getEnvironment", void 0), RsbuildHtmlPlugin_define_property(this, "options", void 0), RsbuildHtmlPlugin_define_property(this, "getContext", void 0), this.name = 'RsbuildHtmlPlugin', this.options = options, this.getEnvironment = getEnvironment, this.getContext = getContext;
3327
3351
  }
3328
3352
  }
3329
3353
  let getDefaultTemplateContent = (mountId)=>`<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`, existTemplatePath = new Set();
@@ -3358,7 +3382,7 @@ for(var __webpack_i__ in (()=>{
3358
3382
  publicPath: !0,
3359
3383
  tags
3360
3384
  };
3361
- }, pluginHtml = (modifyTagsFn)=>({
3385
+ }, pluginHtml = (context)=>({
3362
3386
  name: 'rsbuild:html',
3363
3387
  setup (api) {
3364
3388
  api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID, environment })=>{
@@ -3458,7 +3482,7 @@ for(var __webpack_i__ in (()=>{
3458
3482
  }), chain.plugin('rsbuild-html-plugin').use(RsbuildHtmlPlugin, [
3459
3483
  htmlInfoMap,
3460
3484
  ()=>environment,
3461
- null == modifyTagsFn ? void 0 : modifyTagsFn(environment.name)
3485
+ ()=>context
3462
3486
  ]), config.html) {
3463
3487
  let { crossorigin } = config.html;
3464
3488
  crossorigin && chain.output.crossOriginLoading(!0 === crossorigin ? 'anonymous' : crossorigin);
@@ -3585,7 +3609,7 @@ for(var __webpack_i__ in (()=>{
3585
3609
  })(chunkGroup)).filter((name)=>!!name))
3586
3610
  ];
3587
3611
  }
3588
- let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
3612
+ let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)=>{
3589
3613
  let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
3590
3614
  if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
3591
3615
  file,
@@ -3631,13 +3655,14 @@ for(var __webpack_i__ in (()=>{
3631
3655
  files,
3632
3656
  manifestData
3633
3657
  });
3634
- if (isObject(generatedManifest)) return generatedManifest;
3658
+ if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
3635
3659
  throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
3636
3660
  }
3637
- return manifestData;
3661
+ return environment.manifest = manifestData, manifestData;
3638
3662
  }, pluginManifest = ()=>({
3639
3663
  name: 'rsbuild:manifest',
3640
3664
  setup (api) {
3665
+ let manifestFilenames = new Map();
3641
3666
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
3642
3667
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
3643
3668
  if (!1 === manifest) return;
@@ -3653,14 +3678,18 @@ for(var __webpack_i__ in (()=>{
3653
3678
  ...manifest
3654
3679
  };
3655
3680
  }(manifest), { RspackManifestPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rspack-manifest-plugin/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
3656
- chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
3681
+ manifestFilenames.set(environment.name, manifestOptions.filename), chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
3657
3682
  {
3658
3683
  fileName: manifestOptions.filename,
3659
3684
  filter,
3660
3685
  writeToFileEmit: isDev && !0 !== writeToDisk,
3661
- generate: generateManifest(htmlPaths, manifestOptions)
3686
+ generate: generateManifest(htmlPaths, manifestOptions, environment)
3662
3687
  }
3663
3688
  ]);
3689
+ }), api.onAfterCreateCompiler(()=>{
3690
+ if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
3691
+ let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
3692
+ new Set(filenames).size !== filenames.length && rslog_index_js_namespaceObject.logger.warn(`[rsbuild:manifest] The \`manifest.filename\` option must be unique when there are multiple environments (${environmentNames.join(', ')}), otherwise the manifest file will be overwritten.`), manifestFilenames.clear();
3664
3693
  });
3665
3694
  }
3666
3695
  });
@@ -3822,13 +3851,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3822
3851
  if (routes.length <= 1) {
3823
3852
  let pathname = routes.length ? routes[0].pathname : '';
3824
3853
  return urls.map(({ label, url })=>{
3825
- let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `➜ ${index_js_default().dim(label.padEnd(10))}`;
3854
+ let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${index_js_default().dim(label.padEnd(10))}`;
3826
3855
  return ` ${prefix}${index_js_default().cyan(normalizedPathname)}\n`;
3827
3856
  }).join('');
3828
3857
  }
3829
3858
  let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
3830
3859
  return urls.forEach(({ label, url }, index)=>{
3831
- for (let r of (index > 0 && (message += '\n'), message += ` ${label}\n`, routes))message += ` ${index_js_default().dim('-')} ${index_js_default().dim(r.entryName.padEnd(maxNameLength + 4))}${index_js_default().cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
3860
+ for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${index_js_default().dim('-')} ${index_js_default().dim(r.entryName.padEnd(maxNameLength + 4))}${index_js_default().cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
3832
3861
  }), message;
3833
3862
  }(urls, routes);
3834
3863
  return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), rslog_index_js_namespaceObject.logger.log(message), message;
@@ -4378,7 +4407,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4378
4407
  if ('webpack' === api.context.bundlerType) return;
4379
4408
  let RSPACK_PROFILE = null == (_process_env_RSPACK_PROFILE = process.env.RSPACK_PROFILE) ? void 0 : _process_env_RSPACK_PROFILE.toUpperCase();
4380
4409
  if (!RSPACK_PROFILE) return;
4381
- let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), enableLogging = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('LOGGING'), onStart = async ()=>{
4410
+ let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), onStart = async ()=>{
4382
4411
  let profileDir = external_node_path_default().join(api.context.distPath, profileDirName), traceFilePath = external_node_path_default().join(profileDir, 'trace.json');
4383
4412
  await isFileExists(profileDir) || await external_node_fs_default().promises.mkdir(profileDir, {
4384
4413
  recursive: !0
@@ -4386,17 +4415,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4386
4415
  };
4387
4416
  api.onBeforeBuild(({ isFirstCompile })=>{
4388
4417
  isFirstCompile && onStart();
4389
- }), api.onBeforeStartDevServer(onStart), api.onAfterBuild(async ({ stats })=>{
4390
- let loggingFilePath = external_node_path_default().join(api.context.distPath, profileDirName, 'logging.json');
4391
- if (enableLogging && stats) {
4392
- let logging = stats.toJson({
4393
- all: !1,
4394
- logging: 'verbose',
4395
- loggingTrace: !0
4396
- });
4397
- await external_node_fs_default().promises.writeFile(loggingFilePath, JSON.stringify(logging));
4398
- }
4399
- }), api.onExit(()=>{
4418
+ }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
4400
4419
  enableProfileTrace && core_default().experiments.globalTrace.cleanup();
4401
4420
  let profileDir = external_node_path_default().join(api.context.distPath, profileDirName);
4402
4421
  stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`profile files saved to ${index_js_default().cyan(profileDir)}`);
@@ -5210,7 +5229,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5210
5229
  }
5211
5230
  ].filter(Boolean);
5212
5231
  if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5213
- help && rslog_index_js_namespaceObject.logger.log(` ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
5232
+ help && rslog_index_js_namespaceObject.logger.log(` \u{279C} ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
5214
5233
  let rl = external_node_readline_default().createInterface({
5215
5234
  input: process.stdin
5216
5235
  });
@@ -5318,14 +5337,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5318
5337
  29,
5319
5338
  39,
5320
5339
  49
5321
- ], server_ansiHTML = function(text) {
5322
- let ansiCodes = [], ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
5323
- let style = '';
5324
- for (let seq of sequences.split(';'))styles[seq] && (style += `${styles[seq]};`);
5325
- return style ? (ansiCodes.push(sequences), `<span style="${style}">`) : closeCode.includes(Number(sequences)) && ansiCodes.length > 0 ? (ansiCodes.pop(), '</span>') : '';
5326
- });
5327
- return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
5328
- };
5340
+ ];
5329
5341
  function socketServer_define_property(obj, key, value) {
5330
5342
  return key in obj ? Object.defineProperty(obj, key, {
5331
5343
  value: value,
@@ -5453,7 +5465,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5453
5465
  text: formattedErrors,
5454
5466
  html: function(errors, root) {
5455
5467
  let htmlItems = errors.map((item)=>{
5456
- var text, text1 = server_ansiHTML((text = item) ? text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;') : ''), root1 = root;
5468
+ var text, text1 = function(text) {
5469
+ let ansiCodes = [], ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
5470
+ let style = '';
5471
+ for (let seq of sequences.split(';'))styles[seq] && (style += `${styles[seq]};`);
5472
+ return style ? (ansiCodes.push(sequences), `<span style="${style}">`) : closeCode.includes(Number(sequences)) && ansiCodes.length > 0 ? (ansiCodes.pop(), '</span>') : '';
5473
+ });
5474
+ return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
5475
+ }((text = item) ? text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;') : ''), root1 = root;
5457
5476
  let pathRegex = /(?:\.\.?[\/\\]|[a-zA-Z]:\\|\/)[^:]*:\d+:\d+/g, urlRegex = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi;
5458
5477
  return text1.split('\n').map((line)=>{
5459
5478
  let replacedLine = line.replace(pathRegex, (file)=>{
@@ -6741,10 +6760,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6741
6760
  pluginFileSize(),
6742
6761
  pluginCleanOutput(),
6743
6762
  pluginAsset(),
6744
- pluginHtml((environment)=>async (...args)=>(await context.hooks.modifyHTMLTags.callChain({
6745
- environment,
6746
- args
6747
- }))[0]),
6763
+ pluginHtml(context),
6748
6764
  pluginAppIcon(),
6749
6765
  pluginWasm(),
6750
6766
  pluginMoment(),
@@ -6995,14 +7011,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6995
7011
  }
6996
7012
  });
6997
7013
  });
6998
- let getTransformFn = (environment)=>(descriptor, handler)=>{
7014
+ let getTransformHook = (environment)=>(descriptor, handler)=>{
6999
7015
  let id = `rsbuild-transform-${transformId++}`;
7000
7016
  transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
7001
7017
  environment,
7002
7018
  handler: (chain, { target, environment })=>{
7003
7019
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
7004
7020
  let rule = chain.module.rule(id);
7005
- descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with);
7021
+ descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.enforce && rule.enforce(descriptor.enforce);
7006
7022
  let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0, external_node_path_namespaceObject.join)(LOADER_PATH, loaderName);
7007
7023
  rule.use(id).loader(loaderPath).options({
7008
7024
  id,
@@ -7041,7 +7057,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7041
7057
  return (environment)=>({
7042
7058
  context: publicContext,
7043
7059
  expose,
7044
- transform: getTransformFn(environment),
7060
+ transform: getTransformHook(environment),
7045
7061
  useExposed,
7046
7062
  processAssets: setProcessAssets(environment),
7047
7063
  resolve: setResolve(environment),
@@ -7061,6 +7077,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7061
7077
  onAfterStartProdServer: hooks.onAfterStartProdServer.tap,
7062
7078
  onBeforeStartProdServer: hooks.onBeforeStartProdServer.tap,
7063
7079
  modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
7080
+ modifyHTML: (handler)=>hooks.modifyHTML.tapEnvironment({
7081
+ environment,
7082
+ handler
7083
+ }),
7064
7084
  modifyHTMLTags: (handler)=>hooks.modifyHTMLTags.tapEnvironment({
7065
7085
  environment,
7066
7086
  handler
@@ -7507,11 +7527,11 @@ ${section.body}` : section.body).join("\n\n"));
7507
7527
  }
7508
7528
  process.title = 'rsbuild-node';
7509
7529
  let { npm_execpath } = process.env;
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`);
7530
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.16\n`);
7511
7531
  try {
7512
7532
  !function() {
7513
7533
  let cli = cac_dist('rsbuild');
7514
- cli.help(), cli.version("1.3.14"), applyCommonOptions(cli);
7534
+ cli.help(), cli.version("1.3.16"), applyCommonOptions(cli);
7515
7535
  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');
7516
7536
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7517
7537
  try {
@@ -7562,7 +7582,7 @@ ${section.body}` : section.body).join("\n\n"));
7562
7582
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7563
7583
  }
7564
7584
  }
7565
- let src_version = "1.3.14";
7585
+ let src_version = "1.3.16";
7566
7586
  })(), 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 === [
7567
7587
  "PLUGIN_CSS_NAME",
7568
7588
  "PLUGIN_SWC_NAME",