@rsbuild/core 1.4.9 → 1.4.10

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
- 717: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 6775: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(8263);
5
+ const loader = __nccwpck_require__(2857);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(8674).defaultGetLocalIdent;
8
+ __nccwpck_require__(7108).defaultGetLocalIdent;
9
9
  },
10
- 8263: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 2857: (__unused_webpack_module, exports, __nccwpck_require__) => {
11
11
  "use strict";
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports["default"] = loader;
14
14
  var _postcss = _interopRequireDefault(__nccwpck_require__(9409));
15
- var _plugins = __nccwpck_require__(4092);
16
- var _utils = __nccwpck_require__(8674);
15
+ var _plugins = __nccwpck_require__(2774);
16
+ var _utils = __nccwpck_require__(7108);
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
- 4092: (__unused_webpack_module, exports, __nccwpck_require__) => {
239
+ 2774: (__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__(5943),
261
+ __nccwpck_require__(893),
262
262
  );
263
263
  var _postcssIcssParser = _interopRequireDefault(
264
- __nccwpck_require__(8058),
264
+ __nccwpck_require__(1500),
265
265
  );
266
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(9661));
266
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(9675));
267
267
  function _interopRequireDefault(obj) {
268
268
  return obj && obj.__esModule ? obj : { default: obj };
269
269
  }
270
270
  },
