@rsbuild/core 1.4.8 → 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
- 6079: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 6775: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(6161);
5
+ const loader = __nccwpck_require__(2857);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(3212).defaultGetLocalIdent;
8
+ __nccwpck_require__(7108).defaultGetLocalIdent;
9
9
  },
10
- 6161: (__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__(4222);
16
- var _utils = __nccwpck_require__(3212);
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
- 4222: (__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__(7173),
261
+ __nccwpck_require__(893),
262
262
  );
263
263
  var _postcssIcssParser = _interopRequireDefault(
264
- __nccwpck_require__(2420),
264
+ __nccwpck_require__(1500),
265
265
  );
266
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(835));
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
- 2420: (__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__(3212);
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
- 7173: (__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__(3212);
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
- 835: (__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__(3212);
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
- 3212: (__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__(6079);
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
- 776: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 381: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(397);
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
- 397: (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
- 875: (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
- 926: (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
- 829: (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
- 236: (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
- 297: (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__(776);
623
+ const { CachedChildCompilation } = __nccwpck_require__(381);
624
624
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
625
- __nccwpck_require__(236);
626
- const prettyError = __nccwpck_require__(926);
627
- const chunkSorter = __nccwpck_require__(875);
625
+ __nccwpck_require__(517);
626
+ const prettyError = __nccwpck_require__(417);
627
+ const chunkSorter = __nccwpck_require__(406);
628
628
  const getHtmlRspackPluginHooks =
629
- __nccwpck_require__(829).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__(297);
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
- 124: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(642)["default"];
4
+ 11: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(893)["default"];
6
6
  },
7
- 642: (__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__(307);
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
- 307: (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__(124);
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
- 664: (__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
- 161: (__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__(664);
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__(161);
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
@@ -2093,7 +2093,8 @@ ${section.body}` : section.body).join("\n\n"));
2093
2093
  let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnvironment === specifiedEnvironment || void 0 === pluginEnvironment;
2094
2094
  async function initPlugins({ context, pluginManager }) {
2095
2095
  index_js_namespaceObject.logger.debug('init plugins');
2096
- let plugins = ((plugins)=>{
2096
+ let plugins = pluginManager.getAllPluginsWithMeta();
2097
+ plugins = ((plugins)=>{
2097
2098
  let allLines = [];
2098
2099
  function getPlugin(name) {
2099
2100
  let targets = plugins.filter((item)=>item.instance.name === name);
@@ -2121,14 +2122,30 @@ ${section.body}` : section.body).join("\n\n"));
2121
2122
  throw Error(`${picocolors_index_js_default().dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${picocolors_index_js_default().yellow(Object.keys(restInRingPoints).join(','))}`);
2122
2123
  }
2123
2124
  return sortedPoint;
2124
- })(pluginManager.getAllPluginsWithMeta()), removedPlugins = new Set(), removedEnvPlugins = {};
2125
+ })(plugins = ((plugins)=>{
2126
+ let prePlugins = [], normalPlugins = [], postPlugins = [];
2127
+ for (let plugin of plugins){
2128
+ let { enforce } = plugin.instance;
2129
+ 'pre' === enforce ? prePlugins.push(plugin) : 'post' === enforce ? postPlugins.push(plugin) : normalPlugins.push(plugin);
2130
+ }
2131
+ return [
2132
+ ...prePlugins,
2133
+ ...normalPlugins,
2134
+ ...postPlugins
2135
+ ];
2136
+ })(plugins));
2137
+ let removedPlugins = new Set(), removedEnvPlugins = {};
2125
2138
  for (let { environment, instance } of plugins)if (instance.remove) if (environment) for (let item of (removedEnvPlugins[environment] ??= new Set(), instance.remove))removedEnvPlugins[environment].add(item);
2126
2139
  else for (let item of instance.remove)removedPlugins.add(item);
2127
2140
  for (let { instance, environment } of plugins){
2128
2141
  var _removedEnvPlugins_environment;
2129
2142
  let { name, setup } = instance;
2130
2143
  if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
2131
- 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 {
2132
2149
  let expected = {
2133
2150
  build: 'build',
2134
2151
  dev: 'serve',
@@ -2260,7 +2277,7 @@ ${section.body}` : section.body).join("\n\n"));
2260
2277
  async function createContext(options, userConfig) {
2261
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';
2262
2279
  return {
2263
- version: "1.4.8",
2280
+ version: "1.4.10",
2264
2281
  rootPath,
2265
2282
  distPath: '',
2266
2283
  cachePath,
@@ -3481,7 +3498,7 @@ ${section.body}` : section.body).join("\n\n"));
3481
3498
  if (mountPoint) return mountPoint;
3482
3499
  let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
3483
3500
  try {
3484
- 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;
3485
3502
  } catch {}
3486
3503
  if (!isConfigFileExists) return defaultMountPoint;
3487
3504
  let configContent = await promises_namespaceObject.readFile(configFilePath, {
@@ -4223,7 +4240,7 @@ ${section.body}` : section.body).join("\n\n"));
4223
4240
  return {
4224
4241
  ...defaultConfig,
4225
4242
  minSize: 0,
4226
- maxInitialRequests: Number.POSITIVE_INFINITY,
4243
+ maxInitialRequests: 1 / 0,
4227
4244
  ...override,
4228
4245
  cacheGroups: {
4229
4246
  ...defaultConfig.cacheGroups,
@@ -4251,7 +4268,7 @@ ${section.body}` : section.body).join("\n\n"));
4251
4268
  return {
4252
4269
  ...defaultConfig,
4253
4270
  minSize: userConfig.minSize ?? 0,
4254
- maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
4271
+ maxSize: userConfig.maxSize ?? 1 / 0,
4255
4272
  ...override,
4256
4273
  cacheGroups: {
4257
4274
  ...defaultConfig.cacheGroups,
@@ -7542,7 +7559,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7542
7559
  handler: (chain, { target, environment })=>{
7543
7560
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
7544
7561
  let rule = chain.module.rule(id);
7545
- descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.enforce && rule.enforce(descriptor.enforce);
7562
+ descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
7546
7563
  let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0, external_node_path_namespaceObject.join)(LOADER_PATH, loaderName);
7547
7564
  rule.use(id).loader(loaderPath).options({
7548
7565
  id,
@@ -7691,7 +7708,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7691
7708
  envs && (rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup));
7692
7709
  let getFlattenedPlugins = async (pluginOptions)=>{
7693
7710
  let plugins = pluginOptions;
7694
- do plugins = (await Promise.all(plugins)).flat(Number.POSITIVE_INFINITY);
7711
+ do plugins = (await Promise.all(plugins)).flat(1 / 0);
7695
7712
  while (plugins.some((v)=>(0, types_namespaceObject.isPromise)(v)));
7696
7713
  return plugins;
7697
7714
  };
@@ -7903,11 +7920,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7903
7920
  ].includes(level) && (index_js_namespaceObject.logger.level = level);
7904
7921
  }
7905
7922
  let { npm_execpath } = process.env;
7906
- (!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.8\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`);
7907
7924
  try {
7908
7925
  !function() {
7909
7926
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7910
- cli.help(), cli.version("1.4.8"), 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`', {
7911
7928
  default: 'jiti'
7912
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', {
7913
7930
  type: [
@@ -7965,7 +7982,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7965
7982
  index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), index_js_namespaceObject.logger.error(err);
7966
7983
  }
7967
7984
  }
7968
- let src_version = "1.4.8";
7985
+ let src_version = "1.4.10";
7969
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 === [
7970
7987
  "PLUGIN_CSS_NAME",
7971
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");
@@ -1908,7 +1908,8 @@ function exit(exitCode, type) {
1908
1908
  let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnvironment === specifiedEnvironment || void 0 === pluginEnvironment;
1909
1909
  async function initPlugins({ context, pluginManager }) {
1910
1910
  logger.debug('init plugins');
1911
- let plugins = ((plugins)=>{
1911
+ let plugins = pluginManager.getAllPluginsWithMeta();
1912
+ plugins = ((plugins)=>{
1912
1913
  let allLines = [];
1913
1914
  function getPlugin(name) {
1914
1915
  let targets = plugins.filter((item)=>item.instance.name === name);
@@ -1936,14 +1937,30 @@ async function initPlugins({ context, pluginManager }) {
1936
1937
  throw Error(`${picocolors.dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${picocolors.yellow(Object.keys(restInRingPoints).join(','))}`);
1937
1938
  }
1938
1939
  return sortedPoint;
1939
- })(pluginManager.getAllPluginsWithMeta()), removedPlugins = new Set(), removedEnvPlugins = {};
1940
+ })(plugins = ((plugins)=>{
1941
+ let prePlugins = [], normalPlugins = [], postPlugins = [];
1942
+ for (let plugin of plugins){
1943
+ let { enforce } = plugin.instance;
1944
+ 'pre' === enforce ? prePlugins.push(plugin) : 'post' === enforce ? postPlugins.push(plugin) : normalPlugins.push(plugin);
1945
+ }
1946
+ return [
1947
+ ...prePlugins,
1948
+ ...normalPlugins,
1949
+ ...postPlugins
1950
+ ];
1951
+ })(plugins));
1952
+ let removedPlugins = new Set(), removedEnvPlugins = {};
1940
1953
  for (let { environment, instance } of plugins)if (instance.remove) if (environment) for (let item of (removedEnvPlugins[environment] ??= new Set(), instance.remove))removedEnvPlugins[environment].add(item);
1941
1954
  else for (let item of instance.remove)removedPlugins.add(item);
1942
1955
  for (let { instance, environment } of plugins){
1943
1956
  var _removedEnvPlugins_environment;
1944
1957
  let { name, setup } = instance;
1945
1958
  if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
1946
- 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 {
1947
1964
  let expected = {
1948
1965
  build: 'build',
1949
1966
  dev: 'serve',
@@ -2075,7 +2092,7 @@ async function updateEnvironmentContext(context, configs) {
2075
2092
  async function createContext(options, userConfig) {
2076
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';
2077
2094
  return {
2078
- version: "1.4.8",
2095
+ version: "1.4.10",
2079
2096
  rootPath,
2080
2097
  distPath: '',
2081
2098
  cachePath,
@@ -3286,7 +3303,7 @@ let isWsl = ()=>{
3286
3303
  if (mountPoint) return mountPoint;
3287
3304
  let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
3288
3305
  try {
3289
- await promises.access(configFilePath, promises_constants.F_OK), isConfigFileExists = !0;
3306
+ await promises.access(configFilePath, external_node_fs_constants.F_OK), isConfigFileExists = !0;
3290
3307
  } catch {}
3291
3308
  if (!isConfigFileExists) return defaultMountPoint;
3292
3309
  let configContent = await promises.readFile(configFilePath, {
@@ -4024,7 +4041,7 @@ let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\
4024
4041
  return {
4025
4042
  ...defaultConfig,
4026
4043
  minSize: 0,
4027
- maxInitialRequests: Number.POSITIVE_INFINITY,
4044
+ maxInitialRequests: 1 / 0,
4028
4045
  ...override,
4029
4046
  cacheGroups: {
4030
4047
  ...defaultConfig.cacheGroups,
@@ -4052,7 +4069,7 @@ let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\
4052
4069
  return {
4053
4070
  ...defaultConfig,
4054
4071
  minSize: userConfig.minSize ?? 0,
4055
- maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
4072
+ maxSize: userConfig.maxSize ?? 1 / 0,
4056
4073
  ...override,
4057
4074
  cacheGroups: {
4058
4075
  ...defaultConfig.cacheGroups,
@@ -7326,7 +7343,7 @@ async function createRsbuild(options = {}) {
7326
7343
  handler: (chain, { target, environment })=>{
7327
7344
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
7328
7345
  let rule = chain.module.rule(id);
7329
- descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.enforce && rule.enforce(descriptor.enforce);
7346
+ descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
7330
7347
  let loaderPath = join(LOADER_PATH, descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs');
7331
7348
  rule.use(id).loader(loaderPath).options({
7332
7349
  id,
@@ -7474,7 +7491,7 @@ async function createRsbuild(options = {}) {
7474
7491
  envs && (rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup));
7475
7492
  let getFlattenedPlugins = async (pluginOptions)=>{
7476
7493
  let plugins = pluginOptions;
7477
- do plugins = (await Promise.all(plugins)).flat(Number.POSITIVE_INFINITY);
7494
+ do plugins = (await Promise.all(plugins)).flat(1 / 0);
7478
7495
  while (plugins.some((v)=>isPromise(v)));
7479
7496
  return plugins;
7480
7497
  };
@@ -7686,11 +7703,11 @@ async function runCLI() {
7686
7703
  ].includes(level) && (logger.level = level);
7687
7704
  }
7688
7705
  let { npm_execpath } = process.env;
7689
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.8\n`);
7706
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.10\n`);
7690
7707
  try {
7691
7708
  !function() {
7692
7709
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7693
- cli.help(), cli.version("1.4.8"), 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`', {
7694
7711
  default: 'jiti'
7695
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', {
7696
7713
  type: [
@@ -7748,5 +7765,5 @@ async function runCLI() {
7748
7765
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
7749
7766
  }
7750
7767
  }
7751
- let src_version = "1.4.8";
7768
+ let src_version = "1.4.10";
7752
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';
@@ -5,7 +5,16 @@ import type { InternalContext, PluginManager, PluginMeta } from './types';
5
5
  */
6
6
  export declare const isEnvironmentMatch: (pluginEnvironment?: string, specifiedEnvironment?: string) => boolean;
7
7
  export declare function createPluginManager(): PluginManager;
8
- export declare const pluginDagSort: (plugins: PluginMeta[]) => PluginMeta[];
8
+ /**
9
+ * Sorts plugins by their `enforce` property.
10
+ */
11
+ export declare const sortPluginsByEnforce: (plugins: PluginMeta[]) => PluginMeta[];
12
+ /**
13
+ * Performs topological sorting on plugins based on their dependencies.
14
+ * Uses the `pre` and `post` properties of plugins to determine the correct
15
+ * execution order.
16
+ */
17
+ export declare const sortPluginsByDependencies: (plugins: PluginMeta[]) => PluginMeta[];
9
18
  export declare function initPlugins({ context, pluginManager, }: {
10
19
  context: InternalContext;
11
20
  pluginManager: PluginManager;
@@ -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;
@@ -146,12 +152,24 @@ export type RsbuildPlugin = {
146
152
  * @param api provides the context info, utility functions and lifecycle hooks.
147
153
  */
148
154
  setup: (api: RsbuildPluginAPI) => MaybePromise<void>;
155
+ /**
156
+ * Specifies the execution order of the plugin.
157
+ * - `'pre'`: Execute the plugin before other plugins.
158
+ * - `'post'`: Execute the plugin after other plugins.
159
+ * - If not specified, the plugin will execute in the order they were registered.
160
+ *
161
+ * This affects the order in which hooks are registered, but if a hook specifies
162
+ * an `order` property, the `order` takes higher precedence.
163
+ */
164
+ enforce?: 'pre' | 'post';
149
165
  /**
150
166
  * Declare the names of pre-plugins, which will be executed before the current plugin.
167
+ * This has higher precedence than the `enforce` property.
151
168
  */
152
169
  pre?: string[];
153
170
  /**
154
171
  * Declare the names of post-plugins, which will be executed after the current plugin.
172
+ * This has higher precedence than the `enforce` property.
155
173
  */
156
174
  post?: string[];
157
175
  /**
@@ -298,6 +316,11 @@ export type TransformDescriptor = {
298
316
  * @see https://rspack.rs/config/module#rulemimetype
299
317
  */
300
318
  mimetype?: Rspack.RuleSetCondition;
319
+ /**
320
+ * The original property for specifying execution order, now deprecated in favor of `order`.
321
+ * @deprecated Use `order` instead.
322
+ */
323
+ enforce?: 'pre' | 'post';
301
324
  /**
302
325
  * Specifies the execution order of the transform function.
303
326
  * - When specified as 'pre', the transform function will execute before other
@@ -306,7 +329,7 @@ export type TransformDescriptor = {
306
329
  * transform functions (or Rspack loaders).
307
330
  * @see https://rspack.rs/config/module#ruleenforce
308
331
  */
309
- enforce?: 'pre' | 'post';
332
+ order?: HookOrder;
310
333
  };
311
334
  export type TransformHook = (descriptor: TransformDescriptor, handler: TransformHandler) => void;
312
335
  export type ProcessAssetsStage = 'additional' | 'pre-process' | 'derived' | 'additions' | 'none' | 'optimize' | 'optimize-count' | 'optimize-compatibility' | 'optimize-size' | 'dev-tooling' | 'optimize-inline' | 'summarize' | 'optimize-hash' | 'optimize-transfer' | 'analyse' | 'report';
@@ -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.8",
3
+ "version": "1.4.10",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -46,17 +46,17 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.4.8",
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.5",
56
+ "@rslib/core": "0.11.0",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/cors": "^2.8.19",
59
- "@types/node": "^22.16.4",
59
+ "@types/node": "^22.16.5",
60
60
  "@types/on-finished": "2.3.5",
61
61
  "@types/webpack-bundle-analyzer": "4.7.0",
62
62
  "@types/ws": "^8.18.1",