@rsbuild/core 1.6.0-beta.0 → 1.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 6129: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 4904: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(7843);
5
+ const loader = __nccwpck_require__(7558);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(3118).defaultGetLocalIdent;
8
+ __nccwpck_require__(5015).defaultGetLocalIdent;
9
9
  },
10
- 7843: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 7558: (__unused_webpack_module, exports, __nccwpck_require__) => {
11
11
  "use strict";
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports["default"] = loader;
14
14
  var _postcss = _interopRequireDefault(__nccwpck_require__(1259));
15
- var _plugins = __nccwpck_require__(4704);
16
- var _utils = __nccwpck_require__(3118);
15
+ var _plugins = __nccwpck_require__(1997);
16
+ var _utils = __nccwpck_require__(5015);
17
17
  function _interopRequireDefault(obj) {
18
18
  return obj && obj.__esModule ? obj : { default: obj };
19
19
  }
@@ -236,7 +236,7 @@
236
236
  callback(null, `${importCode}${moduleCode}${exportCode}`);
237
237
  }
238
238
  },
239
- 4704: (__unused_webpack_module, exports, __nccwpck_require__) => {
239
+ 1997: (__unused_webpack_module, exports, __nccwpck_require__) => {
240
240
  "use strict";
241
241
  Object.defineProperty(exports, "__esModule", { value: true });
242
242
  Object.defineProperty(exports, "icssParser", {
@@ -258,22 +258,22 @@
258
258
  },
259
259
  });
260
260
  var _postcssImportParser = _interopRequireDefault(
261
- __nccwpck_require__(8099),
261
+ __nccwpck_require__(7102),
262
262
  );
263
263
  var _postcssIcssParser = _interopRequireDefault(
264
- __nccwpck_require__(4094),
264
+ __nccwpck_require__(8927),
265
265
  );
266
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(3769));
266
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(7402));
267
267
  function _interopRequireDefault(obj) {
268
268
  return obj && obj.__esModule ? obj : { default: obj };
269
269
  }
270
270
  },
