@rsbuild/core 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 6079: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 717: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(6161);
5
+ const loader = __nccwpck_require__(8263);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(3212).defaultGetLocalIdent;
8
+ __nccwpck_require__(8674).defaultGetLocalIdent;
9
9
  },
10
- 6161: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 8263: (__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__(4092);
16
+ var _utils = __nccwpck_require__(8674);
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
+ 4092: (__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__(5943),
262
262
  );
263
263
  var _postcssIcssParser = _interopRequireDefault(
264
- __nccwpck_require__(2420),
264
+ __nccwpck_require__(8058),
265
265
  );
266
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(835));
266
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(9661));
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
+ 8058: (__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__(8674);
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
+ 5943: (__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__(8674);
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
+ 9661: (__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__(8674);
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
+ 8674: (__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__(717);
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
+ 53: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(397);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(902);
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
+ 902: (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
+ 270: (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
+ 201: (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
+ 96: (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
+ 869: (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
+ 32: (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__(53);
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__(869);
626
+ const prettyError = __nccwpck_require__(201);
627
+ const chunkSorter = __nccwpck_require__(270);
628
628
  const getHtmlRspackPluginHooks =
629
- __nccwpck_require__(829).getHtmlRspackPluginHooks;
629
+ __nccwpck_require__(96).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__(32);
1601
1601
  module.exports = __webpack_exports__;
1602
1602
  })();
@@ -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
+ 357: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(583)["default"];
6
6
  },
7
- 642: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 583: (__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__(370);
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
+ 370: (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__(357);
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
+ 759: (__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
+ 330: (__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__(759);
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__(330);
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,7 +2122,19 @@ ${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){
@@ -2260,7 +2273,7 @@ ${section.body}` : section.body).join("\n\n"));
2260
2273
  async function createContext(options, userConfig) {
2261
2274
  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
2275
  return {
2263
- version: "1.4.8",
2276
+ version: "1.4.9",
2264
2277
  rootPath,
2265
2278
  distPath: '',
2266
2279
  cachePath,
@@ -4223,7 +4236,7 @@ ${section.body}` : section.body).join("\n\n"));
4223
4236
  return {
4224
4237
  ...defaultConfig,
4225
4238
  minSize: 0,
4226
- maxInitialRequests: Number.POSITIVE_INFINITY,
4239
+ maxInitialRequests: 1 / 0,
4227
4240
  ...override,
4228
4241
  cacheGroups: {
4229
4242
  ...defaultConfig.cacheGroups,
@@ -4251,7 +4264,7 @@ ${section.body}` : section.body).join("\n\n"));
4251
4264
  return {
4252
4265
  ...defaultConfig,
4253
4266
  minSize: userConfig.minSize ?? 0,
4254
- maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
4267
+ maxSize: userConfig.maxSize ?? 1 / 0,
4255
4268
  ...override,
4256
4269
  cacheGroups: {
4257
4270
  ...defaultConfig.cacheGroups,
@@ -7542,7 +7555,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7542
7555
  handler: (chain, { target, environment })=>{
7543
7556
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
7544
7557
  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);
7558
+ 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
7559
  let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0, external_node_path_namespaceObject.join)(LOADER_PATH, loaderName);
7547
7560
  rule.use(id).loader(loaderPath).options({
7548
7561
  id,
@@ -7691,7 +7704,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7691
7704
  envs && (rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup));
7692
7705
  let getFlattenedPlugins = async (pluginOptions)=>{
7693
7706
  let plugins = pluginOptions;
7694
- do plugins = (await Promise.all(plugins)).flat(Number.POSITIVE_INFINITY);
7707
+ do plugins = (await Promise.all(plugins)).flat(1 / 0);
7695
7708
  while (plugins.some((v)=>(0, types_namespaceObject.isPromise)(v)));
7696
7709
  return plugins;
7697
7710
  };
@@ -7903,11 +7916,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7903
7916
  ].includes(level) && (index_js_namespaceObject.logger.level = level);
7904
7917
  }
7905
7918
  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`);
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`);
7907
7920
  try {
7908
7921
  !function() {
7909
7922
  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`', {
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`', {
7911
7924
  default: 'jiti'
7912
7925
  }).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
7926
  type: [
@@ -7965,7 +7978,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7965
7978
  index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), index_js_namespaceObject.logger.error(err);
7966
7979
  }
7967
7980
  }
7968
- let src_version = "1.4.8";
7981
+ let src_version = "1.4.9";
7969
7982
  })(), 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
7983
  "PLUGIN_CSS_NAME",
7971
7984
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -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,7 +1937,19 @@ 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){
@@ -2075,7 +2088,7 @@ async function updateEnvironmentContext(context, configs) {
2075
2088
  async function createContext(options, userConfig) {
2076
2089
  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
2090
  return {
2078
- version: "1.4.8",
2091
+ version: "1.4.9",
2079
2092
  rootPath,
2080
2093
  distPath: '',
2081
2094
  cachePath,
@@ -4024,7 +4037,7 @@ let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\
4024
4037
  return {
4025
4038
  ...defaultConfig,
4026
4039
  minSize: 0,
4027
- maxInitialRequests: Number.POSITIVE_INFINITY,
4040
+ maxInitialRequests: 1 / 0,
4028
4041
  ...override,
4029
4042
  cacheGroups: {
4030
4043
  ...defaultConfig.cacheGroups,
@@ -4052,7 +4065,7 @@ let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\
4052
4065
  return {
4053
4066
  ...defaultConfig,
4054
4067
  minSize: userConfig.minSize ?? 0,
4055
- maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
4068
+ maxSize: userConfig.maxSize ?? 1 / 0,
4056
4069
  ...override,
4057
4070
  cacheGroups: {
4058
4071
  ...defaultConfig.cacheGroups,
@@ -7326,7 +7339,7 @@ async function createRsbuild(options = {}) {
7326
7339
  handler: (chain, { target, environment })=>{
7327
7340
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
7328
7341
  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);
7342
+ 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
7343
  let loaderPath = join(LOADER_PATH, descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs');
7331
7344
  rule.use(id).loader(loaderPath).options({
7332
7345
  id,
@@ -7474,7 +7487,7 @@ async function createRsbuild(options = {}) {
7474
7487
  envs && (rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup));
7475
7488
  let getFlattenedPlugins = async (pluginOptions)=>{
7476
7489
  let plugins = pluginOptions;
7477
- do plugins = (await Promise.all(plugins)).flat(Number.POSITIVE_INFINITY);
7490
+ do plugins = (await Promise.all(plugins)).flat(1 / 0);
7478
7491
  while (plugins.some((v)=>isPromise(v)));
7479
7492
  return plugins;
7480
7493
  };
@@ -7686,11 +7699,11 @@ async function runCLI() {
7686
7699
  ].includes(level) && (logger.level = level);
7687
7700
  }
7688
7701
  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`);
7702
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.9\n`);
7690
7703
  try {
7691
7704
  !function() {
7692
7705
  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`', {
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`', {
7694
7707
  default: 'jiti'
7695
7708
  }).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
7709
  type: [
@@ -7748,5 +7761,5 @@ async function runCLI() {
7748
7761
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
7749
7762
  }
7750
7763
  }
7751
- let src_version = "1.4.8";
7764
+ let src_version = "1.4.9";
7752
7765
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, src_version as version };
@@ -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;
@@ -146,12 +146,24 @@ export type RsbuildPlugin = {
146
146
  * @param api provides the context info, utility functions and lifecycle hooks.
147
147
  */
148
148
  setup: (api: RsbuildPluginAPI) => MaybePromise<void>;
149
+ /**
150
+ * Specifies the execution order of the plugin.
151
+ * - `'pre'`: Execute the plugin before other plugins.
152
+ * - `'post'`: Execute the plugin after other plugins.
153
+ * - If not specified, the plugin will execute in the order they were registered.
154
+ *
155
+ * This affects the order in which hooks are registered, but if a hook specifies
156
+ * an `order` property, the `order` takes higher precedence.
157
+ */
158
+ enforce?: 'pre' | 'post';
149
159
  /**
150
160
  * Declare the names of pre-plugins, which will be executed before the current plugin.
161
+ * This has higher precedence than the `enforce` property.
151
162
  */
152
163
  pre?: string[];
153
164
  /**
154
165
  * Declare the names of post-plugins, which will be executed after the current plugin.
166
+ * This has higher precedence than the `enforce` property.
155
167
  */
156
168
  post?: string[];
157
169
  /**
@@ -298,6 +310,11 @@ export type TransformDescriptor = {
298
310
  * @see https://rspack.rs/config/module#rulemimetype
299
311
  */
300
312
  mimetype?: Rspack.RuleSetCondition;
313
+ /**
314
+ * The original property for specifying execution order, now deprecated in favor of `order`.
315
+ * @deprecated Use `order` instead.
316
+ */
317
+ enforce?: 'pre' | 'post';
301
318
  /**
302
319
  * Specifies the execution order of the transform function.
303
320
  * - When specified as 'pre', the transform function will execute before other
@@ -306,7 +323,7 @@ export type TransformDescriptor = {
306
323
  * transform functions (or Rspack loaders).
307
324
  * @see https://rspack.rs/config/module#ruleenforce
308
325
  */
309
- enforce?: 'pre' | 'post';
326
+ order?: HookOrder;
310
327
  };
311
328
  export type TransformHook = (descriptor: TransformDescriptor, handler: TransformHandler) => void;
312
329
  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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
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.9",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.44.0",
53
53
  "jiti": "^2.4.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.10.5",
56
+ "@rslib/core": "0.10.6",
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",