271
- 8058: (__unused_webpack_module, exports, __nccwpck_require__) => {
271
+ 1500: (__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__(8674);
276
+ var _utils = __nccwpck_require__(7108);
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
- 5943: (__unused_webpack_module, exports, __nccwpck_require__) => {
375
+ 893: (__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__(8674);
382
+ var _utils = __nccwpck_require__(7108);
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
- 9661: (__unused_webpack_module, exports, __nccwpck_require__) => {
687
+ 9675: (__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__(8674);
694
+ var _utils = __nccwpck_require__(7108);
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
- 8674: (__unused_webpack_module, exports, __nccwpck_require__) => {
1037
+ 7108: (__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__(717);
8101
+ var __webpack_exports__ = __nccwpck_require__(6775);
8102
8102
  module.exports = __webpack_exports__;
8103
8103
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 53: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 381: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(902);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(246);
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
- 902: (module) => {
314
+ 246: (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
- 270: (module) => {
483
+ 406: (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
- 201: (module) => {
502
+ 417: (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
- 96: (module, __unused_webpack_exports, __nccwpck_require__) => {
523
+ 608: (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
- 869: (module) => {
549
+ 517: (module) => {
550
550
  const voidTags = [
551
551
  "area",
552
552
  "base",
@@ -614,19 +614,19 @@
614
614
  htmlTagObjectToString,
615
615
  };
616
616
  },
617
- 32: (module, __unused_webpack_exports, __nccwpck_require__) => {
617
+ 560: (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
621
  const fs = __nccwpck_require__(896);
622
622
  const path = __nccwpck_require__(928);
623
- const { CachedChildCompilation } = __nccwpck_require__(53);
623
+ const { CachedChildCompilation } = __nccwpck_require__(381);
624
624
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
625
- __nccwpck_require__(869);
626
- const prettyError = __nccwpck_require__(201);
627
- const chunkSorter = __nccwpck_require__(270);
625
+ __nccwpck_require__(517);
626
+ const prettyError = __nccwpck_require__(417);
627
+ const chunkSorter = __nccwpck_require__(406);
628
628
  const getHtmlRspackPluginHooks =
629
- __nccwpck_require__(96).getHtmlRspackPluginHooks;
629
+ __nccwpck_require__(608).getHtmlRspackPluginHooks;
630
630
  const WITH_PLACEHOLDER = "function __with_placeholder__";
631
631
  class HtmlRspackPlugin {
632
632
  constructor(userOptions = {}) {
@@ -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__(32);
1600
+ var __webpack_exports__ = __nccwpck_require__(560);
1601
1601
  module.exports = __webpack_exports__;
1602
1602
  })();
@@ -370,12 +370,12 @@
370
370
  };
371
371
  };
372
372
  },
373
- 798: (module, __unused_webpack_exports, __nccwpck_require__) => {
373
+ 159: (module, __unused_webpack_exports, __nccwpck_require__) => {
374
374
  const { resolve } = __nccwpck_require__(760);
375
375
  const config = __nccwpck_require__(920);
376
- const loadOptions = __nccwpck_require__(80);
377
- const loadPlugins = __nccwpck_require__(910);
378
- const req = __nccwpck_require__(102);
376
+ const loadOptions = __nccwpck_require__(245);
377
+ const loadPlugins = __nccwpck_require__(547);
378
+ const req = __nccwpck_require__(515);
379
379
  const interopRequireDefault = (obj) =>
380
380
  obj && obj.__esModule ? obj : { default: obj };
381
381
  async function processResult(ctx, result) {
@@ -489,8 +489,8 @@
489
489
  * @requires ./plugins
490
490
  */ module.exports = rc;
491
491
  },
492
- 80: (module, __unused_webpack_exports, __nccwpck_require__) => {
493
- const req = __nccwpck_require__(102);
492
+ 245: (module, __unused_webpack_exports, __nccwpck_require__) => {
493
+ const req = __nccwpck_require__(515);
494
494
  async function options(config, file) {
495
495
  if (config.parser && typeof config.parser === "string") {
496
496
  try {
@@ -523,8 +523,8 @@
523
523
  }
524
524
  module.exports = options;
525
525
  },
526
- 910: (module, __unused_webpack_exports, __nccwpck_require__) => {
527
- const req = __nccwpck_require__(102);
526
+ 547: (module, __unused_webpack_exports, __nccwpck_require__) => {
527
+ const req = __nccwpck_require__(515);
528
528
  async function load(plugin, options, file) {
529
529
  try {
530
530
  if (
@@ -579,7 +579,7 @@
579
579
  }
580
580
  module.exports = plugins;
581
581
  },
582
- 102: (module, __unused_webpack_exports, __nccwpck_require__) => {
582
+ 515: (module, __unused_webpack_exports, __nccwpck_require__) => {
583
583
  const { createRequire } = __nccwpck_require__(995);
584
584
  const { pathToFileURL } = __nccwpck_require__(136);
585
585
  const TS_EXT_RE = /\.[mc]?ts$/;
@@ -740,6 +740,6 @@
740
740
  })();
741
741
  if (typeof __nccwpck_require__ !== "undefined")
742
742
  __nccwpck_require__.ab = __dirname + "/";
743
- var __webpack_exports__ = __nccwpck_require__(798);
743
+ var __webpack_exports__ = __nccwpck_require__(159);
744
744
  module.exports = __webpack_exports__;
745
745
  })();
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 357: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(583)["default"];
4
+ 11: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(893)["default"];
6
6
  },
7
- 583: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 893: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(928));
12
- var _utils = __nccwpck_require__(370);
12
+ var _utils = __nccwpck_require__(576);
13
13
  function _interopRequireDefault(obj) {
14
14
  return obj && obj.__esModule ? obj : { default: obj };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 370: (module, exports, __nccwpck_require__) => {
182
+ 576: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -716,6 +716,6 @@
716
716
  })();
717
717
  if (typeof __nccwpck_require__ !== "undefined")
718
718
  __nccwpck_require__.ab = __dirname + "/";
719
- var __webpack_exports__ = __nccwpck_require__(357);
719
+ var __webpack_exports__ = __nccwpck_require__(11);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 759: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 685: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.transformFiles =
7
7
  exports.reduceChunk =
@@ -120,7 +120,7 @@
120
120
  .map(standardizeFilePaths);
121
121
  exports.transformFiles = transformFiles;
122
122
  },
123
- 330: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 416: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
124
  Object.defineProperty(exports, "__esModule", { value: true });
125
125
  exports.normalModuleLoaderHook =
126
126
  exports.getCompilerHooks =
@@ -130,7 +130,7 @@
130
130
  const fs_1 = __nccwpck_require__(896);
131
131
  const path_1 = __nccwpck_require__(928);
132
132
  const lite_tapable_1 = __nccwpck_require__(408);
133
- const helpers_1 = __nccwpck_require__(759);
133
+ const helpers_1 = __nccwpck_require__(685);
134
134
  const compilerHookMap = new WeakMap();
135
135
  const getCompilerHooks = (compiler) => {
136
136
  let hooks = compilerHookMap.get(compiler);
@@ -312,7 +312,7 @@
312
312
  exports.getCompilerHooks =
313
313
  void 0;
314
314
  const path_1 = __nccwpck_require__(928);
315
- const hooks_1 = __nccwpck_require__(330);
315
+ const hooks_1 = __nccwpck_require__(416);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
package/dist/index.cjs CHANGED
@@ -2141,7 +2141,11 @@ ${section.body}` : section.body).join("\n\n"));
2141
2141
  var _removedEnvPlugins_environment;
2142
2142
  let { name, setup } = instance;
2143
2143
  if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
2144
- if (instance.apply && context.action) {
2144
+ if (instance.apply && context.action) if (isFunction(instance.apply)) {
2145
+ if (!1 === instance.apply(context.originalConfig, {
2146
+ action: context.action
2147
+ })) continue;
2148
+ } else {
2145
2149
  let expected = {
2146
2150
  build: 'build',
2147
2151
  dev: 'serve',
@@ -2273,7 +2277,7 @@ ${section.body}` : section.body).join("\n\n"));
2273
2277
  async function createContext(options, userConfig) {
2274
2278
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2275
2279
  return {
2276
- version: "1.4.9",
2280
+ version: "1.4.10",
2277
2281
  rootPath,
2278
2282
  distPath: '',
2279
2283
  cachePath,
@@ -3494,7 +3498,7 @@ ${section.body}` : section.body).join("\n\n"));
3494
3498
  if (mountPoint) return mountPoint;
3495
3499
  let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
3496
3500
  try {
3497
- await promises_namespaceObject.access(configFilePath, promises_namespaceObject.constants.F_OK), isConfigFileExists = !0;
3501
+ await promises_namespaceObject.access(configFilePath, external_node_fs_namespaceObject.constants.F_OK), isConfigFileExists = !0;
3498
3502
  } catch {}
3499
3503
  if (!isConfigFileExists) return defaultMountPoint;
3500
3504
  let configContent = await promises_namespaceObject.readFile(configFilePath, {
@@ -7916,11 +7920,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7916
7920
  ].includes(level) && (index_js_namespaceObject.logger.level = level);
7917
7921
  }
7918
7922
  let { npm_execpath } = process.env;
7919
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.9\n`);
7923
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.10\n`);
7920
7924
  try {
7921
7925
  !function() {
7922
7926
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7923
- cli.help(), cli.version("1.4.9"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7927
+ cli.help(), cli.version("1.4.10"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7924
7928
  default: 'jiti'
7925
7929
  }).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
7926
7930
  type: [
@@ -7978,7 +7982,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7978
7982
  index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), index_js_namespaceObject.logger.error(err);
7979
7983
  }
7980
7984
  }
7981
- let src_version = "1.4.9";
7985
+ let src_version = "1.4.10";
7982
7986
  })(), 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 === [
7983
7987
  "PLUGIN_CSS_NAME",
7984
7988
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import { lookup } from "../compiled/mrmime/index.js";
17
17
  import node_zlib from "node:zlib";
18
18
  import { Buffer as external_node_buffer_Buffer } from "node:buffer";
19
19
  import node_child_process, { execFile } from "node:child_process";
20
- import promises, { constants as promises_constants } from "node:fs/promises";
20
+ import promises from "node:fs/promises";
21
21
  var EsmMode, __webpack_modules__ = {
22
22
  "../../node_modules/.pnpm/clone-deep@4.0.1/node_modules/clone-deep/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
23
23
  let clone = __webpack_require__("../../node_modules/.pnpm/shallow-clone@3.0.1/node_modules/shallow-clone/index.js"), typeOf = __webpack_require__("../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"), isPlainObject = __webpack_require__("../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js");
@@ -1956,7 +1956,11 @@ async function initPlugins({ context, pluginManager }) {
1956
1956
  var _removedEnvPlugins_environment;
1957
1957
  let { name, setup } = instance;
1958
1958
  if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
1959
- if (instance.apply && context.action) {
1959
+ if (instance.apply && context.action) if (isFunction(instance.apply)) {
1960
+ if (!1 === instance.apply(context.originalConfig, {
1961
+ action: context.action
1962
+ })) continue;
1963
+ } else {
1960
1964
  let expected = {
1961
1965
  build: 'build',
1962
1966
  dev: 'serve',
@@ -2088,7 +2092,7 @@ async function updateEnvironmentContext(context, configs) {
2088
2092
  async function createContext(options, userConfig) {
2089
2093
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2090
2094
  return {
2091
- version: "1.4.9",
2095
+ version: "1.4.10",
2092
2096
  rootPath,
2093
2097
  distPath: '',
2094
2098
  cachePath,
@@ -3299,7 +3303,7 @@ let isWsl = ()=>{
3299
3303
  if (mountPoint) return mountPoint;
3300
3304
  let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
3301
3305
  try {
3302
- await promises.access(configFilePath, promises_constants.F_OK), isConfigFileExists = !0;
3306
+ await promises.access(configFilePath, external_node_fs_constants.F_OK), isConfigFileExists = !0;
3303
3307
  } catch {}
3304
3308
  if (!isConfigFileExists) return defaultMountPoint;
3305
3309
  let configContent = await promises.readFile(configFilePath, {
@@ -7699,11 +7703,11 @@ async function runCLI() {
7699
7703
  ].includes(level) && (logger.level = level);
7700
7704
  }
7701
7705
  let { npm_execpath } = process.env;
7702
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.9\n`);
7706
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.10\n`);
7703
7707
  try {
7704
7708
  !function() {
7705
7709
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7706
- cli.help(), cli.version("1.4.9"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7710
+ cli.help(), cli.version("1.4.10"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7707
7711
  default: 'jiti'
7708
7712
  }).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
7709
7713
  type: [
@@ -7761,5 +7765,5 @@ async function runCLI() {
7761
7765
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
7762
7766
  }
7763
7767
  }
7764
- let src_version = "1.4.9";
7768
+ let src_version = "1.4.10";
7765
7769
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, src_version as version };
@@ -19,4 +19,4 @@ export { type Logger, logger } from './logger';
19
19
  export { mergeRsbuildConfig } from './mergeConfig';
20
20
  export type { RsbuildDevServer } from './server/devServer';
21
21
  export type { StartServerResult } from './server/helper';
22
- export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BundlerPluginInstance, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SplitChunks, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
22
+ export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BundlerPluginInstance, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SplitChunks, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
@@ -1,6 +1,5 @@
1
- import type { IncomingMessage, ServerResponse } from 'node:http';
2
1
  import type { Compiler, MultiCompiler, Stats } from '@rspack/core';
3
- import type { DevConfig, EnvironmentContext, NextFunction, ServerConfig } from '../types';
2
+ import type { Connect, DevConfig, EnvironmentContext, ServerConfig } from '../types';
4
3
  export declare const isClientCompiler: (compiler: {
5
4
  options: {
6
5
  target?: Compiler["options"]["target"];
@@ -15,7 +14,6 @@ export declare const setupServerHooks: ({ compiler, token, callbacks: { onDone,
15
14
  token: string;
16
15
  callbacks: ServerCallbacks;
17
16
  }) => void;
18
- type Middleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void>;
19
17
  export type CompilationMiddlewareOptions = {
20
18
  /**
21
19
  * To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable.
@@ -29,7 +27,7 @@ export type CompilationMiddlewareOptions = {
29
27
  serverConfig: ServerConfig;
30
28
  environments: Record<string, EnvironmentContext>;
31
29
  };
32
- export type CompilationMiddleware = Middleware & {
30
+ export type CompilationMiddleware = Connect.NextHandleFunction & {
33
31
  close: (callback: (err: Error | null | undefined) => void) => any;
34
32
  watch: () => void;
35
33
  };
@@ -40,4 +38,3 @@ export type CompilationMiddleware = Middleware & {
40
38
  * - Notify server when compiler hooks are triggered
41
39
  */
42
40
  export declare const getCompilationMiddleware: (compiler: Compiler | MultiCompiler, options: CompilationMiddlewareOptions) => Promise<CompilationMiddleware>;
43
- export {};
@@ -1,7 +1,6 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
- import type Connect from '../../compiled/connect/index.js';
4
- import type { CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
3
+ import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
5
4
  type HTTPServer = Server | Http2SecureServer;
6
5
  export type SockWriteType = 'static-changed' | (string & {});
7
6
  export type SockWrite = (type: SockWriteType, data?: string | boolean | Record<string, any>) => void;
@@ -1,7 +1,6 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
- import type Connect from '../../compiled/connect/index.js';
4
- import type { ServerConfig } from '../types';
3
+ import type { Connect, ServerConfig } from '../types';
5
4
  export declare const createHttpServer: ({ serverConfig, middlewares, }: {
6
5
  serverConfig: ServerConfig;
7
6
  middlewares: Connect.Server;
@@ -1,23 +1,22 @@
1
- import type Connect from '../../compiled/connect/index.js';
2
- import type { EnvironmentAPI, HtmlFallback, RequestHandler as Middleware } from '../types';
1
+ import type { Connect, EnvironmentAPI, HtmlFallback, RequestHandler } from '../types';
3
2
  import type { CompilationManager } from './compilationManager';
4
- export declare const faviconFallbackMiddleware: Middleware;
3
+ export declare const faviconFallbackMiddleware: RequestHandler;
5
4
  export declare const getRequestLoggerMiddleware: () => Promise<Connect.NextHandleFunction>;
6
- export declare const notFoundMiddleware: Middleware;
7
- export declare const optionsFallbackMiddleware: Middleware;
5
+ export declare const notFoundMiddleware: RequestHandler;
6
+ export declare const optionsFallbackMiddleware: RequestHandler;
8
7
  /**
9
8
  * Support access HTML without suffix
10
9
  */
11
10
  export declare const getHtmlCompletionMiddleware: (params: {
12
11
  distPath: string;
13
12
  compilationManager: CompilationManager;
14
- }) => Middleware;
13
+ }) => RequestHandler;
15
14
  /**
16
15
  * handle `server.base`
17
16
  */
18
17
  export declare const getBaseMiddleware: (params: {
19
18
  base: string;
20
- }) => Middleware;
19
+ }) => RequestHandler;
21
20
  /**
22
21
  * support HTML fallback in some edge cases
23
22
  */
@@ -25,10 +24,10 @@ export declare const getHtmlFallbackMiddleware: (params: {
25
24
  distPath: string;
26
25
  compilationManager: CompilationManager;
27
26
  htmlFallback?: HtmlFallback;
28
- }) => Middleware;
27
+ }) => RequestHandler;
29
28
  /**
30
29
  * Support viewing served files via `/rsbuild-dev-server` route
31
30
  */
32
31
  export declare const viewingServedFilesMiddleware: (params: {
33
32
  environments: EnvironmentAPI;
34
- }) => Middleware;
33
+ }) => RequestHandler;
@@ -1,7 +1,6 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
- import type Connect from '../../compiled/connect/index.js';
4
- import type { InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
3
+ import type { Connect, InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
5
4
  import { type StartServerResult } from './helper';
6
5
  type RsbuildProdServerOptions = {
7
6
  pwd: string;
@@ -13,7 +13,7 @@ import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, Rou
13
13
  import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildPlugins } from './plugin';
14
14
  import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
15
15
  import type { BundlerPluginInstance, Rspack, RspackRule } from './rspack';
16
- import type { CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions, WebpackConfig } from './thirdParty';
16
+ import type { Connect, CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions, WebpackConfig } from './thirdParty';
17
17
  import type { ConfigChain, ConfigChainMergeContext, ConfigChainWithContext, MaybePromise, OneOrMany, TwoLevelReadonly } from './utils';
18
18
  export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
19
19
  export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
@@ -1328,8 +1328,7 @@ export type NormalizedHtmlConfig = HtmlConfig & {
1328
1328
  export type ProgressBarConfig = {
1329
1329
  id?: string;
1330
1330
  };
1331
- export type NextFunction = () => void;
1332
- export type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
1331
+ export type RequestHandler = Connect.NextHandleFunction;
1333
1332
  export type EnvironmentAPI = {
1334
1333
  [name: string]: {
1335
1334
  /**
@@ -124,7 +124,12 @@ export type PluginManager = Pick<RsbuildInstance, 'getPlugins' | 'addPlugins' |
124
124
  /** Get all plugins with environment info */
125
125
  getAllPluginsWithMeta: () => PluginMeta[];
126
126
  };
127
- export type RsbuildPluginApply = 'serve' | 'build';
127
+ export type RsbuildPluginApplyFn = (this: void,
128
+ /**
129
+ * The original Rsbuild configuration object (before plugin processing)
130
+ */
131
+ config: RsbuildConfig, context: Pick<RsbuildContext, 'action'>) => boolean;
132
+ export type RsbuildPluginApply = 'serve' | 'build' | RsbuildPluginApplyFn;
128
133
  /**
129
134
  * The type of the Rsbuild plugin object.
130
135
  */
@@ -137,6 +142,7 @@ export type RsbuildPlugin = {
137
142
  * Conditional apply the plugin during serve or build.
138
143
  * - `'serve'`: Apply the plugin when starting the dev server or preview server.
139
144
  * - `'build'`: Apply the plugin during build.
145
+ * - Can be a function that returns `true` to apply the plugin or `false` to skip it.
140
146
  * - If not specified, the plugin will be applied during both serve and build.
141
147
  */
142
148
  apply?: RsbuildPluginApply;
@@ -1,9 +1,11 @@
1
1
  import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
2
2
  /** @ts-ignore `webpack` type only exists when `@rsbuild/webpack` is installed */
3
3
  import type { Configuration as WebpackConfig } from 'webpack';
4
+ import type Connect from '../../compiled/connect/index.js';
4
5
  import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin/index.js';
5
6
  import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss';
6
7
  import type { Rspack } from './rspack';
8
+ export type { Connect };
7
9
  export type { HtmlRspackPlugin };
8
10
  export interface CSSExtractOptions {
9
11
  pluginOptions?: CssExtractRspackPluginOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -46,14 +46,14 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.4.9",
49
+ "@rspack/core": "1.4.10",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.44.0",
53
- "jiti": "^2.4.2"
53
+ "jiti": "^2.5.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.10.6",
56
+ "@rslib/core": "0.11.0",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/cors": "^2.8.19",
59
59
  "@types/node": "^22.16.5",