271
- 4094: (__unused_webpack_module, exports, __nccwpck_require__) => {
271
+ 8927: (__unused_webpack_module, exports, __nccwpck_require__) => {
272
272
  "use strict";
273
273
  Object.defineProperty(exports, "__esModule", { value: true });
274
274
  exports["default"] = void 0;
275
275
  var _icssUtils = __nccwpck_require__(9028);
276
- var _utils = __nccwpck_require__(3118);
276
+ var _utils = __nccwpck_require__(5015);
277
277
  const plugin = (options = {}) => ({
278
278
  postcssPlugin: "postcss-icss-parser",
279
279
  async OnceExit(root) {
@@ -372,14 +372,14 @@
372
372
  plugin.postcss = true;
373
373
  var _default = (exports["default"] = plugin);
374
374
  },
375
- 8099: (__unused_webpack_module, exports, __nccwpck_require__) => {
375
+ 7102: (__unused_webpack_module, exports, __nccwpck_require__) => {
376
376
  "use strict";
377
377
  Object.defineProperty(exports, "__esModule", { value: true });
378
378
  exports["default"] = void 0;
379
379
  var _postcssValueParser = _interopRequireDefault(
380
380
  __nccwpck_require__(2948),
381
381
  );
382
- var _utils = __nccwpck_require__(3118);
382
+ var _utils = __nccwpck_require__(5015);
383
383
  function _interopRequireDefault(obj) {
384
384
  return obj && obj.__esModule ? obj : { default: obj };
385
385
  }
@@ -684,14 +684,14 @@
684
684
  plugin.postcss = true;
685
685
  var _default = (exports["default"] = plugin);
686
686
  },
687
- 3769: (__unused_webpack_module, exports, __nccwpck_require__) => {
687
+ 7402: (__unused_webpack_module, exports, __nccwpck_require__) => {
688
688
  "use strict";
689
689
  Object.defineProperty(exports, "__esModule", { value: true });
690
690
  exports["default"] = void 0;
691
691
  var _postcssValueParser = _interopRequireDefault(
692
692
  __nccwpck_require__(2948),
693
693
  );
694
- var _utils = __nccwpck_require__(3118);
694
+ var _utils = __nccwpck_require__(5015);
695
695
  function _interopRequireDefault(obj) {
696
696
  return obj && obj.__esModule ? obj : { default: obj };
697
697
  }
@@ -1034,7 +1034,7 @@
1034
1034
  plugin.postcss = true;
1035
1035
  var _default = (exports["default"] = plugin);
1036
1036
  },
1037
- 3118: (__unused_webpack_module, exports, __nccwpck_require__) => {
1037
+ 5015: (__unused_webpack_module, exports, __nccwpck_require__) => {
1038
1038
  "use strict";
1039
1039
  Object.defineProperty(exports, "__esModule", { value: true });
1040
1040
  exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
@@ -8098,6 +8098,6 @@
8098
8098
  }
8099
8099
  if (typeof __nccwpck_require__ !== "undefined")
8100
8100
  __nccwpck_require__.ab = __dirname + "/";
8101
- var __webpack_exports__ = __nccwpck_require__(6129);
8101
+ var __webpack_exports__ = __nccwpck_require__(4904);
8102
8102
  module.exports = __webpack_exports__;
8103
8103
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 72: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 173: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(621);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(382);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -311,7 +311,7 @@
311
311
  }
312
312
  module.exports = { CachedChildCompilation };
313
313
  },
314
- 621: (module) => {
314
+ 382: (module) => {
315
315
  "use strict";
316
316
  class HtmlWebpackChildCompiler {
317
317
  constructor(templates) {
@@ -480,7 +480,7 @@
480
480
  }
481
481
  module.exports = { HtmlWebpackChildCompiler };
482
482
  },
483
- 667: (module) => {
483
+ 494: (module) => {
484
484
  "use strict";
485
485
  module.exports = {};
486
486
  module.exports.none = (chunks) => chunks;
@@ -499,7 +499,7 @@
499
499
  };
500
500
  module.exports.auto = module.exports.none;
501
501
  },
502
- 902: (module) => {
502
+ 321: (module) => {
503
503
  "use strict";
504
504
  module.exports = function (err) {
505
505
  return {
@@ -520,7 +520,7 @@
520
520
  };
521
521
  };
522
522
  },
523
- 661: (module, __unused_webpack_exports, __nccwpck_require__) => {
523
+ 368: (module, __unused_webpack_exports, __nccwpck_require__) => {
524
524
  "use strict";
525
525
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
526
526
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -546,7 +546,7 @@
546
546
  }
547
547
  module.exports = { getHtmlRspackPluginHooks };
548
548
  },
549
- 332: (module) => {
549
+ 421: (module) => {
550
550
  const voidTags = [
551
551
  "area",
552
552
  "base",
@@ -614,19 +614,19 @@
614
614
  htmlTagObjectToString,
615
615
  };
616
616
  },
617
- 873: (module, __unused_webpack_exports, __nccwpck_require__) => {
617
+ 896: (module, __unused_webpack_exports, __nccwpck_require__) => {
618
618
  "use strict";
619
619
  const promisify = __nccwpck_require__(23).promisify;
620
620
  const vm = __nccwpck_require__(154);
621
- const fs = __nccwpck_require__(896);
621
+ const fs = __nccwpck_require__(515);
622
622
  const path = __nccwpck_require__(928);
623
- const { CachedChildCompilation } = __nccwpck_require__(72);
623
+ const { CachedChildCompilation } = __nccwpck_require__(173);
624
624
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
625
- __nccwpck_require__(332);
626
- const prettyError = __nccwpck_require__(902);
627
- const chunkSorter = __nccwpck_require__(667);
625
+ __nccwpck_require__(421);
626
+ const prettyError = __nccwpck_require__(321);
627
+ const chunkSorter = __nccwpck_require__(494);
628
628
  const getHtmlRspackPluginHooks =
629
- __nccwpck_require__(661).getHtmlRspackPluginHooks;
629
+ __nccwpck_require__(368).getHtmlRspackPluginHooks;
630
630
  const WITH_PLACEHOLDER = "function __with_placeholder__";
631
631
  class HtmlRspackPlugin {
632
632
  constructor(userOptions = {}) {
@@ -1558,7 +1558,7 @@
1558
1558
  "use strict";
1559
1559
  module.exports = require("@rspack/lite-tapable");
1560
1560
  },
1561
- 896: (module) => {
1561
+ 515: (module) => {
1562
1562
  "use strict";
1563
1563
  module.exports = require("fs");
1564
1564
  },
@@ -1597,6 +1597,6 @@
1597
1597
  }
1598
1598
  if (typeof __nccwpck_require__ !== "undefined")
1599
1599
  __nccwpck_require__.ab = __dirname + "/";
1600
- var __webpack_exports__ = __nccwpck_require__(873);
1600
+ var __webpack_exports__ = __nccwpck_require__(896);
1601
1601
  module.exports = __webpack_exports__;
1602
1602
  })();
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 202: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(256)["default"];
4
+ 471: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(817)["default"];
6
6
  },
7
- 256: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 817: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
12
- var _utils = __nccwpck_require__(889);
12
+ var _utils = __nccwpck_require__(724);
13
13
  function _interopRequireDefault(e) {
14
14
  return e && e.__esModule ? e : { default: e };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 889: (module, exports, __nccwpck_require__) => {
182
+ 724: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -715,6 +715,6 @@
715
715
  })();
716
716
  if (typeof __nccwpck_require__ !== "undefined")
717
717
  __nccwpck_require__.ab = __dirname + "/";
718
- var __webpack_exports__ = __nccwpck_require__(202);
718
+ var __webpack_exports__ = __nccwpck_require__(471);
719
719
  module.exports = __webpack_exports__;
720
720
  })();
@@ -100,6 +100,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
100
100
  if ('truecolor' === env.COLORTERM) return 3;
101
101
  if ('xterm-kitty' === env.TERM) return 3;
102
102
  if ('xterm-ghostty' === env.TERM) return 3;
103
+ if ('wezterm' === env.TERM) return 3;
103
104
  if ('TERM_PROGRAM' in env) {
104
105
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
105
106
  switch(env.TERM_PROGRAM){
@@ -234,6 +235,14 @@ let LOG_TYPES = {
234
235
  color: magenta
235
236
  }
236
237
  };
238
+ const normalizeErrorMessage = (err)=>{
239
+ if (err.stack) {
240
+ let [name, ...rest] = err.stack.split('\n');
241
+ if (name.startsWith('Error: ')) name = name.slice(7);
242
+ return `${name}\n${gray(rest.join('\n'))}`;
243
+ }
244
+ return err.message;
245
+ };
237
246
  let createLogger = (options = {})=>{
238
247
  let maxLevel = options.level || 'info';
239
248
  let log = (type, message, ...args)=>{
@@ -246,12 +255,14 @@ let createLogger = (options = {})=>{
246
255
  label = (logType.label || '').padEnd(7);
247
256
  label = bold(logType.color ? logType.color(label) : label);
248
257
  }
249
- if (message instanceof Error) if (message.stack) {
250
- let [name, ...rest] = message.stack.split('\n');
251
- if (name.startsWith('Error: ')) name = name.slice(7);
252
- text = `${name}\n${gray(rest.join('\n'))}`;
253
- } else text = message.message;
254
- else if ('error' === logType.level && 'string' == typeof message) {
258
+ if (message instanceof Error) {
259
+ text += normalizeErrorMessage(message);
260
+ const { cause } = message;
261
+ if (cause) {
262
+ text += yellow('\n [cause]: ');
263
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
264
+ }
265
+ } else if ('error' === logType.level && 'string' == typeof message) {
255
266
  let lines = message.split('\n');
256
267
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
257
268
  } else text = `${message}`;
@@ -1 +1 @@
1
- {"name":"rslog","version":"1.2.11","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"rslog","version":"1.3.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 683: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 588: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.transformFiles =
7
7
  exports.reduceChunk =
@@ -120,7 +120,7 @@
120
120
  .map(standardizeFilePaths);
121
121
  exports.transformFiles = transformFiles;
122
122
  },
123
- 694: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 45: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
124
  Object.defineProperty(exports, "__esModule", { value: true });
125
125
  exports.normalModuleLoaderHook =
126
126
  exports.getCompilerHooks =
@@ -130,7 +130,7 @@
130
130
  const node_fs_1 = __nccwpck_require__(24);
131
131
  const node_path_1 = __nccwpck_require__(760);
132
132
  const lite_tapable_1 = __nccwpck_require__(408);
133
- const helpers_1 = __nccwpck_require__(683);
133
+ const helpers_1 = __nccwpck_require__(588);
134
134
  const compilerHookMap = new WeakMap();
135
135
  const getCompilerHooks = (compiler) => {
136
136
  let hooks = compilerHookMap.get(compiler);
@@ -313,7 +313,7 @@
313
313
  exports.getCompilerHooks =
314
314
  void 0;
315
315
  const node_path_1 = __nccwpck_require__(760);
316
- const hooks_1 = __nccwpck_require__(694);
316
+ const hooks_1 = __nccwpck_require__(45);
317
317
  Object.defineProperty(exports, "getCompilerHooks", {
318
318
  enumerable: true,
319
319
  get: function () {
package/dist/index.cjs CHANGED
@@ -1712,7 +1712,7 @@ for(var __webpack_i__ in (()=>{
1712
1712
  var external_node_module_ = __webpack_require__("node:module");
1713
1713
  let rspack_rspack = (0, external_node_module_.createRequire)(__rslib_import_meta_url__)('@rspack/core');
1714
1714
  var external_node_path_ = __webpack_require__("node:path"), external_node_path_default = __webpack_require__.n(external_node_path_), external_node_url_ = __webpack_require__("node:url");
1715
- let constants_filename = (0, external_node_url_.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno = 'undefined' != typeof Deno, ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
1715
+ let constants_filename = (0, external_node_url_.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno = 'undefined' != typeof Deno, isWindows = 'win32' === process.platform, ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
1716
1716
  'chrome >= 87',
1717
1717
  'edge >= 88',
1718
1718
  'firefox >= 78',
@@ -3168,7 +3168,7 @@ ${section.body}` : section.body).join("\n\n"));
3168
3168
  })(message = function(message) {
3169
3169
  let hint = 'You may need an appropriate loader to handle this file type.';
3170
3170
  if (-1 === message.indexOf(hint)) return message;
3171
- let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${color.yellow(`@rsbuild/plugin-${packageName}`)}" ${color.dim(`(https://npmjs.com/package/@rsbuild/plugin-${packageName})`)}.`;
3171
+ let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${color.yellow(`@rsbuild/plugin-${packageName}`)}" ${color.dim(`(https://npmjs.com/package/@rsbuild/plugin-${packageName})`)}.\n`;
3172
3172
  for (let plugin of [
3173
3173
  {
3174
3174
  test: /File: .+\.s(c|a)ss/,
@@ -3269,7 +3269,7 @@ ${section.body}` : section.body).join("\n\n"));
3269
3269
  }
3270
3270
  return {};
3271
3271
  }
3272
- let rspackMinVersion = '1.5.0', external_node_fs_namespaceObject = require("node:fs");
3272
+ let external_node_fs_namespaceObject = require("node:fs");
3273
3273
  var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
3274
3274
  class BrowserslistError extends Error {
3275
3275
  constructor(message){
@@ -3356,7 +3356,7 @@ ${section.body}` : section.body).join("\n\n"));
3356
3356
  } catch {
3357
3357
  return url;
3358
3358
  }
3359
- }, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === external_node_path_.sep ? filepath : filepath.replace(/\\/g, '/'), isFileSync = (filePath)=>{
3359
+ }, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === external_node_path_.sep ? filepath : filepath.replace(/\\/g, '/'), normalizeRuleConditionPath = (filepath)=>isWindows && 'string' == typeof filepath && filepath.includes('/') && external_node_path_.win32.isAbsolute(filepath) ? filepath.replace(/\//g, '\\') : filepath, isFileSync = (filePath)=>{
3360
3360
  try {
3361
3361
  return external_node_fs_default().statSync(filePath, {
3362
3362
  throwIfNoEntry: !1
@@ -3421,14 +3421,10 @@ ${section.body}` : section.body).join("\n\n"));
3421
3421
  x,
3422
3422
  y
3423
3423
  ];
3424
- if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
3424
+ if (pair.some(Array.isArray)) return [
3425
3425
  ...helpers_castArray(x),
3426
3426
  ...helpers_castArray(y)
3427
- ] : Array.isArray(x) ? merge({
3428
- patterns: x
3429
- }, y, path) : merge(x, {
3430
- patterns: y
3431
- }, path);
3427
+ ];
3432
3428
  if (pair.some(isFunction)) return pair;
3433
3429
  if (!isPlainObject(x) || !isPlainObject(y)) return y;
3434
3430
  let merged = {};
@@ -3440,7 +3436,27 @@ ${section.body}` : section.body).join("\n\n"));
3440
3436
  merged[key] = merge(x[key], y[key], childPath);
3441
3437
  }
3442
3438
  return merged;
3443
- }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), defaultConfig_require = (0, external_node_module_.createRequire)(__rslib_import_meta_url__), defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
3439
+ }, normalizeConfigStructure = (config)=>{
3440
+ let { dev, output, ...rest } = config;
3441
+ return output && (Array.isArray((output = {
3442
+ ...output
3443
+ }).copy) && (output.copy = {
3444
+ patterns: output.copy
3445
+ }), 'string' == typeof output.distPath && (output.distPath = {
3446
+ root: output.distPath
3447
+ })), dev && (dev = {
3448
+ ...dev
3449
+ }).watchFiles && !Array.isArray(dev.watchFiles) && (dev.watchFiles = [
3450
+ dev.watchFiles
3451
+ ]), {
3452
+ ...rest,
3453
+ dev,
3454
+ output
3455
+ };
3456
+ }, mergeRsbuildConfig = (...originalConfigs)=>{
3457
+ let configs = originalConfigs.map(normalizeConfigStructure);
3458
+ return 2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {});
3459
+ }, defaultConfig_require = (0, external_node_module_.createRequire)(__rslib_import_meta_url__), defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
3444
3460
  dev: {
3445
3461
  hmr: !0,
3446
3462
  liveReload: !0,
@@ -3586,25 +3602,6 @@ ${section.body}` : section.body).join("\n\n"));
3586
3602
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
3587
3603
  }
3588
3604
  return merged;
3589
- }, normalizeConfigStructure = (config, rootPath)=>{
3590
- let { dev, output } = config;
3591
- return config.server ||= {}, config.server.publicDir = normalizePublicDirs(rootPath, config.server.publicDir), 'string' == typeof output?.distPath && (config = {
3592
- ...config,
3593
- output: {
3594
- ...output,
3595
- distPath: {
3596
- root: output.distPath
3597
- }
3598
- }
3599
- }), dev?.watchFiles && !Array.isArray(dev.watchFiles) && (config = {
3600
- ...config,
3601
- dev: {
3602
- ...dev,
3603
- watchFiles: [
3604
- dev.watchFiles
3605
- ]
3606
- }
3607
- }), config;
3608
3605
  }, normalizePublicDirs = (rootPath, publicDir)=>{
3609
3606
  if (!1 === publicDir) return [];
3610
3607
  let defaultConfig = {
@@ -3828,7 +3825,7 @@ ${section.body}` : section.body).join("\n\n"));
3828
3825
  async function createContext(options, userConfig) {
3829
3826
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
3830
3827
  return {
3831
- version: "1.6.0-beta.0",
3828
+ version: "1.6.0-beta.1",
3832
3829
  rootPath,
3833
3830
  distPath: '',
3834
3831
  cachePath,
@@ -4240,14 +4237,14 @@ ${section.body}` : section.body).join("\n\n"));
4240
4237
  context,
4241
4238
  pluginManager
4242
4239
  }), await modifyRsbuildConfig(context);
4243
- let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, mergeRsbuildConfig({
4240
+ let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.publicDir = normalizePublicDirs(rootPath, config.server.publicDir), mergeRsbuildConfig({
4244
4241
  ...createDefaultConfig(),
4245
4242
  mode: (()=>{
4246
4243
  if (config.mode) return config.mode;
4247
4244
  let nodeEnv = process.env.NODE_ENV || '';
4248
4245
  return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
4249
4246
  })()
4250
- }, normalizeConfigStructure(config, rootPath))), environments = {}, mergedEnvironments = ((normalizedConfig, rootPath, specifiedEnvironments)=>{
4247
+ }, config)), environments = {}, mergedEnvironments = ((normalizedConfig, rootPath, specifiedEnvironments)=>{
4251
4248
  let defaultEntry, { environments, dev, server: _server, provider: _provider, ...baseConfig } = normalizedConfig, isEnvironmentEnabled = (name)=>!specifiedEnvironments || specifiedEnvironments.includes(name), applyEnvironmentDefaultConfig = (config)=>{
4252
4249
  var root;
4253
4250
  let entryFile;
@@ -4273,7 +4270,7 @@ ${section.body}` : section.body).join("\n\n"));
4273
4270
  ...mergeRsbuildConfig({
4274
4271
  ...baseConfig,
4275
4272
  dev: pick(dev, allowedEnvironmentDevKeys)
4276
- }, normalizeConfigStructure(config, rootPath))
4273
+ }, config)
4277
4274
  })
4278
4275
  ]));
4279
4276
  if (0 === Object.keys(resolvedEnvironments).length) throw createEnvironmentNotFoundError(specifiedEnvironments);
@@ -4384,8 +4381,10 @@ ${section.body}` : section.body).join("\n\n"));
4384
4381
  if (item1 < item2) return -1;
4385
4382
  }
4386
4383
  return 0;
4387
- })(version, rspackMinVersion) >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green(rspackMinVersion)}`);
4388
- let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
4384
+ })(version, '1.5.0') >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green("1.5.0")}`);
4385
+ let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]);
4386
+ 'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
4387
+ let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
4389
4388
  isVersionLogged || (logger.debug(`using Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
4390
4389
  }, lazyModules = new Set();
4391
4390
  return compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
@@ -6372,12 +6371,16 @@ ${section.body}` : section.body).join("\n\n"));
6372
6371
  let rawLocation = external_node_path_default().relative(context.rootPath, source);
6373
6372
  return null !== line && (rawLocation += null === column ? `:${line}` : `:${line}:${column}`), rawLocation;
6374
6373
  }, formatBrowserErrorLog = async (message, context, fs)=>{
6375
- let log = `${color.cyan('[browser]')} ${color.red(message.message)}`;
6374
+ var log;
6375
+ let log1 = `${color.cyan('[browser]')} ${color.red(message.message)}`;
6376
6376
  if (message.stack) {
6377
6377
  let rawLocation = await formatErrorLocation(message.stack, context, fs);
6378
- rawLocation && (log += color.dim(` (${rawLocation})`));
6378
+ rawLocation && (log1 += color.dim(` (${rawLocation})`));
6379
6379
  }
6380
- return log;
6380
+ return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${color.yellow(` - \`process\` is a Node.js global and not available in browsers.
6381
+ - To access \`process.env.*\`, define them in a \`.env\` file with the \`PUBLIC_\` prefix.
6382
+ - Or configure them via \`source.define\`.
6383
+ - Alternatively, install \`@rsbuild/plugin-node-polyfill\` to polyfill Node.js globals.`)}` : log;
6381
6384
  }, styles = {
6382
6385
  1: 'font-weight:bold',
6383
6386
  2: 'opacity:0.5',
@@ -8143,7 +8146,6 @@ ${section.body}` : section.body).join("\n\n"));
8143
8146
  }
