@rsbuild/core 0.7.8 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -122,7 +122,7 @@ var init_format = __esm({
122
122
 
123
123
  // src/constants.ts
124
124
  import { join } from "path";
125
- var ROOT_DIST_DIR, HTML_DIST_DIR, SERVER_DIST_DIR, SERVICE_WORKER_DIST_DIR, JS_DIST_DIR, CSS_DIST_DIR, SVG_DIST_DIR, FONT_DIST_DIR, WASM_DIST_DIR, IMAGE_DIST_DIR, MEDIA_DIST_DIR, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, DEFAULT_PORT, DEFAULT_DATA_URL_SIZE, DEFAULT_MOUNT_ID, DEFAULT_DEV_HOST, HTML_REGEX, CSS_REGEX, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, FONT_EXTENSIONS, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS;
125
+ var ROOT_DIST_DIR, HTML_DIST_DIR, SERVER_DIST_DIR, SERVICE_WORKER_DIST_DIR, JS_DIST_DIR, CSS_DIST_DIR, SVG_DIST_DIR, FONT_DIST_DIR, WASM_DIST_DIR, IMAGE_DIST_DIR, MEDIA_DIST_DIR, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, DEFAULT_PORT, DEFAULT_DATA_URL_SIZE, DEFAULT_MOUNT_ID, DEFAULT_DEV_HOST, HTML_REGEX, CSS_REGEX, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, FONT_EXTENSIONS, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS, TARGET_ID_MAP;
126
126
  var init_constants = __esm({
127
127
  "src/constants.ts"() {
128
128
  "use strict";
@@ -169,6 +169,49 @@ var init_constants = __esm({
169
169
  ];
170
170
  VIDEO_EXTENSIONS = ["mp4", "webm", "ogg", "mov"];
171
171
  AUDIO_EXTENSIONS = ["mp3", "wav", "flac", "aac", "m4a", "opus"];
172
+ TARGET_ID_MAP = {
173
+ web: "Client",
174
+ node: "Server",
175
+ "web-worker": "Web Worker",
176
+ "service-worker": "Service Worker"
177
+ };
178
+ }
179
+ });
180
+
181
+ // src/logger.ts
182
+ import { color } from "@rsbuild/shared";
183
+ import { logger } from "../compiled/rslog/index.js";
184
+ function getTime() {
185
+ const now = /* @__PURE__ */ new Date();
186
+ const hours = String(now.getHours()).padStart(2, "0");
187
+ const minutes = String(now.getMinutes()).padStart(2, "0");
188
+ const seconds = String(now.getSeconds()).padStart(2, "0");
189
+ return `${hours}:${minutes}:${seconds}`;
190
+ }
191
+ var isDebug;
192
+ var init_logger = __esm({
193
+ "src/logger.ts"() {
194
+ "use strict";
195
+ init_esm();
196
+ isDebug = () => {
197
+ if (!process.env.DEBUG) {
198
+ return false;
199
+ }
200
+ const values = process.env.DEBUG.toLocaleLowerCase().split(",");
201
+ return ["rsbuild", "builder", "*"].some((key) => values.includes(key));
202
+ };
203
+ if (isDebug()) {
204
+ logger.level = "verbose";
205
+ }
206
+ logger.override({
207
+ debug: (message, ...args) => {
208
+ if (logger.level !== "verbose") {
209
+ return;
210
+ }
211
+ const time = color.gray(`${getTime()}`);
212
+ console.log(` ${color.magenta("rsbuild")} ${time} ${message}`, ...args);
213
+ }
214
+ });
172
215
  }
173
216
  });
174
217
 
@@ -176,12 +219,9 @@ var init_constants = __esm({
176
219
  import path2, { posix } from "path";
177
220
  import {
178
221
  DEFAULT_ASSET_PREFIX,
179
- addTrailingSlash,
180
- color,
181
- isDebug,
182
- isMultiCompiler,
183
- isProd,
184
- removeTailingSlash
222
+ castArray,
223
+ color as color2,
224
+ isProd
185
225
  } from "@rsbuild/shared";
186
226
  import { fse } from "@rsbuild/shared";
187
227
  function formatErrorMessage(errors) {
@@ -189,14 +229,14 @@ function formatErrorMessage(errors) {
189
229
  const text = `${messages.join("\n\n")}
190
230
  `;
191
231
  const isTerserError = text.includes("from Terser");
192
- const title = color.bold(
193
- color.red(isTerserError ? "Minify error: " : "Compile error: ")
232
+ const title = color2.bold(
233
+ color2.red(isTerserError ? "Minify error: " : "Compile error: ")
194
234
  );
195
235
  if (!errors.length) {
196
236
  return `${title}
197
- ${color.yellow(`For more details, please setting 'stats.errors: true' `)}`;
237
+ ${color2.yellow(`For more details, please setting 'stats.errors: true' `)}`;
198
238
  }
199
- const tip = color.yellow(
239
+ const tip = color2.yellow(
200
240
  isTerserError ? "Failed to minify with terser, check for syntax errors." : "Failed to compile, check the errors for troubleshooting."
201
241
  );
202
242
  return `${title}
@@ -227,7 +267,7 @@ function formatStats(stats, options = {}) {
227
267
  warnings: getAllStatsWarnings(statsData)
228
268
  },
229
269
  // display verbose messages in prod build or debug mode
230
- isProd() || isDebug()
270
+ isProd() || logger.level === "verbose"
231
271
  );
232
272
  if (stats.hasErrors()) {
233
273
  return {
@@ -236,7 +276,7 @@ function formatStats(stats, options = {}) {
236
276
  };
237
277
  }
238
278
  if (warnings.length) {
239
- const title = color.bold(color.yellow("Compile Warning: \n"));
279
+ const title = color2.bold(color2.yellow("Compile Warning: \n"));
240
280
  return {
241
281
  message: `${title}${warnings.join("\n\n")}
242
282
  `,
@@ -252,13 +292,78 @@ function isEmptyDir(path14) {
252
292
  async function isFileExists(file) {
253
293
  return fse.promises.access(file, fse.constants.F_OK).then(() => true).catch(() => false);
254
294
  }
255
- var rspackMinVersion, compareSemver, isSatisfyRspackVersion, getCompiledPath, hintNodePolyfill, getAllStatsErrors, getAllStatsWarnings, formatPublicPath, getPublicPathFromChain, ensureAbsolutePath, isFileSync, findExists, urlJoin, canParse, ensureAssetPrefix;
295
+ function getFilename2(config, type, isProd7) {
296
+ const { filename, filenameHash } = config.output;
297
+ const getHash = () => {
298
+ if (typeof filenameHash === "string") {
299
+ return filenameHash ? `.[${filenameHash}]` : "";
300
+ }
301
+ return filenameHash ? ".[contenthash:8]" : "";
302
+ };
303
+ const hash = getHash();
304
+ switch (type) {
305
+ case "js":
306
+ return filename.js ?? `[name]${isProd7 ? hash : ""}.js`;
307
+ case "css":
308
+ return filename.css ?? `[name]${isProd7 ? hash : ""}.css`;
309
+ case "svg":
310
+ return filename.svg ?? `[name]${hash}.svg`;
311
+ case "font":
312
+ return filename.font ?? `[name]${hash}[ext]`;
313
+ case "image":
314
+ return filename.image ?? `[name]${hash}[ext]`;
315
+ case "media":
316
+ return filename.media ?? `[name]${hash}[ext]`;
317
+ default:
318
+ throw new Error(`unknown key ${type} in "output.filename"`);
319
+ }
320
+ }
321
+ function partition(array, predicate) {
322
+ const truthy = [];
323
+ const falsy = [];
324
+ for (const value of array) {
325
+ if (predicate(value)) {
326
+ truthy.push(value);
327
+ } else {
328
+ falsy.push(value);
329
+ }
330
+ }
331
+ return [truthy, falsy];
332
+ }
333
+ function debounce(func, wait) {
334
+ let timeoutId = null;
335
+ return (...args) => {
336
+ if (timeoutId !== null) {
337
+ clearTimeout(timeoutId);
338
+ }
339
+ timeoutId = setTimeout(() => {
340
+ func(...args);
341
+ }, wait);
342
+ };
343
+ }
344
+ function isWebTarget(target) {
345
+ const targets = castArray(target);
346
+ return targets.includes("web") || target.includes("web-worker");
347
+ }
348
+ function pick(obj, keys) {
349
+ return keys.reduce(
350
+ (ret, key) => {
351
+ if (obj[key] !== void 0) {
352
+ ret[key] = obj[key];
353
+ }
354
+ return ret;
355
+ },
356
+ {}
357
+ );
358
+ }
359
+ var rspackMinVersion, compareSemver, isSatisfyRspackVersion, getCompiledPath, hintNodePolyfill, getAllStatsErrors, getAllStatsWarnings, removeLeadingSlash, removeTailingSlash, addTrailingSlash, formatPublicPath, getPublicPathFromChain, ensureAbsolutePath, isFileSync, findExists, urlJoin, canParse, ensureAssetPrefix, applyToCompiler, upperFirst, isURL, createVirtualModule, isRegExp, isMultiCompiler, onCompileDone;
256
360
  var init_helpers = __esm({
257
361
  "src/helpers.ts"() {
258
362
  "use strict";
259
363
  init_esm();
260
364
  init_format();
261
365
  init_constants();
366
+ init_logger();
262
367
  rspackMinVersion = "0.6.2";
263
368
  compareSemver = (version1, version2) => {
264
369
  const parts1 = version1.split(".").map(Number);
@@ -343,7 +448,7 @@ var init_helpers = __esm({
343
448
  ];
344
449
  return `${message}
345
450
 
346
- ${color.yellow(tips.join("\n"))}`;
451
+ ${color2.yellow(tips.join("\n"))}`;
347
452
  }
348
453
  return message;
349
454
  };
@@ -365,6 +470,9 @@ ${color.yellow(tips.join("\n"))}`;
365
470
  }
366
471
  return statsData.warnings;
367
472
  };
473
+ removeLeadingSlash = (s) => s.replace(/^\/+/, "");
474
+ removeTailingSlash = (s) => s.replace(/\/+$/, "");
475
+ addTrailingSlash = (s) => s.endsWith("/") ? s : `${s}/`;
368
476
  formatPublicPath = (publicPath, withSlash = true) => {
369
477
  if (publicPath === "auto") {
370
478
  return publicPath;
@@ -422,12 +530,56 @@ ${color.yellow(tips.join("\n"))}`;
422
530
  }
423
531
  return posix.join(assetPrefix, url2);
424
532
  };
533
+ applyToCompiler = (compiler, apply) => {
534
+ if (isMultiCompiler(compiler)) {
535
+ compiler.compilers.forEach(apply);
536
+ } else {
537
+ apply(compiler);
538
+ }
539
+ };
540
+ upperFirst = (str) => str ? str.charAt(0).toUpperCase() + str.slice(1) : "";
541
+ isURL = (str) => str.startsWith("http") || str.startsWith("//:");
542
+ createVirtualModule = (content) => `data:text/javascript,${content}`;
543
+ isRegExp = (obj) => Object.prototype.toString.call(obj) === "[object RegExp]";
544
+ isMultiCompiler = (compiler) => {
545
+ return compiler.constructor.name === "MultiCompiler";
546
+ };
547
+ onCompileDone = (compiler, onDone, MultiStatsCtor) => {
548
+ if (isMultiCompiler(compiler)) {
549
+ const { compilers } = compiler;
550
+ const compilerStats = [];
551
+ let doneCompilers = 0;
552
+ for (let index = 0; index < compilers.length; index++) {
553
+ const compiler2 = compilers[index];
554
+ const compilerIndex = index;
555
+ let compilerDone = false;
556
+ compiler2.hooks.done.tapPromise("rsbuild:done", async (stats) => {
557
+ if (!compilerDone) {
558
+ compilerDone = true;
559
+ doneCompilers++;
560
+ }
561
+ compilerStats[compilerIndex] = stats;
562
+ if (doneCompilers === compilers.length) {
563
+ await onDone(new MultiStatsCtor(compilerStats));
564
+ }
565
+ });
566
+ compiler2.hooks.invalid.tap("rsbuild:done", () => {
567
+ if (compilerDone) {
568
+ compilerDone = false;
569
+ doneCompilers--;
570
+ }
571
+ });
572
+ }
573
+ } else {
574
+ compiler.hooks.done.tapPromise("rsbuild:done", onDone);
575
+ }
576
+ };
425
577
  }
426
578
  });
427
579
 
428
580
  // src/mergeConfig.ts
429
581
  import {
430
- castArray,
582
+ castArray as castArray2,
431
583
  isFunction,
432
584
  isPlainObject
433
585
  } from "@rsbuild/shared";
@@ -461,7 +613,7 @@ var init_mergeConfig = __esm({
461
613
  }
462
614
  const pair = [x, y];
463
615
  if (pair.some(Array.isArray)) {
464
- return [...castArray(x), ...castArray(y)];
616
+ return [...castArray2(x), ...castArray2(y)];
465
617
  }
466
618
  if (pair.some(isFunction)) {
467
619
  return pair;
@@ -494,13 +646,14 @@ var init_mergeConfig = __esm({
494
646
 
495
647
  // src/server/restart.ts
496
648
  import path3 from "path";
497
- import { color as color2, logger } from "@rsbuild/shared";
649
+ import { color as color3 } from "@rsbuild/shared";
498
650
  var cleaners, onBeforeRestartServer, clearConsole, restartDevServer;
499
651
  var init_restart = __esm({
500
652
  "src/server/restart.ts"() {
501
653
  "use strict";
502
654
  init_esm();
503
655
  init_init();
656
+ init_logger();
504
657
  cleaners = [];
505
658
  onBeforeRestartServer = (cleaner) => {
506
659
  cleaners.push(cleaner);
@@ -513,7 +666,7 @@ var init_restart = __esm({
513
666
  restartDevServer = async ({ filePath }) => {
514
667
  clearConsole();
515
668
  const filename = path3.basename(filePath);
516
- logger.info(`Restart because ${color2.yellow(filename)} is changed.
669
+ logger.info(`Restart because ${color3.yellow(filename)} is changed.
517
670
  `);
518
671
  for (const cleaner of cleaners) {
519
672
  await cleaner();
@@ -534,13 +687,10 @@ import { isAbsolute, join as join2 } from "path";
534
687
  import {
535
688
  DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX2,
536
689
  RspackChain,
537
- color as color3,
538
- debounce,
690
+ color as color4,
539
691
  fse as fse2,
540
692
  getNodeEnv,
541
- isObject,
542
- logger as logger2,
543
- upperFirst
693
+ isObject
544
694
  } from "@rsbuild/shared";
545
695
  function getDefaultEntry(root) {
546
696
  const files = [
@@ -621,7 +771,7 @@ async function loadConfig({
621
771
  };
622
772
  const result = await configExport(params);
623
773
  if (result === void 0) {
624
- throw new Error("Rsbuild config function must return a config object.");
774
+ throw new Error("The config function must return a config object.");
625
775
  }
626
776
  return {
627
777
  content: applyMetaInfo(result),
@@ -630,7 +780,7 @@ async function loadConfig({
630
780
  }
631
781
  if (!isObject(configExport)) {
632
782
  throw new Error(
633
- `Rsbuild config must be an object or a function that returns an object, get ${color3.yellow(
783
+ `The config must be an object or a function that returns an object, get ${color4.yellow(
634
784
  configExport
635
785
  )}`
636
786
  );
@@ -640,7 +790,7 @@ async function loadConfig({
640
790
  filePath: configFilePath
641
791
  };
642
792
  } catch (err) {
643
- logger2.error(`Failed to load file: ${color3.dim(configFilePath)}`);
793
+ logger.error(`Failed to load file: ${color4.dim(configFilePath)}`);
644
794
  throw err;
645
795
  }
646
796
  }
@@ -678,11 +828,11 @@ async function outputInspectConfigFiles({
678
828
  )
679
829
  );
680
830
  const fileInfos = files.map(
681
- (item) => ` - ${color3.bold(color3.yellow(item.label))}: ${color3.underline(
831
+ (item) => ` - ${color4.bold(color4.yellow(item.label))}: ${color4.underline(
682
832
  item.path
683
833
  )}`
684
834
  ).join("\n");
685
- logger2.success(
835
+ logger.success(
686
836
  `Inspect config succeed, open following files to view the content:
687
837
 
688
838
  ${fileInfos}
@@ -700,6 +850,7 @@ var init_config = __esm({
700
850
  init_esm();
701
851
  init_constants();
702
852
  init_helpers();
853
+ init_logger();
703
854
  init_mergeConfig();
704
855
  init_restart();
705
856
  getDefaultDevConfig = () => ({
@@ -840,7 +991,7 @@ var init_config = __esm({
840
991
  if (fs.existsSync(customConfigPath)) {
841
992
  return customConfigPath;
842
993
  }
843
- logger2.warn(`Cannot find config file: ${color3.dim(customConfigPath)}
994
+ logger.warn(`Cannot find config file: ${color4.dim(customConfigPath)}
844
995
  `);
845
996
  }
846
997
  const CONFIG_FILES = [
@@ -1021,9 +1172,8 @@ __export(entry_exports, {
1021
1172
  pluginEntry: () => pluginEntry
1022
1173
  });
1023
1174
  import {
1024
- castArray as castArray2,
1025
- color as color4,
1026
- createVirtualModule,
1175
+ castArray as castArray3,
1176
+ color as color5,
1027
1177
  reduceConfigsMergeContext
1028
1178
  } from "@rsbuild/shared";
1029
1179
  function getEntryObject(config, target) {
@@ -1041,6 +1191,7 @@ var init_entry = __esm({
1041
1191
  "src/plugins/entry.ts"() {
1042
1192
  "use strict";
1043
1193
  init_esm();
1194
+ init_helpers();
1044
1195
  pluginEntry = () => ({
1045
1196
  name: "rsbuild:entry",
1046
1197
  setup(api) {
@@ -1059,16 +1210,16 @@ var init_entry = __esm({
1059
1210
  if (injectCoreJsEntry) {
1060
1211
  addEntry(createVirtualModule('import "core-js";'));
1061
1212
  }
1062
- castArray2(entry[entryName]).forEach(addEntry);
1213
+ castArray3(entry[entryName]).forEach(addEntry);
1063
1214
  }
1064
1215
  }
1065
1216
  );
1066
1217
  api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
1067
1218
  if (bundlerConfigs.every((config) => !config.entry)) {
1068
1219
  throw new Error(
1069
- `Could not find any entry module, please make sure that ${color4.cyan(
1220
+ `Could not find any entry module, please make sure that ${color5.cyan(
1070
1221
  "src/index.(ts|js|tsx|jsx|mjs|cjs)"
1071
- )} exists, or customize entry through the ${color4.cyan(
1222
+ )} exists, or customize entry through the ${color5.cyan(
1072
1223
  "source.entry"
1073
1224
  )} configuration.`
1074
1225
  );
@@ -1081,15 +1232,11 @@ var init_entry = __esm({
1081
1232
 
1082
1233
  // src/createContext.ts
1083
1234
  import { isAbsolute as isAbsolute2, join as join4 } from "path";
1084
- import {
1085
- getDistPath,
1086
- logger as logger3
1087
- } from "@rsbuild/shared";
1088
1235
  function getAbsolutePath(root, filepath) {
1089
1236
  return isAbsolute2(filepath) ? filepath : join4(root, filepath);
1090
1237
  }
1091
1238
  function getAbsoluteDistPath(cwd, config) {
1092
- const dirRoot = getDistPath(config, "root");
1239
+ const dirRoot = config.output?.distPath?.root ?? ROOT_DIST_DIR;
1093
1240
  return getAbsolutePath(cwd, dirRoot);
1094
1241
  }
1095
1242
  async function createContextByConfig(options, bundlerType, config = {}) {
@@ -1101,7 +1248,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
1101
1248
  return {
1102
1249
  entry: getEntryObject(config, "web"),
1103
1250
  targets: config.output?.targets || [],
1104
- version: "0.7.8",
1251
+ version: "0.7.9",
1105
1252
  rootPath,
1106
1253
  distPath,
1107
1254
  cachePath,
@@ -1143,7 +1290,7 @@ function createPublicContext(context) {
1143
1290
  return void 0;
1144
1291
  },
1145
1292
  set(_, prop) {
1146
- logger3.error(
1293
+ logger.error(
1147
1294
  `Context is readonly, you can not assign to the "context.${prop}" prop.`
1148
1295
  );
1149
1296
  return true;
@@ -1169,21 +1316,18 @@ var init_createContext = __esm({
1169
1316
  "use strict";
1170
1317
  init_esm();
1171
1318
  init_config();
1319
+ init_constants();
1172
1320
  init_initHooks();
1321
+ init_logger();
1173
1322
  init_entry();
1174
1323
  }
1175
1324
  });
1176
1325
 
1177
1326
  // src/initPlugins.ts
1178
1327
  import { join as join5 } from "path";
1179
- import {
1180
- getDistPath as getDistPath2,
1181
- removeLeadingSlash
1182
- } from "@rsbuild/shared";
1183
1328
  function getHTMLPathByEntry(entryName, config) {
1184
- const htmlPath = getDistPath2(config, "html");
1185
1329
  const filename = config.html.outputStructure === "flat" ? `${entryName}.html` : `${entryName}/index.html`;
1186
- return removeLeadingSlash(`${htmlPath}/${filename}`);
1330
+ return removeLeadingSlash(`${config.output.distPath.html}/${filename}`);
1187
1331
  }
1188
1332
  function applyTransformPlugin(chain, transformer) {
1189
1333
  const name = "RsbuildTransformPlugin";
@@ -1306,6 +1450,7 @@ var init_initPlugins = __esm({
1306
1450
  init_esm();
1307
1451
  init_constants();
1308
1452
  init_createContext();
1453
+ init_helpers();
1309
1454
  }
1310
1455
  });
1311
1456
 
@@ -1340,7 +1485,7 @@ var init_pluginHelper = __esm({
1340
1485
  });
1341
1486
 
1342
1487
  // src/pluginManager.ts
1343
- import { color as color5, debug, isFunction as isFunction3, logger as logger4 } from "@rsbuild/shared";
1488
+ import { color as color6, isFunction as isFunction3 } from "@rsbuild/shared";
1344
1489
  function validatePlugin(plugin) {
1345
1490
  const type = typeof plugin;
1346
1491
  if (type !== "object" || plugin === null) {
@@ -1354,12 +1499,12 @@ function validatePlugin(plugin) {
1354
1499
  if (isFunction3(plugin.apply)) {
1355
1500
  const { name = "SomeWebpackPlugin" } = plugin.constructor || {};
1356
1501
  const messages = [
1357
- `${color5.yellow(
1502
+ `${color6.yellow(
1358
1503
  name
1359
- )} looks like a Webpack or Rspack plugin, please use ${color5.yellow(
1504
+ )} looks like a Webpack or Rspack plugin, please use ${color6.yellow(
1360
1505
  "`tools.rspack`"
1361
1506
  )} to register it:`,
1362
- color5.green(`
1507
+ color6.green(`
1363
1508
  // rsbuild.config.ts
1364
1509
  export default {
1365
1510
  tools: {
@@ -1386,13 +1531,13 @@ function createPluginManager() {
1386
1531
  }
1387
1532
  validatePlugin(newPlugin);
1388
1533
  if (plugins.find((item) => item.name === newPlugin.name)) {
1389
- logger4.warn(
1534
+ logger.warn(
1390
1535
  `Rsbuild plugin "${newPlugin.name}" registered multiple times.`
1391
1536
  );
1392
1537
  } else if (before) {
1393
1538
  const index = plugins.findIndex((item) => item.name === before);
1394
1539
  if (index === -1) {
1395
- logger4.warn(`Plugin "${before}" does not exist.`);
1540
+ logger.warn(`Plugin "${before}" does not exist.`);
1396
1541
  plugins.push(newPlugin);
1397
1542
  } else {
1398
1543
  plugins.splice(index, 0, newPlugin);
@@ -1417,7 +1562,7 @@ async function initPlugins({
1417
1562
  pluginAPI,
1418
1563
  pluginManager
1419
1564
  }) {
1420
- debug("init plugins");
1565
+ logger.debug("init plugins");
1421
1566
  const plugins = pluginDagSort(pluginManager.getPlugins());
1422
1567
  const removedPlugins = plugins.reduce((ret, plugin) => {
1423
1568
  if (plugin.remove) {
@@ -1431,13 +1576,14 @@ async function initPlugins({
1431
1576
  }
1432
1577
  await plugin.setup(pluginAPI);
1433
1578
  }
1434
- debug("init plugins done");
1579
+ logger.debug("init plugins done");
1435
1580
  }
1436
1581
  var pluginDagSort;
1437
1582
  var init_pluginManager = __esm({
1438
1583
  "src/pluginManager.ts"() {
1439
1584
  "use strict";
1440
1585
  init_esm();
1586
+ init_logger();
1441
1587
  pluginDagSort = (plugins) => {
1442
1588
  let allLines = [];
1443
1589
  function getPlugin(name) {
@@ -1569,19 +1715,81 @@ var init_inspectConfig = __esm({
1569
1715
  }
1570
1716
  });
1571
1717
 
1718
+ // src/configChain.ts
1719
+ import {
1720
+ RspackChain as RspackChain2,
1721
+ castArray as castArray4,
1722
+ isPlainObject as isPlainObject2
1723
+ } from "@rsbuild/shared";
1724
+ async function getBundlerChain() {
1725
+ const bundlerChain = new RspackChain2();
1726
+ return bundlerChain;
1727
+ }
1728
+ async function modifyBundlerChain(context, utils) {
1729
+ logger.debug("modify bundler chain");
1730
+ const bundlerChain = await getBundlerChain();
1731
+ const [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.call(
1732
+ bundlerChain,
1733
+ utils
1734
+ );
1735
+ if (context.config.tools?.bundlerChain) {
1736
+ for (const item of castArray4(context.config.tools.bundlerChain)) {
1737
+ await item(modifiedBundlerChain, utils);
1738
+ }
1739
+ }
1740
+ logger.debug("modify bundler chain done");
1741
+ return modifiedBundlerChain;
1742
+ }
1743
+ function chainToConfig(chain) {
1744
+ const config = chain.toConfig();
1745
+ const { entry } = config;
1746
+ if (!isPlainObject2(entry)) {
1747
+ return config;
1748
+ }
1749
+ const formattedEntry = {};
1750
+ for (const [entryName, entryValue] of Object.entries(entry)) {
1751
+ const entryImport = [];
1752
+ let entryDescription = null;
1753
+ for (const item of castArray4(entryValue)) {
1754
+ if (typeof item === "string") {
1755
+ entryImport.push(item);
1756
+ continue;
1757
+ }
1758
+ if (item.import) {
1759
+ entryImport.push(...castArray4(item.import));
1760
+ }
1761
+ if (entryDescription) {
1762
+ Object.assign(entryDescription, item);
1763
+ } else {
1764
+ entryDescription = item;
1765
+ }
1766
+ }
1767
+ formattedEntry[entryName] = entryDescription ? {
1768
+ ...entryDescription,
1769
+ import: entryImport
1770
+ } : entryImport;
1771
+ }
1772
+ config.entry = formattedEntry;
1773
+ return config;
1774
+ }
1775
+ var init_configChain = __esm({
1776
+ "src/configChain.ts"() {
1777
+ "use strict";
1778
+ init_esm();
1779
+ init_logger();
1780
+ }
1781
+ });
1782
+
1572
1783
  // src/provider/rspackConfig.ts
1573
1784
  import {
1574
1785
  CHAIN_ID,
1575
- castArray as castArray3,
1576
- chainToConfig,
1577
- debug as debug2,
1786
+ castArray as castArray5,
1578
1787
  getNodeEnv as getNodeEnv4,
1579
- modifyBundlerChain,
1580
1788
  reduceConfigsAsyncWithContext
1581
1789
  } from "@rsbuild/shared";
1582
1790
  import { rspack as rspack2 } from "@rspack/core";
1583
1791
  async function modifyRspackConfig(context, rspackConfig, utils) {
1584
- debug2("modify Rspack config");
1792
+ logger.debug("modify Rspack config");
1585
1793
  let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
1586
1794
  rspackConfig,
1587
1795
  utils
@@ -1594,7 +1802,7 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
1594
1802
  mergeFn: utils.mergeConfig
1595
1803
  });
1596
1804
  }
1597
- debug2("modify Rspack config done");
1805
+ logger.debug("modify Rspack config done");
1598
1806
  return modifiedConfig;
1599
1807
  }
1600
1808
  async function getConfigUtils(config, chainUtils) {
@@ -1604,7 +1812,7 @@ async function getConfigUtils(config, chainUtils) {
1604
1812
  rspack: rspack2,
1605
1813
  mergeConfig: merge2,
1606
1814
  addRules(rules) {
1607
- const ruleArr = castArray3(rules);
1815
+ const ruleArr = castArray5(rules);
1608
1816
  if (!config.module) {
1609
1817
  config.module = {};
1610
1818
  }
@@ -1614,14 +1822,14 @@ async function getConfigUtils(config, chainUtils) {
1614
1822
  config.module.rules.unshift(...ruleArr);
1615
1823
  },
1616
1824
  prependPlugins(plugins) {
1617
- const pluginArr = castArray3(plugins);
1825
+ const pluginArr = castArray5(plugins);
1618
1826
  if (!config.plugins) {
1619
1827
  config.plugins = [];
1620
1828
  }
1621
1829
  config.plugins.unshift(...pluginArr);
1622
1830
  },
1623
1831
  appendPlugins(plugins) {
1624
- const pluginArr = castArray3(plugins);
1832
+ const pluginArr = castArray5(plugins);
1625
1833
  if (!config.plugins) {
1626
1834
  config.plugins = [];
1627
1835
  }
@@ -1684,23 +1892,21 @@ var init_rspackConfig = __esm({
1684
1892
  "src/provider/rspackConfig.ts"() {
1685
1893
  "use strict";
1686
1894
  init_esm();
1895
+ init_configChain();
1896
+ init_logger();
1687
1897
  init_pluginHelper();
1688
1898
  }
1689
1899
  });
1690
1900
 
1691
1901
  // src/provider/initConfigs.ts
1692
- import {
1693
- debug as debug3,
1694
- isDebug as isDebug2
1695
- } from "@rsbuild/shared";
1696
1902
  async function modifyRsbuildConfig(context) {
1697
- debug3("modify Rsbuild config");
1903
+ logger.debug("modify Rsbuild config");
1698
1904
  const [modified] = await context.hooks.modifyRsbuildConfig.call(
1699
1905
  context.config,
1700
1906
  { mergeRsbuildConfig }
1701
1907
  );
1702
1908
  context.config = modified;
1703
- debug3("modify Rsbuild config done");
1909
+ logger.debug("modify Rsbuild config done");
1704
1910
  }
1705
1911
  async function initRsbuildConfig({
1706
1912
  context,
@@ -1728,7 +1934,7 @@ async function initConfigs({
1728
1934
  const rspackConfigs = await Promise.all(
1729
1935
  targets.map((target) => generateRspackConfig({ target, context }))
1730
1936
  );
1731
- if (isDebug2()) {
1937
+ if (isDebug()) {
1732
1938
  const inspect = () => {
1733
1939
  const inspectOptions = {
1734
1940
  verbose: true,
@@ -1755,6 +1961,7 @@ var init_initConfigs = __esm({
1755
1961
  init_esm();
1756
1962
  init_config();
1757
1963
  init_createContext();
1964
+ init_logger();
1758
1965
  init_mergeConfig();
1759
1966
  init_pluginManager();
1760
1967
  init_inspectConfig();
@@ -1766,13 +1973,10 @@ var init_initConfigs = __esm({
1766
1973
  var devMiddleware_exports = {};
1767
1974
  __export(devMiddleware_exports, {
1768
1975
  getDevMiddleware: () => getDevMiddleware,
1976
+ isClientCompiler: () => isClientCompiler,
1977
+ isNodeCompiler: () => isNodeCompiler,
1769
1978
  setupServerHooks: () => setupServerHooks
1770
1979
  });
1771
- import {
1772
- applyToCompiler,
1773
- isClientCompiler,
1774
- isNodeCompiler
1775
- } from "@rsbuild/shared";
1776
1980
  function applyHMREntry({
1777
1981
  compiler,
1778
1982
  clientPaths,
@@ -1792,11 +1996,26 @@ function applyHMREntry({
1792
1996
  }).apply(compiler);
1793
1997
  }
1794
1998
  }
1795
- var setupServerHooks, getDevMiddleware;
1999
+ var isClientCompiler, isNodeCompiler, setupServerHooks, getDevMiddleware;
1796
2000
  var init_devMiddleware = __esm({
1797
2001
  "src/server/devMiddleware.ts"() {
1798
2002
  "use strict";
1799
2003
  init_esm();
2004
+ init_helpers();
2005
+ isClientCompiler = (compiler) => {
2006
+ const { target } = compiler.options;
2007
+ if (target) {
2008
+ return Array.isArray(target) ? target.includes("web") : target === "web";
2009
+ }
2010
+ return false;
2011
+ };
2012
+ isNodeCompiler = (compiler) => {
2013
+ const { target } = compiler.options;
2014
+ if (target) {
2015
+ return Array.isArray(target) ? target.includes("node") : target === "node";
2016
+ }
2017
+ return false;
2018
+ };
1800
2019
  setupServerHooks = (compiler, hookCallbacks) => {
1801
2020
  if (isNodeCompiler(compiler)) {
1802
2021
  return;
@@ -1835,13 +2054,9 @@ __export(createCompiler_exports, {
1835
2054
  createDevMiddleware: () => createDevMiddleware
1836
2055
  });
1837
2056
  import {
1838
- TARGET_ID_MAP,
1839
- color as color6,
1840
- debug as debug4,
2057
+ color as color7,
1841
2058
  isDev,
1842
2059
  isProd as isProd2,
1843
- logger as logger5,
1844
- onCompileDone,
1845
2060
  prettyTime
1846
2061
  } from "@rsbuild/shared";
1847
2062
  import { rspack as rspack3 } from "@rspack/core";
@@ -1849,13 +2064,13 @@ async function createCompiler({
1849
2064
  context,
1850
2065
  rspackConfigs
1851
2066
  }) {
1852
- debug4("create compiler");
2067
+ logger.debug("create compiler");
1853
2068
  await context.hooks.onBeforeCreateCompiler.call({
1854
2069
  bundlerConfigs: rspackConfigs
1855
2070
  });
1856
2071
  if (!await isSatisfyRspackVersion(rspack3.rspackVersion)) {
1857
2072
  throw new Error(
1858
- `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color6.green(
2073
+ `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color7.green(
1859
2074
  rspackMinVersion
1860
2075
  )}`
1861
2076
  );
@@ -1866,14 +2081,14 @@ async function createCompiler({
1866
2081
  let isCompiling = false;
1867
2082
  const logRspackVersion = () => {
1868
2083
  if (!isVersionLogged) {
1869
- debug4(`Use Rspack v${rspack3.rspackVersion}`);
2084
+ logger.debug(`Use Rspack v${rspack3.rspackVersion}`);
1870
2085
  isVersionLogged = true;
1871
2086
  }
1872
2087
  };
1873
2088
  compiler.hooks.watchRun.tap("rsbuild:compiling", () => {
1874
2089
  logRspackVersion();
1875
2090
  if (!isCompiling) {
1876
- logger5.start("Compiling...");
2091
+ logger.start("Compiling...");
1877
2092
  }
1878
2093
  isCompiling = true;
1879
2094
  });
@@ -1890,7 +2105,7 @@ async function createCompiler({
1890
2105
  const time = prettyTime(c.time / 1e3);
1891
2106
  const target = context.targets[index];
1892
2107
  const name = TARGET_ID_MAP[target || "web"];
1893
- logger5.ready(`${name} compiled in ${time}`);
2108
+ logger.ready(`${name} compiled in ${time}`);
1894
2109
  }
1895
2110
  };
1896
2111
  if (!stats.hasErrors()) {
@@ -1904,10 +2119,10 @@ async function createCompiler({
1904
2119
  }
1905
2120
  const { message, level } = formatStats(stats, getStatsOptions(compiler));
1906
2121
  if (level === "error") {
1907
- logger5.error(message);
2122
+ logger.error(message);
1908
2123
  }
1909
2124
  if (level === "warning") {
1910
- logger5.warn(message);
2125
+ logger.warn(message);
1911
2126
  }
1912
2127
  if (isDev()) {
1913
2128
  await context.hooks.onDevCompileDone.call({
@@ -1925,7 +2140,7 @@ async function createCompiler({
1925
2140
  rspack3.MultiStats
1926
2141
  );
1927
2142
  await context.hooks.onAfterCreateCompiler.call({ compiler });
1928
- debug4("create compiler done");
2143
+ logger.debug("create compiler done");
1929
2144
  return compiler;
1930
2145
  }
1931
2146
  async function createDevMiddleware(options, customCompiler) {
@@ -1949,7 +2164,9 @@ var init_createCompiler = __esm({
1949
2164
  "src/provider/createCompiler.ts"() {
1950
2165
  "use strict";
1951
2166
  init_esm();
2167
+ init_constants();
1952
2168
  init_helpers();
2169
+ init_logger();
1953
2170
  init_initConfigs();
1954
2171
  }
1955
2172
  });
@@ -1958,16 +2175,14 @@ var init_createCompiler = __esm({
1958
2175
  import path4 from "path";
1959
2176
  import { parse as parse2 } from "url";
1960
2177
  import {
1961
- color as color7,
1962
- debug as debug5,
1963
- isDebug as isDebug3,
1964
- logger as logger6
2178
+ color as color8
1965
2179
  } from "@rsbuild/shared";
1966
2180
  var faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, getHtmlFallbackMiddleware;
1967
2181
  var init_middlewares = __esm({
1968
2182
  "src/server/middlewares.ts"() {
1969
2183
  "use strict";
1970
2184
  init_esm();
2185
+ init_logger();
1971
2186
  faviconFallbackMiddleware = (req, res, next) => {
1972
2187
  if (req.url === "/favicon.ico") {
1973
2188
  res.statusCode = 204;
@@ -1978,16 +2193,16 @@ var init_middlewares = __esm({
1978
2193
  };
1979
2194
  getStatusCodeColor = (status) => {
1980
2195
  if (status >= 500) {
1981
- return color7.red;
2196
+ return color8.red;
1982
2197
  }
1983
2198
  if (status >= 400) {
1984
- return color7.yellow;
2199
+ return color8.yellow;
1985
2200
  }
1986
2201
  if (status >= 300) {
1987
- return color7.cyan;
2202
+ return color8.cyan;
1988
2203
  }
1989
2204
  if (status >= 200) {
1990
- return color7.green;
2205
+ return color8.green;
1991
2206
  }
1992
2207
  return (res) => res;
1993
2208
  };
@@ -2002,8 +2217,8 @@ var init_middlewares = __esm({
2002
2217
  const statusColor = getStatusCodeColor(status);
2003
2218
  const endAt = process.hrtime();
2004
2219
  const totalTime = (endAt[0] - _startAt[0]) * 1e3 + (endAt[1] - _startAt[1]) * 1e-6;
2005
- debug5(
2006
- `${statusColor(status)} ${method} ${color7.gray(url2)} ${color7.gray(
2220
+ logger.debug(
2221
+ `${statusColor(status)} ${method} ${color8.gray(url2)} ${color8.gray(
2007
2222
  `${totalTime.toFixed(3)} ms`
2008
2223
  )}`
2009
2224
  );
@@ -2032,8 +2247,8 @@ var init_middlewares = __esm({
2032
2247
  try {
2033
2248
  pathname = parse2(url2, false, true).pathname;
2034
2249
  } catch (err) {
2035
- logger6.error(
2036
- new Error(`Invalid URL: ${color7.yellow(url2)}`, { cause: err })
2250
+ logger.error(
2251
+ new Error(`Invalid URL: ${color8.yellow(url2)}`, { cause: err })
2037
2252
  );
2038
2253
  return next();
2039
2254
  }
@@ -2045,10 +2260,10 @@ var init_middlewares = __esm({
2045
2260
  });
2046
2261
  };
2047
2262
  const rewrite = (newUrl, isFallback = false) => {
2048
- if (isFallback && isDebug3()) {
2049
- debug5(
2050
- `${req.method} ${color7.gray(
2051
- `${req.url} ${color7.yellow("fallback")} to ${newUrl}`
2263
+ if (isFallback && logger.level === "verbose") {
2264
+ logger.debug(
2265
+ `${req.method} ${color8.gray(
2266
+ `${req.url} ${color8.yellow("fallback")} to ${newUrl}`
2052
2267
  )}`
2053
2268
  );
2054
2269
  }
@@ -2093,9 +2308,6 @@ __export(proxy_exports, {
2093
2308
  createProxyMiddleware: () => createProxyMiddleware,
2094
2309
  formatProxyOptions: () => formatProxyOptions
2095
2310
  });
2096
- import {
2097
- logger as logger7
2098
- } from "@rsbuild/shared";
2099
2311
  import {
2100
2312
  createProxyMiddleware as baseCreateProxyMiddleware
2101
2313
  } from "@rsbuild/shared/http-proxy-middleware";
@@ -2120,7 +2332,7 @@ function formatProxyOptions(proxyOptions) {
2120
2332
  ret.push(opts);
2121
2333
  }
2122
2334
  }
2123
- const handleError = (err) => logger7.error(err);
2335
+ const handleError = (err) => logger.error(err);
2124
2336
  for (const opts of ret) {
2125
2337
  opts.onError ??= handleError;
2126
2338
  }
@@ -2131,6 +2343,7 @@ var init_proxy = __esm({
2131
2343
  "src/server/proxy.ts"() {
2132
2344
  "use strict";
2133
2345
  init_esm();
2346
+ init_logger();
2134
2347
  createProxyMiddleware = (proxyOptions) => {
2135
2348
  const formattedOptionsList = formatProxyOptions(proxyOptions);
2136
2349
  const proxyMiddlewares = [];
@@ -2172,13 +2385,13 @@ var init_proxy = __esm({
2172
2385
  // src/server/getDevMiddlewares.ts
2173
2386
  import { isAbsolute as isAbsolute4, join as join7 } from "path";
2174
2387
  import url from "url";
2175
- import { isDebug as isDebug4 } from "@rsbuild/shared";
2176
2388
  var applySetupMiddlewares, applyDefaultMiddlewares, getMiddlewares;
2177
2389
  var init_getDevMiddlewares = __esm({
2178
2390
  "src/server/getDevMiddlewares.ts"() {
2179
2391
  "use strict";
2180
2392
  init_esm();
2181
2393
  init_config();
2394
+ init_logger();
2182
2395
  init_middlewares();
2183
2396
  applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
2184
2397
  const setupMiddlewares = dev.setupMiddlewares || [];
@@ -2296,7 +2509,7 @@ var init_getDevMiddlewares = __esm({
2296
2509
  getMiddlewares = async (options) => {
2297
2510
  const middlewares = [];
2298
2511
  const { compileMiddlewareAPI } = options;
2299
- if (isDebug4()) {
2512
+ if (logger.level === "verbose") {
2300
2513
  middlewares.push(await getRequestLoggerMiddleware());
2301
2514
  }
2302
2515
  const { before, after } = applySetupMiddlewares(
@@ -2323,11 +2536,11 @@ var init_getDevMiddlewares = __esm({
2323
2536
  // src/server/helper.ts
2324
2537
  import net from "net";
2325
2538
  import os from "os";
2326
- import { color as color8, deepmerge, isFunction as isFunction4, logger as logger8 } from "@rsbuild/shared";
2539
+ import { color as color9, deepmerge, isFunction as isFunction4 } from "@rsbuild/shared";
2327
2540
  function getURLMessages(urls, routes) {
2328
2541
  if (routes.length === 1) {
2329
2542
  return urls.map(
2330
- ({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${color8.cyan(
2543
+ ({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${color9.cyan(
2331
2544
  normalizeUrl(`${url2}${routes[0].pathname}`)
2332
2545
  )}
2333
2546
  `
@@ -2342,9 +2555,9 @@ function getURLMessages(urls, routes) {
2342
2555
  message += ` ${`> ${label}`}
2343
2556
  `;
2344
2557
  for (const r of routes) {
2345
- message += ` ${color8.dim("-")} ${color8.dim(
2558
+ message += ` ${color9.dim("-")} ${color9.dim(
2346
2559
  r.entryName.padEnd(maxNameLength + 4)
2347
- )}${color8.cyan(normalizeUrl(`${url2}${r.pathname}`))}
2560
+ )}${color9.cyan(normalizeUrl(`${url2}${r.pathname}`))}
2348
2561
  `;
2349
2562
  }
2350
2563
  });
@@ -2385,7 +2598,7 @@ function printServerURLs({
2385
2598
  return;
2386
2599
  }
2387
2600
  const message = getURLMessages(urls, routes);
2388
- logger8.log(message);
2601
+ logger.log(message);
2389
2602
  return message;
2390
2603
  }
2391
2604
  var normalizeUrl, formatPrefix, formatRoutes, HMR_SOCK_PATH, getPort, getServerConfig, getDevConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
@@ -2394,6 +2607,7 @@ var init_helper = __esm({
2394
2607
  "use strict";
2395
2608
  init_esm();
2396
2609
  init_constants();
2610
+ init_logger();
2397
2611
  normalizeUrl = (url2) => url2.replace(/([^:]\/)\/+/g, "$1");
2398
2612
  formatPrefix = (prefix) => {
2399
2613
  if (!prefix) {
@@ -2457,8 +2671,8 @@ var init_helper = __esm({
2457
2671
  );
2458
2672
  }
2459
2673
  if (!silent) {
2460
- logger8.info(
2461
- `Port ${original} is in use, ${color8.yellow(`using port ${port}.`)}
2674
+ logger.info(
2675
+ `Port ${original} is in use, ${color9.yellow(`using port ${port}.`)}
2462
2676
  `
2463
2677
  );
2464
2678
  }
@@ -2683,13 +2897,13 @@ var init_watchFiles = __esm({
2683
2897
  });
2684
2898
 
2685
2899
  // src/server/socketServer.ts
2686
- import { logger as logger9 } from "@rsbuild/shared";
2687
2900
  var SocketServer;
2688
2901
  var init_socketServer = __esm({
2689
2902
  "src/server/socketServer.ts"() {
2690
2903
  "use strict";
2691
2904
  init_esm();
2692
2905
  init_helpers();
2906
+ init_logger();
2693
2907
  SocketServer = class {
2694
2908
  constructor(options) {
2695
2909
  __publicField(this, "wsServer");
@@ -2715,7 +2929,7 @@ var init_socketServer = __esm({
2715
2929
  path: this.options.client?.path
2716
2930
  });
2717
2931
  this.wsServer.on("error", (err) => {
2718
- logger9.error(err);
2932
+ logger.error(err);
2719
2933
  });
2720
2934
  this.timer = setInterval(() => {
2721
2935
  for (const socket of this.wsServer.clients) {
@@ -2934,10 +3148,8 @@ __export(devServer_exports, {
2934
3148
  });
2935
3149
  import fs3 from "fs";
2936
3150
  import {
2937
- debug as debug6,
2938
3151
  getNodeEnv as getNodeEnv5,
2939
3152
  getPublicPathFromCompiler,
2940
- isMultiCompiler as isMultiCompiler2,
2941
3153
  setNodeEnv as setNodeEnv2
2942
3154
  } from "@rsbuild/shared";
2943
3155
  async function createDevServer(options, createDevMiddleware2, config, {
@@ -2948,7 +3160,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
2948
3160
  if (!getNodeEnv5()) {
2949
3161
  setNodeEnv2("development");
2950
3162
  }
2951
- debug6("create dev server");
3163
+ logger.debug("create dev server");
2952
3164
  const serverConfig = config.server;
2953
3165
  const { port, host, https } = await getServerConfig({
2954
3166
  config,
@@ -2975,7 +3187,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
2975
3187
  customCompiler
2976
3188
  );
2977
3189
  const { CompilerDevMiddleware: CompilerDevMiddleware2 } = await Promise.resolve().then(() => (init_compilerDevMiddleware(), compilerDevMiddleware_exports));
2978
- const publicPaths = isMultiCompiler2(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [getPublicPathFromCompiler(compiler)];
3190
+ const publicPaths = isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [getPublicPathFromCompiler(compiler)];
2979
3191
  const compilerDevMiddleware = new CompilerDevMiddleware2({
2980
3192
  dev: devConfig,
2981
3193
  server: serverConfig,
@@ -2983,7 +3195,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
2983
3195
  devMiddleware
2984
3196
  });
2985
3197
  await compilerDevMiddleware.init();
2986
- outputFileSystem = (isMultiCompiler2(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) || fs3;
3198
+ outputFileSystem = (isMultiCompiler(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) || fs3;
2987
3199
  return {
2988
3200
  middleware: compilerDevMiddleware.middleware,
2989
3201
  sockWrite: (...args) => compilerDevMiddleware.sockWrite(...args),
@@ -3047,7 +3259,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
3047
3259
  serverConfig,
3048
3260
  middlewares
3049
3261
  });
3050
- debug6("listen dev server");
3262
+ logger.debug("listen dev server");
3051
3263
  return new Promise((resolve) => {
3052
3264
  httpServer.listen(
3053
3265
  {
@@ -3060,7 +3272,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
3060
3272
  }
3061
3273
  middlewares.use(notFoundMiddleware);
3062
3274
  httpServer.on("upgrade", devMiddlewares.onUpgrade);
3063
- debug6("listen dev server done");
3275
+ logger.debug("listen dev server done");
3064
3276
  await server.afterListen();
3065
3277
  const closeServer = async () => {
3066
3278
  await server.close();
@@ -3091,7 +3303,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
3091
3303
  await fileWatcher?.close();
3092
3304
  }
3093
3305
  };
3094
- debug6("create dev server done");
3306
+ logger.debug("create dev server done");
3095
3307
  return server;
3096
3308
  }
3097
3309
  var init_devServer = __esm({
@@ -3099,6 +3311,8 @@ var init_devServer = __esm({
3099
3311
  "use strict";
3100
3312
  init_esm();
3101
3313
  init_constants();
3314
+ init_helpers();
3315
+ init_logger();
3102
3316
  init_getDevMiddlewares();
3103
3317
  init_helper();
3104
3318
  init_httpServer();
@@ -3113,13 +3327,15 @@ var build_exports = {};
3113
3327
  __export(build_exports, {
3114
3328
  build: () => build
3115
3329
  });
3116
- import { getNodeEnv as getNodeEnv6, logger as logger10, onCompileDone as onCompileDone2, setNodeEnv as setNodeEnv3 } from "@rsbuild/shared";
3330
+ import { getNodeEnv as getNodeEnv6, setNodeEnv as setNodeEnv3 } from "@rsbuild/shared";
3117
3331
  import { rspack as rspack4 } from "@rspack/core";
3118
3332
  var build;
3119
3333
  var init_build = __esm({
3120
3334
  "src/provider/build.ts"() {
3121
3335
  "use strict";
3122
3336
  init_esm();
3337
+ init_helpers();
3338
+ init_logger();
3123
3339
  init_createCompiler();
3124
3340
  init_initConfigs();
3125
3341
  build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
@@ -3148,7 +3364,7 @@ var init_build = __esm({
3148
3364
  isFirstCompile = false;
3149
3365
  await p;
3150
3366
  };
3151
- onCompileDone2(
3367
+ onCompileDone(
3152
3368
  compiler,
3153
3369
  onDone,
3154
3370
  // @ts-expect-error type mismatch
@@ -3157,7 +3373,7 @@ var init_build = __esm({
3157
3373
  if (watch) {
3158
3374
  compiler.watch({}, (err) => {
3159
3375
  if (err) {
3160
- logger10.error(err);
3376
+ logger.error(err);
3161
3377
  }
3162
3378
  });
3163
3379
  return;
@@ -3170,7 +3386,7 @@ var init_build = __esm({
3170
3386
  } else {
3171
3387
  compiler.close((closeErr) => {
3172
3388
  if (closeErr) {
3173
- logger10.error(closeErr);
3389
+ logger.error(closeErr);
3174
3390
  }
3175
3391
  resolve({ stats });
3176
3392
  });
@@ -3267,22 +3483,30 @@ __export(basic_exports, {
3267
3483
  pluginBasic: () => pluginBasic
3268
3484
  });
3269
3485
  import path5 from "path";
3270
- import { TARGET_ID_MAP as TARGET_ID_MAP2, getJsSourceMap, isUsingHMR } from "@rsbuild/shared";
3271
- var pluginBasic;
3486
+ import { isProd as isProd3, isUsingHMR } from "@rsbuild/shared";
3487
+ var getJsSourceMap, pluginBasic;
3272
3488
  var init_basic = __esm({
3273
3489
  "src/plugins/basic.ts"() {
3274
3490
  "use strict";
3275
3491
  init_esm();
3492
+ init_constants();
3493
+ getJsSourceMap = (config) => {
3494
+ const { sourceMap } = config.output;
3495
+ if (sourceMap.js === void 0) {
3496
+ return isProd3() ? false : "cheap-module-source-map";
3497
+ }
3498
+ return sourceMap.js;
3499
+ };
3276
3500
  pluginBasic = () => ({
3277
3501
  name: "rsbuild:basic",
3278
3502
  setup(api) {
3279
3503
  api.modifyBundlerChain(
3280
- (chain, { env, isProd: isProd6, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
3504
+ (chain, { env, isProd: isProd7, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
3281
3505
  const config = api.getNormalizedConfig();
3282
- chain.name(TARGET_ID_MAP2[target]);
3506
+ chain.name(TARGET_ID_MAP[target]);
3283
3507
  chain.devtool(getJsSourceMap(config));
3284
3508
  chain.context(api.context.rootPath);
3285
- chain.mode(isProd6 ? "production" : "development");
3509
+ chain.mode(isProd7 ? "production" : "development");
3286
3510
  chain.merge({
3287
3511
  infrastructureLogging: {
3288
3512
  // Using `error` level to avoid `cache.PackFileCacheStrategy` logs
@@ -3295,9 +3519,9 @@ var init_basic = __esm({
3295
3519
  exportsPresence: "error"
3296
3520
  }
3297
3521
  });
3298
- const isMinimize = isProd6 && config.output.minify !== false;
3522
+ const isMinimize = isProd7 && config.output.minify !== false;
3299
3523
  chain.optimization.minimize(isMinimize);
3300
- const usingHMR = isUsingHMR(config, { target, isProd: isProd6 });
3524
+ const usingHMR = isUsingHMR(config, { target, isProd: isProd7 });
3301
3525
  if (usingHMR) {
3302
3526
  chain.plugin(CHAIN_ID3.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
3303
3527
  }
@@ -3467,7 +3691,7 @@ import {
3467
3691
  deepmerge as deepmerge2,
3468
3692
  getBrowserslistWithDefault as getBrowserslistWithDefault2,
3469
3693
  isFunction as isFunction5,
3470
- isPlainObject as isPlainObject2,
3694
+ isPlainObject as isPlainObject3,
3471
3695
  reduceConfigs,
3472
3696
  reduceConfigsWithContext
3473
3697
  } from "@rsbuild/shared";
@@ -3493,7 +3717,7 @@ async function applyCSSRule({
3493
3717
  rule,
3494
3718
  config,
3495
3719
  context,
3496
- utils: { target, isProd: isProd6, CHAIN_ID: CHAIN_ID3 },
3720
+ utils: { target, isProd: isProd7, CHAIN_ID: CHAIN_ID3 },
3497
3721
  importLoaders = 1
3498
3722
  }) {
3499
3723
  const browserslist = await getBrowserslistWithDefault2(
@@ -3502,7 +3726,7 @@ async function applyCSSRule({
3502
3726
  target
3503
3727
  );
3504
3728
  const enableExtractCSS = isUseCssExtract(config, target);
3505
- const localIdentName = getCSSModulesLocalIdentName(config, isProd6);
3729
+ const localIdentName = getCSSModulesLocalIdentName(config, isProd7);
3506
3730
  const cssLoaderOptions = getCSSLoaderOptions({
3507
3731
  config,
3508
3732
  importLoaders,
@@ -3544,8 +3768,8 @@ var init_css = __esm({
3544
3768
  init_pluginHelper();
3545
3769
  enableNativeCss = (config) => !config.output.injectStyles;
3546
3770
  isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
3547
- getCSSModulesLocalIdentName = (config, isProd6) => config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
3548
- (isProd6 ? "[local]-[hash:base64:6]" : "[path][name]__[local]-[hash:base64:6]");
3771
+ getCSSModulesLocalIdentName = (config, isProd7) => config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
3772
+ (isProd7 ? "[local]-[hash:base64:6]" : "[path][name]__[local]-[hash:base64:6]");
3549
3773
  normalizeCssLoaderOptions = (options, exportOnlyLocals) => {
3550
3774
  if (options.modules && exportOnlyLocals) {
3551
3775
  let { modules } = options;
@@ -3575,7 +3799,7 @@ var init_css = __esm({
3575
3799
  (plugin) => isFunction5(plugin) ? plugin({}) : plugin
3576
3800
  );
3577
3801
  const hasAutoprefixer = pluginObjects.some((pluginObject) => {
3578
- if (isPlainObject2(pluginObject) && "postcssPlugin" in pluginObject) {
3802
+ if (isPlainObject3(pluginObject) && "postcssPlugin" in pluginObject) {
3579
3803
  return pluginObject.postcssPlugin === "autoprefixer";
3580
3804
  }
3581
3805
  return false;
@@ -3693,19 +3917,17 @@ __export(output_exports, {
3693
3917
  });
3694
3918
  import { posix as posix2 } from "path";
3695
3919
  import {
3696
- DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX3,
3697
- getDistPath as getDistPath3,
3698
- getFilename as getFilename2
3920
+ DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX3
3699
3921
  } from "@rsbuild/shared";
3700
3922
  import { rspack as rspack5 } from "@rspack/core";
3701
3923
  function getPublicPath({
3702
- isProd: isProd6,
3924
+ isProd: isProd7,
3703
3925
  config,
3704
3926
  context
3705
3927
  }) {
3706
3928
  const { dev, output } = config;
3707
3929
  let publicPath = DEFAULT_ASSET_PREFIX3;
3708
- if (isProd6) {
3930
+ if (isProd7) {
3709
3931
  if (typeof output.assetPrefix === "string") {
3710
3932
  publicPath = output.assetPrefix;
3711
3933
  }
@@ -3737,16 +3959,16 @@ var init_output = __esm({
3737
3959
  name: "rsbuild:output",
3738
3960
  setup(api) {
3739
3961
  api.modifyBundlerChain(
3740
- async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd: isProd6, isServer, isServiceWorker }) => {
3962
+ async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd: isProd7, isServer, isServiceWorker }) => {
3741
3963
  const config = api.getNormalizedConfig();
3742
3964
  const publicPath = getPublicPath({
3743
3965
  config,
3744
- isProd: isProd6,
3966
+ isProd: isProd7,
3745
3967
  context: api.context
3746
3968
  });
3747
- const jsPath = getDistPath3(config, "js");
3748
- const jsAsyncPath = getDistPath3(config, "jsAsync");
3749
- const jsFilename = getFilename2(config, "js", isProd6);
3969
+ const jsPath = config.output.distPath.js;
3970
+ const jsAsyncPath = config.output.distPath.jsAsync ?? (jsPath ? `${jsPath}/async` : "async");
3971
+ const jsFilename = getFilename2(config, "js", isProd7);
3750
3972
  const isJsFilenameFn = typeof jsFilename === "function";
3751
3973
  chain.output.path(api.context.distPath).filename(
3752
3974
  isJsFilenameFn ? (...args) => {
@@ -3760,14 +3982,14 @@ var init_output = __esm({
3760
3982
  } : posix2.join(jsAsyncPath, jsFilename)
3761
3983
  ).publicPath(publicPath).pathinfo(false).hashFunction("xxhash64");
3762
3984
  if (isServer) {
3763
- const serverPath = getDistPath3(config, "server");
3985
+ const serverPath = config.output.distPath.server;
3764
3986
  chain.output.path(posix2.join(api.context.distPath, serverPath)).filename("[name].js").chunkFilename("[name].js").library({
3765
3987
  ...chain.output.get("library") || {},
3766
3988
  type: "commonjs2"
3767
3989
  });
3768
3990
  }
3769
3991
  if (isServiceWorker) {
3770
- const workerPath = getDistPath3(config, "worker");
3992
+ const workerPath = config.output.distPath.worker;
3771
3993
  const filename = posix2.join(workerPath, "[name].js");
3772
3994
  chain.output.filename(filename).chunkFilename(filename);
3773
3995
  }
@@ -3778,9 +4000,9 @@ var init_output = __esm({
3778
4000
  }
3779
4001
  if (isUseCssExtract(config, target)) {
3780
4002
  const extractPluginOptions = config.tools.cssExtract.pluginOptions;
3781
- const cssPath = getDistPath3(config, "css");
3782
- const cssFilename = getFilename2(config, "css", isProd6);
3783
- const cssAsyncPath = getDistPath3(config, "cssAsync");
4003
+ const cssPath = config.output.distPath.css;
4004
+ const cssFilename = getFilename2(config, "css", isProd7);
4005
+ const cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : "async");
3784
4006
  chain.plugin(CHAIN_ID3.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
3785
4007
  {
3786
4008
  filename: posix2.join(cssPath, cssFilename),
@@ -3802,7 +4024,7 @@ __export(resolve_exports, {
3802
4024
  pluginResolve: () => pluginResolve
3803
4025
  });
3804
4026
  import {
3805
- castArray as castArray4,
4027
+ castArray as castArray6,
3806
4028
  reduceConfigsWithContext as reduceConfigsWithContext2
3807
4029
  } from "@rsbuild/shared";
3808
4030
  function applyFullySpecified({
@@ -3839,7 +4061,7 @@ function applyAlias({
3839
4061
  ctx: { target }
3840
4062
  });
3841
4063
  for (const name of Object.keys(mergedAlias)) {
3842
- const values = castArray4(mergedAlias[name]);
4064
+ const values = castArray6(mergedAlias[name]);
3843
4065
  const formattedValues = values.map((value) => {
3844
4066
  if (typeof value === "string" && value.startsWith(".")) {
3845
4067
  return ensureAbsolutePath(rootPath, value);
@@ -3896,7 +4118,7 @@ __export(fileSize_exports, {
3896
4118
  });
3897
4119
  import path7 from "path";
3898
4120
  import { JS_REGEX, fse as fse4 } from "@rsbuild/shared";
3899
- import { color as color9, logger as logger11 } from "@rsbuild/shared";
4121
+ import { color as color10 } from "@rsbuild/shared";
3900
4122
  async function printHeader(longestFileLength, longestLabelLength) {
3901
4123
  const longestLengths = [longestFileLength, longestLabelLength];
3902
4124
  const headerRow = ["File", "Size", "Gzipped"].reduce((prev, cur, index) => {
@@ -3907,7 +4129,7 @@ async function printHeader(longestFileLength, longestLabelLength) {
3907
4129
  }
3908
4130
  return `${prev + curLabel} `;
3909
4131
  }, " ");
3910
- logger11.log(color9.bold(color9.blue(headerRow)));
4132
+ logger.log(color10.bold(color10.blue(headerRow)));
3911
4133
  }
3912
4134
  async function printFileSizes(config, stats, rootPath) {
3913
4135
  if (config.detail === false && config.total === false) {
@@ -3958,7 +4180,7 @@ async function printFileSizes(config, stats, rootPath) {
3958
4180
  return;
3959
4181
  }
3960
4182
  assets.sort((a, b) => a.size - b.size);
3961
- logger11.info("Production file sizes:\n");
4183
+ logger.info("Production file sizes:\n");
3962
4184
  const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
3963
4185
  const longestFileLength = Math.max(
3964
4186
  ...assets.map((a) => (a.folder + path7.sep + a.name).length)
@@ -3980,22 +4202,22 @@ async function printFileSizes(config, stats, rootPath) {
3980
4202
  const rightPadding = " ".repeat(longestLabelLength - sizeLength);
3981
4203
  sizeLabel += rightPadding;
3982
4204
  }
3983
- let fileNameLabel = color9.dim(asset.folder + path7.sep) + coloringAssetName(asset.name);
4205
+ let fileNameLabel = color10.dim(asset.folder + path7.sep) + coloringAssetName(asset.name);
3984
4206
  if (fileNameLength < longestFileLength) {
3985
4207
  const rightPadding = " ".repeat(longestFileLength - fileNameLength);
3986
4208
  fileNameLabel += rightPadding;
3987
4209
  }
3988
- logger11.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
4210
+ logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
3989
4211
  }
3990
4212
  }
3991
4213
  if (config.total !== false) {
3992
- const totalSizeLabel = `${color9.bold(
3993
- color9.blue("Total size:")
4214
+ const totalSizeLabel = `${color10.bold(
4215
+ color10.blue("Total size:")
3994
4216
  )} ${calcFileSize(totalSize)}`;
3995
- const gzippedSizeLabel = `${color9.bold(
3996
- color9.blue("Gzipped size:")
4217
+ const gzippedSizeLabel = `${color10.bold(
4218
+ color10.blue("Gzipped size:")
3997
4219
  )} ${calcFileSize(totalGzipSize)}`;
3998
- logger11.log(`
4220
+ logger.log(`
3999
4221
  ${totalSizeLabel}
4000
4222
  ${gzippedSizeLabel}
4001
4223
  `);
@@ -4007,15 +4229,16 @@ var init_fileSize = __esm({
4007
4229
  "use strict";
4008
4230
  init_esm();
4009
4231
  init_constants();
4232
+ init_logger();
4010
4233
  filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
4011
4234
  getAssetColor = (size) => {
4012
4235
  if (size > 300 * 1e3) {
4013
- return color9.red;
4236
+ return color10.red;
4014
4237
  }
4015
4238
  if (size > 100 * 1e3) {
4016
- return color9.yellow;
4239
+ return color10.yellow;
4017
4240
  }
4018
- return color9.green;
4241
+ return color10.green;
4019
4242
  };
4020
4243
  calcFileSize = (len) => {
4021
4244
  const val = len / 1e3;
@@ -4023,15 +4246,15 @@ var init_fileSize = __esm({
4023
4246
  };
4024
4247
  coloringAssetName = (assetName) => {
4025
4248
  if (JS_REGEX.test(assetName)) {
4026
- return color9.cyan(assetName);
4249
+ return color10.cyan(assetName);
4027
4250
  }
4028
4251
  if (CSS_REGEX.test(assetName)) {
4029
- return color9.yellow(assetName);
4252
+ return color10.yellow(assetName);
4030
4253
  }
4031
4254
  if (HTML_REGEX.test(assetName)) {
4032
- return color9.green(assetName);
4255
+ return color10.green(assetName);
4033
4256
  }
4034
- return color9.magenta(assetName);
4257
+ return color10.magenta(assetName);
4035
4258
  };
4036
4259
  pluginFileSize = () => ({
4037
4260
  name: "rsbuild:file-size",
@@ -4053,8 +4276,8 @@ var init_fileSize = __esm({
4053
4276
  api.context.rootPath
4054
4277
  );
4055
4278
  } catch (err) {
4056
- logger11.warn("Failed to print file size.");
4057
- logger11.warn(err);
4279
+ logger.warn("Failed to print file size.");
4280
+ logger.warn(err);
4058
4281
  }
4059
4282
  }
4060
4283
  });
@@ -4069,12 +4292,13 @@ __export(cleanOutput_exports, {
4069
4292
  pluginCleanOutput: () => pluginCleanOutput
4070
4293
  });
4071
4294
  import { sep } from "path";
4072
- import { color as color10, fse as fse5, logger as logger12 } from "@rsbuild/shared";
4295
+ import { color as color11, fse as fse5 } from "@rsbuild/shared";
4073
4296
  var emptyDir, addTrailingSep, isStrictSubdir, pluginCleanOutput;
4074
4297
  var init_cleanOutput = __esm({
4075
4298
  "src/plugins/cleanOutput.ts"() {
4076
4299
  "use strict";
4077
4300
  init_esm();
4301
+ init_logger();
4078
4302
  emptyDir = async (dir) => {
4079
4303
  if (await fse5.pathExists(dir)) {
4080
4304
  await fse5.emptyDir(dir);
@@ -4096,14 +4320,14 @@ var init_cleanOutput = __esm({
4096
4320
  if (cleanDistPath === void 0) {
4097
4321
  cleanDistPath = isStrictSubdir(rootPath, distPath);
4098
4322
  if (!cleanDistPath) {
4099
- logger12.warn(
4323
+ logger.warn(
4100
4324
  "The dist path is not a subdir of root path, Rsbuild will not empty it."
4101
4325
  );
4102
- logger12.warn(
4103
- `Please set ${color10.yellow("`output.cleanDistPath`")} config manually.`
4326
+ logger.warn(
4327
+ `Please set ${color11.yellow("`output.cleanDistPath`")} config manually.`
4104
4328
  );
4105
- logger12.warn(`Current root path: ${color10.dim(rootPath)}`);
4106
- logger12.warn(`Current dist path: ${color10.dim(distPath)}`);
4329
+ logger.warn(`Current root path: ${color11.dim(rootPath)}`);
4330
+ logger.warn(`Current dist path: ${color11.dim(distPath)}`);
4107
4331
  }
4108
4332
  }
4109
4333
  if (cleanDistPath) {
@@ -4124,7 +4348,6 @@ __export(asset_exports, {
4124
4348
  pluginAsset: () => pluginAsset
4125
4349
  });
4126
4350
  import path8 from "path";
4127
- import { getDistPath as getDistPath4, getFilename as getFilename3 } from "@rsbuild/shared";
4128
4351
  function getRegExpForExts(exts) {
4129
4352
  const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
4130
4353
  return new RegExp(
@@ -4138,6 +4361,7 @@ var init_asset = __esm({
4138
4361
  "use strict";
4139
4362
  init_esm();
4140
4363
  init_constants();
4364
+ init_helpers();
4141
4365
  chainStaticAssetRule = ({
4142
4366
  emit,
4143
4367
  rule,
@@ -4162,12 +4386,12 @@ var init_asset = __esm({
4162
4386
  pluginAsset = () => ({
4163
4387
  name: "rsbuild:asset",
4164
4388
  setup(api) {
4165
- api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
4389
+ api.modifyBundlerChain((chain, { isProd: isProd7, target }) => {
4166
4390
  const config = api.getNormalizedConfig();
4167
4391
  const createAssetRule = (assetType, exts, emit2) => {
4168
4392
  const regExp = getRegExpForExts(exts);
4169
- const distDir = getDistPath4(config, assetType);
4170
- const filename = getFilename3(config, assetType, isProd6);
4393
+ const distDir = config.output.distPath[assetType];
4394
+ const filename = getFilename2(config, assetType, isProd7);
4171
4395
  const { dataUriLimit } = config.output;
4172
4396
  const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
4173
4397
  const rule = chain.module.rule(assetType).test(regExp);
@@ -4250,9 +4474,9 @@ var init_minimize = __esm({
4250
4474
  }
4251
4475
  return options;
4252
4476
  };
4253
- parseMinifyOptions = (config, isProd6 = true) => {
4477
+ parseMinifyOptions = (config, isProd7 = true) => {
4254
4478
  const minify = config.output.minify;
4255
- if (minify === false || !isProd6) {
4479
+ if (minify === false || !isProd7) {
4256
4480
  return {
4257
4481
  minifyJs: false,
4258
4482
  minifyCss: false,
@@ -4284,9 +4508,9 @@ var init_minimize = __esm({
4284
4508
  if (api.context.bundlerType === "webpack") {
4285
4509
  return;
4286
4510
  }
4287
- api.modifyBundlerChain(async (chain, { isProd: isProd6 }) => {
4511
+ api.modifyBundlerChain(async (chain, { isProd: isProd7 }) => {
4288
4512
  const config = api.getNormalizedConfig();
4289
- const isMinimize = isProd6 && config.output.minify !== false;
4513
+ const isMinimize = isProd7 && config.output.minify !== false;
4290
4514
  if (!isMinimize) {
4291
4515
  return;
4292
4516
  }
@@ -4314,8 +4538,7 @@ __export(HtmlBasicPlugin_exports, {
4314
4538
  hasTitle: () => hasTitle
4315
4539
  });
4316
4540
  import {
4317
- isFunction as isFunction6,
4318
- partition
4541
+ isFunction as isFunction6
4319
4542
  } from "@rsbuild/shared";
4320
4543
  var VOID_TAGS, HEAD_TAGS, FILE_ATTRS, hasTitle, getTagPriority, formatBasicTag, fromBasicTag, formatTags, applyTagConfig, addTitleTag, addFavicon, HtmlBasicPlugin;
4321
4544
  var init_HtmlBasicPlugin = __esm({
@@ -4602,14 +4825,12 @@ __export(html_exports, {
4602
4825
  });
4603
4826
  import path9, { isAbsolute as isAbsolute6 } from "path";
4604
4827
  import {
4605
- castArray as castArray5,
4606
- color as color11,
4828
+ castArray as castArray7,
4829
+ color as color12,
4607
4830
  deepmerge as deepmerge4,
4608
4831
  fse as fse6,
4609
- getDistPath as getDistPath5,
4610
4832
  isHtmlDisabled,
4611
- isPlainObject as isPlainObject3,
4612
- isURL,
4833
+ isPlainObject as isPlainObject4,
4613
4834
  reduceConfigsMergeContext as reduceConfigsMergeContext2,
4614
4835
  reduceConfigsWithContext as reduceConfigsWithContext3
4615
4836
  } from "@rsbuild/shared";
@@ -4645,8 +4866,8 @@ function getTerserMinifyOptions(config) {
4645
4866
  const finalOptions = applyRemoveConsole(options, config);
4646
4867
  return finalOptions;
4647
4868
  }
4648
- async function getHtmlMinifyOptions(isProd6, config) {
4649
- if (!isProd6 || !config.output.minify || !parseMinifyOptions(config).minifyHtml) {
4869
+ async function getHtmlMinifyOptions(isProd7, config) {
4870
+ if (!isProd7 || !config.output.minify || !parseMinifyOptions(config).minifyHtml) {
4650
4871
  return false;
4651
4872
  }
4652
4873
  const minifyJS = getTerserMinifyOptions(config);
@@ -4696,7 +4917,7 @@ async function getTemplate(entryName, config, rootPath) {
4696
4917
  if (!existTemplatePath.includes(absolutePath)) {
4697
4918
  if (!await isFileExists(absolutePath)) {
4698
4919
  throw new Error(
4699
- `Failed to resolve HTML template, please check if the file exists: ${color11.cyan(
4920
+ `Failed to resolve HTML template, please check if the file exists: ${color12.cyan(
4700
4921
  absolutePath
4701
4922
  )}`
4702
4923
  );
@@ -4755,7 +4976,7 @@ function getTemplateParameters(entryName, config, assetPrefix) {
4755
4976
  function getChunks(entryName, entryValue) {
4756
4977
  const chunks = [entryName];
4757
4978
  for (const item of entryValue) {
4758
- if (!isPlainObject3(item)) {
4979
+ if (!isPlainObject4(item)) {
4759
4980
  continue;
4760
4981
  }
4761
4982
  const { dependOn } = item;
@@ -4781,7 +5002,7 @@ var init_html = __esm({
4781
5002
  existTemplatePath = [];
4782
5003
  getTagConfig = (api) => {
4783
5004
  const config = api.getNormalizedConfig();
4784
- const tags = castArray5(config.html.tags).filter(Boolean);
5005
+ const tags = castArray7(config.html.tags).filter(Boolean);
4785
5006
  if (!tags.length) {
4786
5007
  return void 0;
4787
5008
  }
@@ -4796,12 +5017,12 @@ var init_html = __esm({
4796
5017
  name: "rsbuild:html",
4797
5018
  setup(api) {
4798
5019
  api.modifyBundlerChain(
4799
- async (chain, { HtmlPlugin, isProd: isProd6, CHAIN_ID: CHAIN_ID3, target }) => {
5020
+ async (chain, { HtmlPlugin, isProd: isProd7, CHAIN_ID: CHAIN_ID3, target }) => {
4800
5021
  const config = api.getNormalizedConfig();
4801
5022
  if (isHtmlDisabled(config, target)) {
4802
5023
  return;
4803
5024
  }
4804
- const minify = await getHtmlMinifyOptions(isProd6, config);
5025
+ const minify = await getHtmlMinifyOptions(isProd7, config);
4805
5026
  const assetPrefix = getPublicPathFromChain(chain, false);
4806
5027
  const entries = chain.entryPoints.entries() || {};
4807
5028
  const entryNames = Object.keys(entries);
@@ -4877,7 +5098,7 @@ var init_html = __esm({
4877
5098
  }
4878
5099
  if (appIcon) {
4879
5100
  const { HtmlAppIconPlugin: HtmlAppIconPlugin2 } = await Promise.resolve().then(() => (init_HtmlAppIconPlugin(), HtmlAppIconPlugin_exports));
4880
- const distDir = getDistPath5(config, "image");
5101
+ const distDir = config.output.distPath.image;
4881
5102
  const iconPath = path9.isAbsolute(appIcon) ? appIcon : path9.join(api.context.rootPath, appIcon);
4882
5103
  chain.plugin(CHAIN_ID3.PLUGIN.APP_ICON).use(HtmlAppIconPlugin2, [{ iconPath, distDir }]);
4883
5104
  }
@@ -4913,7 +5134,6 @@ __export(wasm_exports, {
4913
5134
  pluginWasm: () => pluginWasm
4914
5135
  });
4915
5136
  import { posix as posix4 } from "path";
4916
- import { getDistPath as getDistPath6 } from "@rsbuild/shared";
4917
5137
  var pluginWasm;
4918
5138
  var init_wasm = __esm({
4919
5139
  "src/plugins/wasm.ts"() {
@@ -4924,7 +5144,7 @@ var init_wasm = __esm({
4924
5144
  setup(api) {
4925
5145
  api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID3 }) => {
4926
5146
  const config = api.getNormalizedConfig();
4927
- const distPath = getDistPath6(config, "wasm");
5147
+ const distPath = config.output.distPath.wasm;
4928
5148
  chain.experiments({
4929
5149
  ...chain.get("experiments"),
4930
5150
  asyncWebAssembly: true
@@ -4979,12 +5199,12 @@ __export(nodeAddons_exports, {
4979
5199
  pluginNodeAddons: () => pluginNodeAddons
4980
5200
  });
4981
5201
  import path10 from "path";
4982
- var getFilename4, pluginNodeAddons;
5202
+ var getFilename3, pluginNodeAddons;
4983
5203
  var init_nodeAddons = __esm({
4984
5204
  "src/plugins/nodeAddons.ts"() {
4985
5205
  "use strict";
4986
5206
  init_esm();
4987
- getFilename4 = (resourcePath) => {
5207
+ getFilename3 = (resourcePath) => {
4988
5208
  let basename2 = "";
4989
5209
  if (resourcePath) {
4990
5210
  const parsed = path10.parse(resourcePath);
@@ -5003,7 +5223,7 @@ var init_nodeAddons = __esm({
5003
5223
  api.transform(
5004
5224
  { test: /\.node$/, targets: ["node"], raw: true },
5005
5225
  ({ code, emitFile, resourcePath }) => {
5006
- const name = getFilename4(resourcePath);
5226
+ const name = getFilename3(resourcePath);
5007
5227
  if (name === null) {
5008
5228
  throw new Error(`Failed to load Node.js addon: "${resourcePath}"`);
5009
5229
  }
@@ -5060,13 +5280,14 @@ var progress_exports = {};
5060
5280
  __export(progress_exports, {
5061
5281
  pluginProgress: () => pluginProgress
5062
5282
  });
5063
- import { TARGET_ID_MAP as TARGET_ID_MAP3, isProd as isProd3 } from "@rsbuild/shared";
5283
+ import { isProd as isProd4 } from "@rsbuild/shared";
5064
5284
  import { rspack as rspack7 } from "@rspack/core";
5065
5285
  var pluginProgress;
5066
5286
  var init_progress = __esm({
5067
5287
  "src/plugins/progress.ts"() {
5068
5288
  "use strict";
5069
5289
  init_esm();
5290
+ init_constants();
5070
5291
  pluginProgress = () => ({
5071
5292
  name: "rsbuild:progress",
5072
5293
  setup(api) {
@@ -5076,11 +5297,11 @@ var init_progress = __esm({
5076
5297
  api.modifyBundlerChain(async (chain, { target, CHAIN_ID: CHAIN_ID3 }) => {
5077
5298
  const config = api.getNormalizedConfig();
5078
5299
  const options = config.dev.progressBar ?? // enable progress bar in production by default
5079
- isProd3();
5300
+ isProd4();
5080
5301
  if (!options) {
5081
5302
  return;
5082
5303
  }
5083
- const prefix = options !== true && options.id !== void 0 ? options.id : TARGET_ID_MAP3[target];
5304
+ const prefix = options !== true && options.id !== void 0 ? options.id : TARGET_ID_MAP[target];
5084
5305
  chain.plugin(CHAIN_ID3.PLUGIN.PROGRESS).use(rspack7.ProgressPlugin, [
5085
5306
  {
5086
5307
  prefix,
@@ -5107,7 +5328,6 @@ import {
5107
5328
  deepmerge as deepmerge5,
5108
5329
  getBrowserslistWithDefault as getBrowserslistWithDefault3,
5109
5330
  getCoreJsVersion,
5110
- isWebTarget,
5111
5331
  reduceConfigs as reduceConfigs2
5112
5332
  } from "@rsbuild/shared";
5113
5333
  async function getDefaultSwcConfig(config, rootPath, target) {
@@ -5170,6 +5390,7 @@ var init_swc = __esm({
5170
5390
  "use strict";
5171
5391
  init_esm();
5172
5392
  init_constants();
5393
+ init_helpers();
5173
5394
  builtinSwcLoaderName = "builtin:swc-loader";
5174
5395
  pluginSwc = () => ({
5175
5396
  name: PLUGIN_SWC_NAME,
@@ -5485,7 +5706,7 @@ __export(open_exports, {
5485
5706
  });
5486
5707
  import { exec } from "child_process";
5487
5708
  import { promisify } from "util";
5488
- import { castArray as castArray6, debug as debug7, logger as logger13 } from "@rsbuild/shared";
5709
+ import { castArray as castArray8 } from "@rsbuild/shared";
5489
5710
  async function openBrowser(url2) {
5490
5711
  const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
5491
5712
  if (shouldTryOpenChromeWithAppleScript) {
@@ -5502,10 +5723,10 @@ async function openBrowser(url2) {
5502
5723
  );
5503
5724
  return true;
5504
5725
  }
5505
- debug7("Failed to find the target browser.");
5726
+ logger.debug("Failed to find the target browser.");
5506
5727
  } catch (err) {
5507
- debug7("Failed to open start URL with apple script.");
5508
- logger13.debug(err);
5728
+ logger.debug("Failed to open start URL with apple script.");
5729
+ logger.debug(err);
5509
5730
  }
5510
5731
  }
5511
5732
  try {
@@ -5513,8 +5734,8 @@ async function openBrowser(url2) {
5513
5734
  await open(url2);
5514
5735
  return true;
5515
5736
  } catch (err) {
5516
- logger13.error("Failed to open start URL.");
5517
- logger13.error(err);
5737
+ logger.error("Failed to open start URL.");
5738
+ logger.error(err);
5518
5739
  return false;
5519
5740
  }
5520
5741
  }
@@ -5584,6 +5805,7 @@ var init_open = __esm({
5584
5805
  init_esm();
5585
5806
  init_constants();
5586
5807
  init_helpers();
5808
+ init_logger();
5587
5809
  execAsync = promisify(exec);
5588
5810
  supportedChromiumBrowsers = [
5589
5811
  "Google Chrome Canary",
@@ -5621,7 +5843,7 @@ var init_open = __esm({
5621
5843
  return { targets: open, before: beforeStartUrl };
5622
5844
  }
5623
5845
  return {
5624
- targets: open.target ? castArray6(open.target) : [],
5846
+ targets: open.target ? castArray8(open.target) : [],
5625
5847
  before: open.before
5626
5848
  };
5627
5849
  };
@@ -5635,7 +5857,6 @@ __export(InlineChunkHtmlPlugin_exports, {
5635
5857
  });
5636
5858
  import { join as join9 } from "path";
5637
5859
  import {
5638
- addTrailingSlash as addTrailingSlash2,
5639
5860
  getPublicPathFromCompiler as getPublicPathFromCompiler3,
5640
5861
  isFunction as isFunction7
5641
5862
  } from "@rsbuild/shared";
@@ -5644,6 +5865,7 @@ var init_InlineChunkHtmlPlugin = __esm({
5644
5865
  "src/rspack/InlineChunkHtmlPlugin.ts"() {
5645
5866
  "use strict";
5646
5867
  init_esm();
5868
+ init_helpers();
5647
5869
  init_pluginHelper();
5648
5870
  InlineChunkHtmlPlugin = class {
5649
5871
  constructor({
@@ -5676,7 +5898,7 @@ var init_InlineChunkHtmlPlugin = __esm({
5676
5898
  const { devtool } = compilation.options;
5677
5899
  if (devtool && // If the source map is inlined, we do not need to update the sourceMappingURL
5678
5900
  !devtool.includes("inline") && source.includes("# sourceMappingURL")) {
5679
- const prefix = addTrailingSlash2(
5901
+ const prefix = addTrailingSlash(
5680
5902
  join9(publicPath, this.distPath[type] || "")
5681
5903
  );
5682
5904
  return source.replace(
@@ -5816,8 +6038,7 @@ __export(inlineChunk_exports, {
5816
6038
  });
5817
6039
  import {
5818
6040
  JS_REGEX as JS_REGEX2,
5819
- isHtmlDisabled as isHtmlDisabled2,
5820
- pick
6041
+ isHtmlDisabled as isHtmlDisabled2
5821
6042
  } from "@rsbuild/shared";
5822
6043
  var pluginInlineChunk;
5823
6044
  var init_inlineChunk = __esm({
@@ -5825,6 +6046,7 @@ var init_inlineChunk = __esm({
5825
6046
  "use strict";
5826
6047
  init_esm();
5827
6048
  init_constants();
6049
+ init_helpers();
5828
6050
  pluginInlineChunk = () => ({
5829
6051
  name: "rsbuild:inline-chunk",
5830
6052
  setup(api) {
@@ -5864,13 +6086,13 @@ var bundleAnalyzer_exports = {};
5864
6086
  __export(bundleAnalyzer_exports, {
5865
6087
  pluginBundleAnalyzer: () => pluginBundleAnalyzer
5866
6088
  });
5867
- import { isProd as isProd4 } from "@rsbuild/shared";
6089
+ import { isProd as isProd5 } from "@rsbuild/shared";
5868
6090
  function pluginBundleAnalyzer() {
5869
6091
  return {
5870
6092
  name: "rsbuild:bundle-analyzer",
5871
6093
  setup(api) {
5872
6094
  api.modifyRsbuildConfig((config) => {
5873
- if (isProd4() || !isUseAnalyzer(config)) {
6095
+ if (isProd5() || !isUseAnalyzer(config)) {
5874
6096
  return;
5875
6097
  }
5876
6098
  config.dev ||= {};
@@ -5909,12 +6131,13 @@ var rsdoctor_exports = {};
5909
6131
  __export(rsdoctor_exports, {
5910
6132
  pluginRsdoctor: () => pluginRsdoctor
5911
6133
  });
5912
- import { color as color12, logger as logger14 } from "@rsbuild/shared";
6134
+ import { color as color13 } from "@rsbuild/shared";
5913
6135
  var pluginRsdoctor;
5914
6136
  var init_rsdoctor = __esm({
5915
6137
  "src/plugins/rsdoctor.ts"() {
5916
6138
  "use strict";
5917
6139
  init_esm();
6140
+ init_logger();
5918
6141
  pluginRsdoctor = () => ({
5919
6142
  name: "rsbuild:rsdoctor",
5920
6143
  setup(api) {
@@ -5931,8 +6154,8 @@ var init_rsdoctor = __esm({
5931
6154
  });
5932
6155
  module = await import(path14);
5933
6156
  } catch (err) {
5934
- logger14.warn(
5935
- `\`process.env.RSDOCTOR\` enabled, please install ${color12.bold(color12.yellow(packageName))} package.`
6157
+ logger.warn(
6158
+ `\`process.env.RSDOCTOR\` enabled, please install ${color13.bold(color13.yellow(packageName))} package.`
5936
6159
  );
5937
6160
  return;
5938
6161
  }
@@ -5953,7 +6176,7 @@ var init_rsdoctor = __esm({
5953
6176
  isAutoRegister = true;
5954
6177
  }
5955
6178
  if (isAutoRegister) {
5956
- logger14.info(`${color12.bold(color12.yellow(packageName))} enabled.`);
6179
+ logger.info(`${color13.bold(color13.yellow(packageName))} enabled.`);
5957
6180
  }
5958
6181
  });
5959
6182
  }
@@ -6112,8 +6335,7 @@ __export(HtmlPreloadOrPrefetchPlugin_exports, {
6112
6335
  HtmlPreloadOrPrefetchPlugin: () => HtmlPreloadOrPrefetchPlugin
6113
6336
  });
6114
6337
  import {
6115
- getPublicPathFromCompiler as getPublicPathFromCompiler4,
6116
- upperFirst as upperFirst2
6338
+ getPublicPathFromCompiler as getPublicPathFromCompiler4
6117
6339
  } from "@rsbuild/shared";
6118
6340
  function filterResourceHints(resourceHints, scripts) {
6119
6341
  return resourceHints.filter(
@@ -6215,7 +6437,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
6215
6437
  apply(compiler) {
6216
6438
  compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
6217
6439
  getHTMLPlugin().getHooks(compilation).beforeAssetTagGeneration.tap(
6218
- `HTML${upperFirst2(this.type)}Plugin`,
6440
+ `HTML${upperFirst(this.type)}Plugin`,
6219
6441
  (htmlPluginData) => {
6220
6442
  this.resourceHints = generateLinks(
6221
6443
  this.options,
@@ -6228,7 +6450,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
6228
6450
  }
6229
6451
  );
6230
6452
  getHTMLPlugin().getHooks(compilation).alterAssetTags.tap(
6231
- `HTML${upperFirst2(this.type)}Plugin`,
6453
+ `HTML${upperFirst(this.type)}Plugin`,
6232
6454
  (htmlPluginData) => {
6233
6455
  if (this.resourceHints) {
6234
6456
  htmlPluginData.assetTags.styles = [
@@ -6636,20 +6858,20 @@ __export(rspackProfile_exports, {
6636
6858
  import inspector from "inspector";
6637
6859
  import path13 from "path";
6638
6860
  import { fse as fse8 } from "@rsbuild/shared";
6639
- import { logger as logger15 } from "@rsbuild/shared";
6640
6861
  import { rspack as rspack9 } from "@rspack/core";
6641
6862
  var stopProfiler, pluginRspackProfile;
6642
6863
  var init_rspackProfile = __esm({
6643
6864
  "src/plugins/rspackProfile.ts"() {
6644
6865
  "use strict";
6645
6866
  init_esm();
6867
+ init_logger();
6646
6868
  stopProfiler = (output, profileSession) => {
6647
6869
  if (!profileSession) {
6648
6870
  return;
6649
6871
  }
6650
6872
  profileSession.post("Profiler.stop", (error, param) => {
6651
6873
  if (error) {
6652
- logger15.error("Failed to generate JS CPU profile:", error);
6874
+ logger.error("Failed to generate JS CPU profile:", error);
6653
6875
  return;
6654
6876
  }
6655
6877
  fse8.writeFileSync(output, JSON.stringify(param.profile));
@@ -6710,7 +6932,7 @@ var init_rspackProfile = __esm({
6710
6932
  rspack9.experimental_cleanupGlobalTrace();
6711
6933
  }
6712
6934
  stopProfiler(cpuProfilePath, profileSession);
6713
- logger15.info(`Saved Rspack profile file to ${profileDir}`);
6935
+ logger.info(`Saved Rspack profile file to ${profileDir}`);
6714
6936
  });
6715
6937
  }
6716
6938
  });
@@ -6722,17 +6944,17 @@ var lazyCompilation_exports = {};
6722
6944
  __export(lazyCompilation_exports, {
6723
6945
  pluginLazyCompilation: () => pluginLazyCompilation
6724
6946
  });
6725
- import { isRegExp } from "@rsbuild/shared";
6726
6947
  var pluginLazyCompilation;
6727
6948
  var init_lazyCompilation = __esm({
6728
6949
  "src/plugins/lazyCompilation.ts"() {
6729
6950
  "use strict";
6730
6951
  init_esm();
6952
+ init_helpers();
6731
6953
  pluginLazyCompilation = () => ({
6732
6954
  name: "rsbuild:lazy-compilation",
6733
6955
  setup(api) {
6734
- api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
6735
- if (isProd6 || target !== "web") {
6956
+ api.modifyBundlerChain((chain, { isProd: isProd7, target }) => {
6957
+ if (isProd7 || target !== "web") {
6736
6958
  return;
6737
6959
  }
6738
6960
  const config = api.getNormalizedConfig();
@@ -6798,9 +7020,7 @@ __export(sri_exports, {
6798
7020
  import crypto2 from "crypto";
6799
7021
  import {
6800
7022
  isHtmlDisabled as isHtmlDisabled4,
6801
- isProd as isProd5,
6802
- logger as logger16,
6803
- removeLeadingSlash as removeLeadingSlash2
7023
+ isProd as isProd6
6804
7024
  } from "@rsbuild/shared";
6805
7025
  var getAssetName, pluginSri;
6806
7026
  var init_sri = __esm({
@@ -6808,11 +7028,13 @@ var init_sri = __esm({
6808
7028
  "use strict";
6809
7029
  init_esm();
6810
7030
  init_constants();
7031
+ init_helpers();
7032
+ init_logger();
6811
7033
  getAssetName = (url2, assetPrefix) => {
6812
7034
  if (url2.startsWith(assetPrefix)) {
6813
- return removeLeadingSlash2(url2.replace(assetPrefix, ""));
7035
+ return removeLeadingSlash(url2.replace(assetPrefix, ""));
6814
7036
  }
6815
- return removeLeadingSlash2(url2);
7037
+ return removeLeadingSlash(url2);
6816
7038
  };
6817
7039
  pluginSri = () => ({
6818
7040
  name: "rsbuild:sri",
@@ -6821,7 +7043,7 @@ var init_sri = __esm({
6821
7043
  const getAlgorithm = () => {
6822
7044
  const config = api.getNormalizedConfig();
6823
7045
  const { sri } = config.security;
6824
- const enable = sri.enable === "auto" ? isProd5() : sri.enable;
7046
+ const enable = sri.enable === "auto" ? isProd6() : sri.enable;
6825
7047
  if (!enable) {
6826
7048
  return null;
6827
7049
  }
@@ -6888,7 +7110,7 @@ var init_sri = __esm({
6888
7110
  `integrity="${integrity}"`
6889
7111
  );
6890
7112
  } else {
6891
- logger16.debug(
7113
+ logger.debug(
6892
7114
  `[rsbuild:sri] failed to generate integrity for ${assetName}.`
6893
7115
  );
6894
7116
  replacedHtml = replacedHtml.replace(
@@ -6960,12 +7182,12 @@ var nonce_exports = {};
6960
7182
  __export(nonce_exports, {
6961
7183
  pluginNonce: () => pluginNonce
6962
7184
  });
6963
- import { applyToCompiler as applyToCompiler2, createVirtualModule as createVirtualModule2 } from "@rsbuild/shared";
6964
7185
  var pluginNonce;
6965
7186
  var init_nonce = __esm({
6966
7187
  "src/plugins/nonce.ts"() {
6967
7188
  "use strict";
6968
7189
  init_esm();
7190
+ init_helpers();
6969
7191
  pluginNonce = () => ({
6970
7192
  name: "rsbuild:nonce",
6971
7193
  setup(api) {
@@ -6974,7 +7196,7 @@ var init_nonce = __esm({
6974
7196
  if (!nonce) {
6975
7197
  return;
6976
7198
  }
6977
- applyToCompiler2(compiler, (compiler2) => {
7199
+ applyToCompiler(compiler, (compiler2) => {
6978
7200
  const { plugins } = compiler2.options;
6979
7201
  const hasHTML = plugins.some(
6980
7202
  (plugin) => plugin && plugin.constructor.name === "HtmlBasicPlugin"
@@ -6982,7 +7204,7 @@ var init_nonce = __esm({
6982
7204
  if (!hasHTML) {
6983
7205
  return;
6984
7206
  }
6985
- const injectCode = createVirtualModule2(
7207
+ const injectCode = createVirtualModule(
6986
7208
  `__webpack_nonce__ = "${nonce}";`
6987
7209
  );
6988
7210
  new compiler2.webpack.EntryPlugin(compiler2.context, injectCode, {
@@ -7022,7 +7244,6 @@ __export(prodServer_exports, {
7022
7244
  import { join as join11 } from "path";
7023
7245
  import {
7024
7246
  getNodeEnv as getNodeEnv8,
7025
- isDebug as isDebug5,
7026
7247
  setNodeEnv as setNodeEnv4
7027
7248
  } from "@rsbuild/shared";
7028
7249
  async function startProdServer(context, config, { getPortSilently } = {}) {
@@ -7101,6 +7322,7 @@ var init_prodServer = __esm({
7101
7322
  "use strict";
7102
7323
  init_esm();
7103
7324
  init_constants();
7325
+ init_logger();
7104
7326
  init_helper();
7105
7327
  init_httpServer();
7106
7328
  init_middlewares();
@@ -7119,7 +7341,7 @@ var init_prodServer = __esm({
7119
7341
  }
7120
7342
  async applyDefaultMiddlewares() {
7121
7343
  const { headers, proxy, historyApiFallback, compress } = this.options.serverConfig;
7122
- if (isDebug5()) {
7344
+ if (logger.level === "verbose") {
7123
7345
  this.middlewares.use(await getRequestLoggerMiddleware());
7124
7346
  }
7125
7347
  if (compress) {
@@ -7196,10 +7418,6 @@ __export(createRsbuild_exports, {
7196
7418
  createRsbuild: () => createRsbuild,
7197
7419
  pickRsbuildConfig: () => pickRsbuildConfig
7198
7420
  });
7199
- import {
7200
- debug as debug8,
7201
- pick as pick2
7202
- } from "@rsbuild/shared";
7203
7421
  async function applyDefaultPlugins(pluginManager, context) {
7204
7422
  const { pluginBasic: pluginBasic2 } = await Promise.resolve().then(() => (init_basic(), basic_exports));
7205
7423
  const { pluginEntry: pluginEntry2 } = await Promise.resolve().then(() => (init_entry(), entry_exports));
@@ -7289,9 +7507,9 @@ async function createRsbuild(options = {}) {
7289
7507
  );
7290
7508
  const pluginAPI = getPluginAPI({ context, pluginManager });
7291
7509
  context.pluginAPI = pluginAPI;
7292
- debug8("add default plugins");
7510
+ logger.debug("add default plugins");
7293
7511
  await applyDefaultPlugins(pluginManager, context);
7294
- debug8("add default plugins done");
7512
+ logger.debug("add default plugins done");
7295
7513
  const provider = rsbuildConfig.provider || await getRspackProvider();
7296
7514
  const providerInstance = await provider({
7297
7515
  context,
@@ -7305,13 +7523,13 @@ async function createRsbuild(options = {}) {
7305
7523
  return startProdServer2(context, config, options2);
7306
7524
  };
7307
7525
  const rsbuild = {
7308
- ...pick2(pluginManager, [
7526
+ ...pick(pluginManager, [
7309
7527
  "addPlugins",
7310
7528
  "getPlugins",
7311
7529
  "removePlugins",
7312
7530
  "isPluginExists"
7313
7531
  ]),
7314
- ...pick2(pluginAPI, [
7532
+ ...pick(pluginAPI, [
7315
7533
  "onBeforeBuild",
7316
7534
  "onBeforeCreateCompiler",
7317
7535
  "onBeforeStartDevServer",
@@ -7327,7 +7545,7 @@ async function createRsbuild(options = {}) {
7327
7545
  "getRsbuildConfig",
7328
7546
  "getNormalizedConfig"
7329
7547
  ]),
7330
- ...pick2(providerInstance, [
7548
+ ...pick(providerInstance, [
7331
7549
  "build",
7332
7550
  "initConfigs",
7333
7551
  "inspectConfig",
@@ -7350,8 +7568,10 @@ var init_createRsbuild = __esm({
7350
7568
  "use strict";
7351
7569
  init_esm();
7352
7570
  init_createContext();
7571
+ init_helpers();
7353
7572
  init_initPlugins();
7354
7573
  init_internal();
7574
+ init_logger();
7355
7575
  init_pluginHelper();
7356
7576
  init_pluginManager();
7357
7577
  getRspackProvider = async () => {
@@ -7369,15 +7589,16 @@ var init_createRsbuild = __esm({
7369
7589
  "security",
7370
7590
  "performance",
7371
7591
  "moduleFederation",
7592
+ "environments",
7372
7593
  "_privateMeta"
7373
7594
  ];
7374
- return pick2(rsbuildConfig, keys);
7595
+ return pick(rsbuildConfig, keys);
7375
7596
  };
7376
7597
  }
7377
7598
  });
7378
7599
 
7379
7600
  // src/cli/init.ts
7380
- import { isDev as isDev2, logger as logger17 } from "@rsbuild/shared";
7601
+ import { isDev as isDev2 } from "@rsbuild/shared";
7381
7602
  async function init({
7382
7603
  cliOptions,
7383
7604
  isRestart
@@ -7431,7 +7652,7 @@ async function init({
7431
7652
  });
7432
7653
  } catch (err) {
7433
7654
  if (isRestart) {
7434
- logger17.error(err);
7655
+ logger.error(err);
7435
7656
  } else {
7436
7657
  throw err;
7437
7658
  }
@@ -7444,6 +7665,7 @@ var init_init = __esm({
7444
7665
  init_esm();
7445
7666
  init_config();
7446
7667
  init_loadEnv();
7668
+ init_logger();
7447
7669
  init_restart();
7448
7670
  commonOpts = {};
7449
7671
  }
@@ -7452,10 +7674,10 @@ var init_init = __esm({
7452
7674
  // src/cli/commands.ts
7453
7675
  import { existsSync } from "fs";
7454
7676
  import { join as join12 } from "path";
7455
- import { color as color13, logger as logger18 } from "@rsbuild/shared";
7677
+ import { color as color14 } from "@rsbuild/shared";
7456
7678
  import { program } from "../compiled/commander/index.js";
7457
7679
  function runCli() {
7458
- program.name("rsbuild").usage("<command> [options]").version("0.7.8");
7680
+ program.name("rsbuild").usage("<command> [options]").version("0.7.9");
7459
7681
  const devCommand = program.command("dev");
7460
7682
  const buildCommand = program.command("build");
7461
7683
  const previewCommand = program.command("preview");
@@ -7469,8 +7691,8 @@ function runCli() {
7469
7691
  const rsbuild = await init({ cliOptions: options });
7470
7692
  await rsbuild?.startDevServer();
7471
7693
  } catch (err) {
7472
- logger18.error("Failed to start dev server.");
7473
- logger18.error(err);
7694
+ logger.error("Failed to start dev server.");
7695
+ logger.error(err);
7474
7696
  process.exit(1);
7475
7697
  }
7476
7698
  });
@@ -7481,8 +7703,8 @@ function runCli() {
7481
7703
  watch: options.watch
7482
7704
  });
7483
7705
  } catch (err) {
7484
- logger18.error("Failed to build.");
7485
- logger18.error(err);
7706
+ logger.error("Failed to build.");
7707
+ logger.error(err);
7486
7708
  process.exit(1);
7487
7709
  }
7488
7710
  });
@@ -7493,14 +7715,14 @@ function runCli() {
7493
7715
  const { distPath } = rsbuild.context;
7494
7716
  if (!existsSync(distPath)) {
7495
7717
  throw new Error(
7496
- `The output directory ${color13.yellow(
7718
+ `The output directory ${color14.yellow(
7497
7719
  distPath
7498
7720
  )} does not exist, please build the project before previewing.`
7499
7721
  );
7500
7722
  }
7501
7723
  if (isEmptyDir(distPath)) {
7502
7724
  throw new Error(
7503
- `The output directory ${color13.yellow(
7725
+ `The output directory ${color14.yellow(
7504
7726
  distPath
7505
7727
  )} is empty, please build the project before previewing.`
7506
7728
  );
@@ -7508,8 +7730,8 @@ function runCli() {
7508
7730
  }
7509
7731
  await rsbuild?.preview();
7510
7732
  } catch (err) {
7511
- logger18.error("Failed to start preview server.");
7512
- logger18.error(err);
7733
+ logger.error("Failed to start preview server.");
7734
+ logger.error(err);
7513
7735
  process.exit(1);
7514
7736
  }
7515
7737
  });
@@ -7523,8 +7745,8 @@ function runCli() {
7523
7745
  writeToDisk: true
7524
7746
  });
7525
7747
  } catch (err) {
7526
- logger18.error("Failed to inspect config.");
7527
- logger18.error(err);
7748
+ logger.error("Failed to inspect config.");
7749
+ logger.error(err);
7528
7750
  process.exit(1);
7529
7751
  }
7530
7752
  });
@@ -7536,6 +7758,7 @@ var init_commands = __esm({
7536
7758
  "use strict";
7537
7759
  init_esm();
7538
7760
  init_helpers();
7761
+ init_logger();
7539
7762
  init_init();
7540
7763
  applyCommonOptions = (command) => {
7541
7764
  command.option(
@@ -7553,7 +7776,6 @@ var init_commands = __esm({
7553
7776
  });
7554
7777
 
7555
7778
  // src/cli/prepare.ts
7556
- import { logger as logger19 } from "@rsbuild/shared";
7557
7779
  function initNodeEnv() {
7558
7780
  if (!process.env.NODE_ENV) {
7559
7781
  const command = process.argv[2];
@@ -7566,20 +7788,23 @@ function prepareCli() {
7566
7788
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7567
7789
  console.log();
7568
7790
  }
7569
- logger19.greet(` ${`Rsbuild v${"0.7.8"}`}
7791
+ logger.greet(` ${`Rsbuild v${"0.7.9"}`}
7570
7792
  `);
7571
7793
  }
7572
7794
  var init_prepare = __esm({
7573
7795
  "src/cli/prepare.ts"() {
7574
7796
  "use strict";
7575
7797
  init_esm();
7798
+ init_logger();
7576
7799
  }
7577
7800
  });
7578
7801
 
7579
7802
  // src/internal.ts
7580
7803
  var internal_exports = {};
7581
7804
  __export(internal_exports, {
7805
+ TARGET_ID_MAP: () => TARGET_ID_MAP,
7582
7806
  applySwcDecoratorConfig: () => applySwcDecoratorConfig,
7807
+ chainToConfig: () => chainToConfig,
7583
7808
  createDevServer: () => createDevServer,
7584
7809
  createPluginManager: () => createPluginManager,
7585
7810
  formatStats: () => formatStats,
@@ -7591,6 +7816,8 @@ __export(internal_exports, {
7591
7816
  initHooks: () => initHooks,
7592
7817
  initPlugins: () => initPlugins,
7593
7818
  initRsbuildConfig: () => initRsbuildConfig,
7819
+ modifyBundlerChain: () => modifyBundlerChain,
7820
+ onCompileDone: () => onCompileDone,
7594
7821
  outputInspectConfigFiles: () => outputInspectConfigFiles,
7595
7822
  prepareCli: () => prepareCli,
7596
7823
  runCli: () => runCli,
@@ -7610,10 +7837,12 @@ var init_internal = __esm({
7610
7837
  init_pluginHelper();
7611
7838
  init_helpers();
7612
7839
  init_rspackConfig();
7840
+ init_configChain();
7613
7841
  init_swc();
7614
7842
  init_minimize();
7615
7843
  init_devMiddleware();
7616
7844
  init_devServer();
7845
+ init_constants();
7617
7846
  }
7618
7847
  });
7619
7848
 
@@ -7623,12 +7852,12 @@ init_internal();
7623
7852
  init_loadEnv();
7624
7853
  init_createRsbuild();
7625
7854
  init_config();
7855
+ init_logger();
7626
7856
  init_mergeConfig();
7627
7857
  init_helpers();
7628
7858
  init_constants();
7629
7859
  import { rspack as rspack10 } from "@rspack/core";
7630
- import { logger as logger20 } from "@rsbuild/shared";
7631
- var version = "0.7.8";
7860
+ var version = "0.7.9";
7632
7861
  export {
7633
7862
  PLUGIN_CSS_NAME,
7634
7863
  PLUGIN_SWC_NAME,
@@ -7638,7 +7867,7 @@ export {
7638
7867
  ensureAssetPrefix,
7639
7868
  loadConfig,
7640
7869
  loadEnv,
7641
- logger20 as logger,
7870
+ logger,
7642
7871
  mergeRsbuildConfig,
7643
7872
  rspack10 as rspack,
7644
7873
  version