8144
8147
  }), chain.experiments({
8145
8148
  ...chain.get('experiments'),
8146
- lazyBarrel: !0,
8147
8149
  inlineEnum: isProd,
8148
8150
  inlineConst: isProd,
8149
8151
  typeReexportsPresence: !0,
@@ -8152,7 +8154,7 @@ ${section.body}` : section.body).join("\n\n"));
8152
8154
  force: !1
8153
8155
  }
8154
8156
  }
8155
- })), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-silent';
8157
+ }));
8156
8158
  });
8157
8159
  }
8158
8160
  },
@@ -9009,8 +9011,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9009
9011
  if (!function({ rule, isDev, config, rsbuildTarget }) {
9010
9012
  for (let condition of (rule.include.add({
9011
9013
  not: NODE_MODULES_REGEX
9012
- }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(condition);
9013
- for (let condition of config.source.exclude || [])rule.exclude.add(condition);
9014
+ }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(normalizeRuleConditionPath(condition));
9015
+ for (let condition of config.source.exclude || [])rule.exclude.add(normalizeRuleConditionPath(condition));
9014
9016
  }({
9015
9017
  rule,
9016
9018
  isDev,
@@ -9105,11 +9107,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9105
9107
  api.modifyBundlerChain((chain, { environment, target })=>{
9106
9108
  let { config } = environment;
9107
9109
  if (config.output.module) {
9108
- if ('web' === target && (api.logger.warn('[rsbuild:config] `output.module` for web target is experimental and may not work as expected.'), chain.optimization.runtimeChunk(!0)), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
9109
- chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import').library({
9110
+ if ('web' === target && chain.optimization.runtimeChunk(!0), 'node' === target && chain.output.library({
9110
9111
  ...chain.output.get('library'),
9111
9112
  type: 'module'
9112
- }), chain.experiments({
9113
+ }), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
9114
+ chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'), chain.experiments({
9113
9115
  ...chain.get('experiments'),
9114
9116
  outputModule: !0
9115
9117
  });
@@ -9260,7 +9262,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9260
9262
  return;
9261
9263
  }
9262
9264
  try {
9263
- let moduleURL = 'win32' === process.platform ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
9265
+ let moduleURL = isWindows ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
9264
9266
  module = await import(moduleURL);
9265
9267
  } catch {
9266
9268
  logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
@@ -9905,11 +9907,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9905
9907
  }
9906
9908
  !function() {
9907
9909
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9908
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.0-beta.0\n`);
9910
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.0-beta.1\n`);
9909
9911
  }();
9910
9912
  try {
9911
9913
  let cli, devDescription, devCommand, buildCommand, previewCommand, inspectCommand;
9912
- (cli = ((name = "")=>new CAC(name))('rsbuild')).version("1.6.0-beta.0"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9914
+ (cli = ((name = "")=>new CAC(name))('rsbuild')).version("1.6.0-beta.1"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9913
9915
  default: 'jiti'
9914
9916
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9915
9917
  type: [
@@ -9927,6 +9929,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9927
9929
  }
9928
9930
  }), buildCommand.option('-w, --watch', 'Enable watch mode to automatically rebuild on file changes').action(async (options)=>{
9929
9931
  try {
9932
+ options.watch || (process.env.RSPACK_UNSAFE_FAST_DROP = 'true');
9930
9933
  let rsbuild = await init_init({
9931
9934
  cliOptions: options,
9932
9935
  isBuildWatch: options.watch
@@ -9966,7 +9969,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9966
9969
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9967
9970
  }
9968
9971
  }
9969
- let src_version = "1.6.0-beta.0";
9972
+ let src_version = "1.6.0-beta.1";
9970
9973
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
9971
9974
  "PLUGIN_CSS_NAME",
9972
9975
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -1602,7 +1602,7 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
1602
1602
  var external_node_module_ = __webpack_require__("node:module");
1603
1603
  let rspack_rspack = (0, external_node_module_.createRequire)(import.meta.url)('@rspack/core');
1604
1604
  var external_node_path_ = __webpack_require__("node:path"), external_node_url_ = __webpack_require__("node:url");
1605
- let constants_filename = (0, external_node_url_.fileURLToPath)(import.meta.url), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno = 'undefined' != typeof Deno, ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
1605
+ let constants_filename = (0, external_node_url_.fileURLToPath)(import.meta.url), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno = 'undefined' != typeof Deno, isWindows = 'win32' === process.platform, ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
1606
1606
  'chrome >= 87',
1607
1607
  'edge >= 88',
1608
1608
  'firefox >= 78',
@@ -3056,7 +3056,7 @@ function formatStatsError(stats, verbose) {
3056
3056
  })(message = function(message) {
3057
3057
  let hint = 'You may need an appropriate loader to handle this file type.';
3058
3058
  if (-1 === message.indexOf(hint)) return message;
3059
- let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${color.yellow(`@rsbuild/plugin-${packageName}`)}" ${color.dim(`(https://npmjs.com/package/@rsbuild/plugin-${packageName})`)}.`;
3059
+ let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${color.yellow(`@rsbuild/plugin-${packageName}`)}" ${color.dim(`(https://npmjs.com/package/@rsbuild/plugin-${packageName})`)}.\n`;
3060
3060
  for (let plugin of [
3061
3061
  {
3062
3062
  test: /File: .+\.s(c|a)ss/,
@@ -3157,7 +3157,6 @@ function formatStats(stats, hasErrors) {
3157
3157
  }
3158
3158
  return {};
3159
3159
  }
3160
- let rspackMinVersion = '1.5.0';
3161
3160
  class BrowserslistError extends Error {
3162
3161
  constructor(message){
3163
3162
  var key, value;
@@ -3241,7 +3240,7 @@ let getCompiledPath = (packageName)=>(0, external_node_path_.join)(COMPILED_PATH
3241
3240
  } catch {
3242
3241
  return url;
3243
3242
  }
3244
- }, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === external_node_path_.sep ? filepath : filepath.replace(/\\/g, '/'), isFileSync = (filePath)=>{
3243
+ }, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === external_node_path_.sep ? filepath : filepath.replace(/\\/g, '/'), normalizeRuleConditionPath = (filepath)=>isWindows && 'string' == typeof filepath && filepath.includes('/') && external_node_path_.win32.isAbsolute(filepath) ? filepath.replace(/\//g, '\\') : filepath, isFileSync = (filePath)=>{
3245
3244
  try {
3246
3245
  return node_fs.statSync(filePath, {
3247
3246
  throwIfNoEntry: !1
@@ -3306,14 +3305,10 @@ let OVERRIDE_PATHS = [
3306
3305
  x,
3307
3306
  y
3308
3307
  ];
3309
- if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
3308
+ if (pair.some(Array.isArray)) return [
3310
3309
  ...helpers_castArray(x),
3311
3310
  ...helpers_castArray(y)
3312
- ] : Array.isArray(x) ? merge({
3313
- patterns: x
3314
- }, y, path) : merge(x, {
3315
- patterns: y
3316
- }, path);
3311
+ ];
3317
3312
  if (pair.some(isFunction)) return pair;
3318
3313
  if (!isPlainObject(x) || !isPlainObject(y)) return y;
3319
3314
  let merged = {};
@@ -3325,7 +3320,27 @@ let OVERRIDE_PATHS = [
3325
3320
  merged[key] = merge(x[key], y[key], childPath);
3326
3321
  }
3327
3322
  return merged;
3328
- }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), defaultConfig_require = (0, external_node_module_.createRequire)(import.meta.url), defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
3323
+ }, normalizeConfigStructure = (config)=>{
3324
+ let { dev, output, ...rest } = config;
3325
+ return output && (Array.isArray((output = {
3326
+ ...output
3327
+ }).copy) && (output.copy = {
3328
+ patterns: output.copy
3329
+ }), 'string' == typeof output.distPath && (output.distPath = {
3330
+ root: output.distPath
3331
+ })), dev && (dev = {
3332
+ ...dev
3333
+ }).watchFiles && !Array.isArray(dev.watchFiles) && (dev.watchFiles = [
3334
+ dev.watchFiles
3335
+ ]), {
3336
+ ...rest,
3337
+ dev,
3338
+ output
3339
+ };
3340
+ }, mergeRsbuildConfig = (...originalConfigs)=>{
3341
+ let configs = originalConfigs.map(normalizeConfigStructure);
3342
+ return 2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {});
3343
+ }, defaultConfig_require = (0, external_node_module_.createRequire)(import.meta.url), defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
3329
3344
  dev: {
3330
3345
  hmr: !0,
3331
3346
  liveReload: !0,
@@ -3471,46 +3486,6 @@ let OVERRIDE_PATHS = [
3471
3486
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
3472
3487
  }
3473
3488
  return merged;
3474
- }, normalizeConfigStructure = (config, rootPath)=>{
3475
- let { dev, output } = config;
3476
- return config.server ||= {}, config.server.publicDir = normalizePublicDirs(rootPath, config.server.publicDir), 'string' == typeof output?.distPath && (config = {
3477
- ...config,
3478
- output: {
3479
- ...output,
3480
- distPath: {
3481
- root: output.distPath
3482
- }
3483
- }
3484
- }), dev?.watchFiles && !Array.isArray(dev.watchFiles) && (config = {
3485
- ...config,
3486
- dev: {
3487
- ...dev,
3488
- watchFiles: [
3489
- dev.watchFiles
3490
- ]
3491
- }
3492
- }), config;
3493
- }, normalizePublicDirs = (rootPath, publicDir)=>{
3494
- if (!1 === publicDir) return [];
3495
- let defaultConfig = {
3496
- name: (0, external_node_path_.join)(rootPath, 'public'),
3497
- copyOnBuild: 'auto',
3498
- watch: !1
3499
- };
3500
- if (void 0 === publicDir) return [
3501
- defaultConfig
3502
- ];
3503
- let mergeWithDefault = (options)=>{
3504
- if ('' === options.name) throw Error('[rsbuild:config] `publicDir.name` cannot be empty string.');
3505
- let merged = {
3506
- ...defaultConfig,
3507
- ...options
3508
- };
3509
- return (0, external_node_path_.isAbsolute)(merged.name) || (merged.name = (0, external_node_path_.join)(rootPath, merged.name)), merged;
3510
- };
3511
- return Array.isArray(publicDir) ? publicDir.map((options)=>mergeWithDefault(options)) : [
3512
- mergeWithDefault(publicDir)
3513
- ];
3514
3489
  }, exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
3515
3490
  function exit(exitCode, type) {
3516
3491
  if (!isCalled) {
@@ -3709,7 +3684,7 @@ async function updateEnvironmentContext(context, configs) {
3709
3684
  async function createContext(options, userConfig) {
3710
3685
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
3711
3686
  return {
3712
- version: "1.6.0-beta.0",
3687
+ version: "1.6.0-beta.1",
3713
3688
  rootPath,
3714
3689
  distPath: '',
3715
3690
  cachePath,
@@ -4118,14 +4093,35 @@ async function initRsbuildConfig({ context, pluginManager }) {
4118
4093
  context,
4119
4094
  pluginManager
4120
4095
  }), await modifyRsbuildConfig(context);
4121
- let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, mergeRsbuildConfig({
4096
+ let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.publicDir = ((rootPath, publicDir)=>{
4097
+ if (!1 === publicDir) return [];
4098
+ let defaultConfig = {
4099
+ name: (0, external_node_path_.join)(rootPath, 'public'),
4100
+ copyOnBuild: 'auto',
4101
+ watch: !1
4102
+ };
4103
+ if (void 0 === publicDir) return [
4104
+ defaultConfig
4105
+ ];
4106
+ let mergeWithDefault = (options)=>{
4107
+ if ('' === options.name) throw Error('[rsbuild:config] `publicDir.name` cannot be empty string.');
4108
+ let merged = {
4109
+ ...defaultConfig,
4110
+ ...options
4111
+ };
4112
+ return (0, external_node_path_.isAbsolute)(merged.name) || (merged.name = (0, external_node_path_.join)(rootPath, merged.name)), merged;
4113
+ };
4114
+ return Array.isArray(publicDir) ? publicDir.map((options)=>mergeWithDefault(options)) : [
4115
+ mergeWithDefault(publicDir)
4116
+ ];
4117
+ })(rootPath, config.server.publicDir), mergeRsbuildConfig({
4122
4118
  ...createDefaultConfig(),
4123
4119
  mode: (()=>{
4124
4120
  if (config.mode) return config.mode;
4125
4121
  let nodeEnv = process.env.NODE_ENV || '';
4126
4122
  return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
4127
4123
  })()
4128
- }, normalizeConfigStructure(config, rootPath))), environments = {}, mergedEnvironments = ((normalizedConfig, rootPath, specifiedEnvironments)=>{
4124
+ }, config)), environments = {}, mergedEnvironments = ((normalizedConfig, rootPath, specifiedEnvironments)=>{
4129
4125
  let defaultEntry, { environments, dev, server: _server, provider: _provider, ...baseConfig } = normalizedConfig, isEnvironmentEnabled = (name)=>!specifiedEnvironments || specifiedEnvironments.includes(name), applyEnvironmentDefaultConfig = (config)=>{
4130
4126
  let entryFile;
4131
4127
  config.source.entry && 0 !== Object.keys(config.source.entry).length || (config.source.entry = (defaultEntry || (defaultEntry = (entryFile = findExists([
@@ -4150,7 +4146,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4150
4146
  ...mergeRsbuildConfig({
4151
4147
  ...baseConfig,
4152
4148
  dev: pick(dev, allowedEnvironmentDevKeys)
4153
- }, normalizeConfigStructure(config, rootPath))
4149
+ }, config)
4154
4150
  })
4155
4151
  ]));
4156
4152
  if (0 === Object.keys(resolvedEnvironments).length) throw createEnvironmentNotFoundError(specifiedEnvironments);
@@ -4260,8 +4256,10 @@ async function createCompiler_createCompiler(options) {
4260
4256
  if (item1 < item2) return -1;
4261
4257
  }
4262
4258
  return 0;
4263
- })(version, rspackMinVersion) >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green(rspackMinVersion)}`);
4264
- let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
4259
+ })(version, '1.5.0') >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green("1.5.0")}`);
4260
+ let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]);
4261
+ 'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
4262
+ let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
4265
4263
  isVersionLogged || (logger.debug(`using Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
4266
4264
  }, lazyModules = new Set();
4267
4265
  return compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
@@ -6234,12 +6232,16 @@ let resolveSourceLocation = async (stack, fs, context)=>{
6234
6232
  let rawLocation = external_node_path_.default.relative(context.rootPath, source);
6235
6233
  return null !== line && (rawLocation += null === column ? `:${line}` : `:${line}:${column}`), rawLocation;
6236
6234
  }, formatBrowserErrorLog = async (message, context, fs)=>{
6237
- let log = `${color.cyan('[browser]')} ${color.red(message.message)}`;
6235
+ var log;
6236
+ let log1 = `${color.cyan('[browser]')} ${color.red(message.message)}`;
6238
6237
  if (message.stack) {
6239
6238
  let rawLocation = await formatErrorLocation(message.stack, context, fs);
6240
- rawLocation && (log += color.dim(` (${rawLocation})`));
6239
+ rawLocation && (log1 += color.dim(` (${rawLocation})`));
6241
6240
  }
6242
- return log;
6241
+ return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${color.yellow(` - \`process\` is a Node.js global and not available in browsers.
6242
+ - To access \`process.env.*\`, define them in a \`.env\` file with the \`PUBLIC_\` prefix.
6243
+ - Or configure them via \`source.define\`.
6244
+ - Alternatively, install \`@rsbuild/plugin-node-polyfill\` to polyfill Node.js globals.`)}` : log;
6243
6245
  }, styles = {
6244
6246
  1: 'font-weight:bold',
6245
6247
  2: 'opacity:0.5',
@@ -7994,7 +7996,6 @@ async function createRsbuild(options = {}) {
7994
7996
  }
7995
7997
  }), chain.experiments({
7996
7998
  ...chain.get('experiments'),
7997
- lazyBarrel: !0,
7998
7999
  inlineEnum: isProd,
7999
8000
  inlineConst: isProd,
8000
8001
  typeReexportsPresence: !0,
@@ -8003,7 +8004,7 @@ async function createRsbuild(options = {}) {
8003
8004
  force: !1
8004
8005
  }
8005
8006
  }
8006
- })), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-silent';
8007
+ }));
8007
8008
  });
8008
8009
  }
8009
8010
  },
@@ -8857,8 +8858,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
8857
8858
  if (!function({ rule, isDev, config, rsbuildTarget }) {
8858
8859
  for (let condition of (rule.include.add({
8859
8860
  not: NODE_MODULES_REGEX
8860
- }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(condition);
8861
- for (let condition of config.source.exclude || [])rule.exclude.add(condition);
8861
+ }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(normalizeRuleConditionPath(condition));
8862
+ for (let condition of config.source.exclude || [])rule.exclude.add(normalizeRuleConditionPath(condition));
8862
8863
  }({
8863
8864
  rule,
8864
8865
  isDev,
@@ -8953,11 +8954,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
8953
8954
  api.modifyBundlerChain((chain, { environment, target })=>{
8954
8955
  let { config } = environment;
8955
8956
  if (config.output.module) {
8956
- if ('web' === target && (api.logger.warn('[rsbuild:config] `output.module` for web target is experimental and may not work as expected.'), chain.optimization.runtimeChunk(!0)), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
8957
- chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import').library({
8957
+ if ('web' === target && chain.optimization.runtimeChunk(!0), 'node' === target && chain.output.library({
8958
8958
  ...chain.output.get('library'),
8959
8959
  type: 'module'
8960
- }), chain.experiments({
8960
+ }), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
8961
+ chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'), chain.experiments({
8961
8962
  ...chain.get('experiments'),
8962
8963
  outputModule: !0
8963
8964
  });
@@ -9108,7 +9109,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9108
9109
  return;
9109
9110
  }
9110
9111
  try {
9111
- let moduleURL = 'win32' === process.platform ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
9112
+ let moduleURL = isWindows ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
9112
9113
  module = await import(moduleURL);
9113
9114
  } catch {
9114
9115
  logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
@@ -9752,11 +9753,11 @@ function runCLI() {
9752
9753
  }
9753
9754
  !function() {
9754
9755
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9755
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.0-beta.0\n`);
9756
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.0-beta.1\n`);
9756
9757
  }();
9757
9758
  try {
9758
9759
  let cli, devDescription, devCommand, buildCommand, previewCommand, inspectCommand;
9759
- (cli = ((name = "")=>new CAC(name))('rsbuild')).version("1.6.0-beta.0"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9760
+ (cli = ((name = "")=>new CAC(name))('rsbuild')).version("1.6.0-beta.1"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9760
9761
  default: 'jiti'
9761
9762
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9762
9763
  type: [
@@ -9774,6 +9775,7 @@ function runCLI() {
9774
9775
  }
9775
9776
  }), buildCommand.option('-w, --watch', 'Enable watch mode to automatically rebuild on file changes').action(async (options)=>{
9776
9777
  try {
9778
+ options.watch || (process.env.RSPACK_UNSAFE_FAST_DROP = 'true');
9777
9779
  let rsbuild = await init_init({
9778
9780
  cliOptions: options,
9779
9781
  isBuildWatch: options.watch
@@ -9813,5 +9815,5 @@ function runCLI() {
9813
9815
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9814
9816
  }
9815
9817
  }
9816
- let src_version = "1.6.0-beta.0";
9818
+ let src_version = "1.6.0-beta.1";
9817
9819
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack_rspack as rspack, runCLI, src_version as version };
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  let constants_dirname = dirname(fileURLToPath(import.meta.url));
5
- join(constants_dirname), join(constants_dirname, '../static');
5
+ process.platform, join(constants_dirname), join(constants_dirname, '../static');
6
6
  let COMPILED_PATH = join(constants_dirname, '../compiled'), vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
7
7
  requireCompiledPackage('picocolors');
8
8
  let transformLoader = async function(source, map) {
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  let constants_dirname = dirname(fileURLToPath(import.meta.url));
5
- join(constants_dirname), join(constants_dirname, '../static');
5
+ process.platform, join(constants_dirname), join(constants_dirname, '../static');
6
6
  let COMPILED_PATH = join(constants_dirname, '../compiled'), vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
7
7
  requireCompiledPackage('picocolors');
8
8
  let transformRawLoader = async function(source, map) {
@@ -1,6 +1,7 @@
1
1
  export declare const __filename: string;
2
2
  export declare const __dirname: string;
3
3
  export declare const isDeno: boolean;
4
+ export declare const isWindows: boolean;
4
5
  export declare const ROOT_DIST_DIR = "dist";
5
6
  export declare const HTML_DIST_DIR = "./";
6
7
  export declare const FAVICON_DIST_DIR = "./";
@@ -18,10 +18,6 @@ import type { NormalizedConfig, RsbuildConfig, RsbuildEntry } from './types';
18
18
  export declare const defaultAllowedOrigins: RegExp;
19
19
  export declare function getDefaultEntry(root: string): RsbuildEntry;
20
20
  export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
21
- /**
22
- * Converts a raw config into a consistent object-based structure.
23
- */
24
- export declare const normalizeConfigStructure: (config: RsbuildConfig, rootPath: string) => RsbuildConfig;
25
21
  /**
26
22
  * Normalizes the user configuration by merging it with defaults and ensuring
27
23
  * consistent structure.
@@ -1,3 +1,4 @@
1
+ import type { Rspack } from '../types';
1
2
  export declare function toRelativePath(base: string, filepath: string): string;
2
3
  export declare function getCommonParentPath(paths: string[]): string;
3
4
  export declare const getCompiledPath: (packageName: string) => string;
@@ -17,3 +18,9 @@ export declare const dedupeNestedPaths: (paths: string[]) => string[];
17
18
  * toPosixPath('foo\\bar') // returns 'foo/bar'
18
19
  */
19
20
  export declare const toPosixPath: (filepath: string) => string;
21
+ /**
22
+ * Normalize filepaths for `source.include` and `source.exclude` configuration.
23
+ * On Windows, `require.resolve` returns paths with posix forward slashes,
24
+ * This function normalizes the path to use backslashes.
25
+ */
26
+ export declare const normalizeRuleConditionPath: (filepath: Rspack.RuleSetCondition) => Rspack.RuleSetCondition;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildConfig } from './types';
2
- export declare const mergeRsbuildConfig: <T = RsbuildConfig>(...configs: T[]) => T;
2
+ export declare const mergeRsbuildConfig: <T = RsbuildConfig>(...originalConfigs: T[]) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.6.0-beta.0",
3
+ "version": "1.6.0-beta.1",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -46,7 +46,7 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.6.0-beta.0",
49
+ "@rspack/core": "1.6.0-beta.1",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.46.0",
@@ -55,10 +55,10 @@
55
55
  "devDependencies": {
56
56
  "@jridgewell/remapping": "^2.3.5",
57
57
  "@jridgewell/trace-mapping": "^0.3.31",
58
- "@rslib/core": "0.15.0",
58
+ "@rslib/core": "0.15.1",
59
59
  "@types/connect": "3.4.38",
60
60
  "@types/cors": "^2.8.19",
61
- "@types/node": "^22.18.10",
61
+ "@types/node": "^22.18.12",
62
62
  "@types/on-finished": "2.3.5",
63
63
  "@types/range-parser": "^1.2.7",
64
64
  "@types/webpack-bundle-analyzer": "4.7.0",
@@ -85,7 +85,7 @@
85
85
  "prebundle": "1.4.2",
86
86
  "range-parser": "^1.2.1",
87
87
  "reduce-configs": "^1.1.1",
88
- "rslog": "^1.2.11",
88
+ "rslog": "^1.3.0",
89
89
  "rspack-chain": "^1.4.1",
90
90
  "rspack-manifest-plugin": "5.1.0",
91
91
  "sirv": "^3.0.2",