@rsbuild/core 1.1.9 → 1.1.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,22 +1,22 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 2928: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 3293: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(7041);
5
+ const loader = __nccwpck_require__(7956);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(922).defaultGetLocalIdent;
8
+ __nccwpck_require__(6563).defaultGetLocalIdent;
9
9
  },
10
- 7041: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 7956: (__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__(9961));
15
15
  var _package = _interopRequireDefault(__nccwpck_require__(7337));
16
16
  var _semver = { satisfies: () => true };
17
- var _options = _interopRequireDefault(__nccwpck_require__(1861));
18
- var _plugins = __nccwpck_require__(6197);
19
- var _utils = __nccwpck_require__(922);
17
+ var _options = _interopRequireDefault(__nccwpck_require__(3818));
18
+ var _plugins = __nccwpck_require__(2241);
19
+ var _utils = __nccwpck_require__(6563);
20
20
  function _interopRequireDefault(obj) {
21
21
  return obj && obj.__esModule ? obj : { default: obj };
22
22
  }
@@ -243,7 +243,7 @@
243
243
  callback(null, `${importCode}${moduleCode}${exportCode}`);
244
244
  }
245
245
  },
246
- 6197: (__unused_webpack_module, exports, __nccwpck_require__) => {
246
+ 2241: (__unused_webpack_module, exports, __nccwpck_require__) => {
247
247
  "use strict";
248
248
  Object.defineProperty(exports, "__esModule", { value: true });
249
249
  Object.defineProperty(exports, "icssParser", {
@@ -265,22 +265,22 @@
265
265
  },
266
266
  });
267
267
  var _postcssImportParser = _interopRequireDefault(
268
- __nccwpck_require__(5437),
268
+ __nccwpck_require__(2760),
269
269
  );
270
270
  var _postcssIcssParser = _interopRequireDefault(
271
- __nccwpck_require__(5802),
271
+ __nccwpck_require__(4123),
272
272
  );
273
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(8103));
273
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(644));
274
274
  function _interopRequireDefault(obj) {
275
275
  return obj && obj.__esModule ? obj : { default: obj };
276
276
  }
277
277
  },
278
- 5802: (__unused_webpack_module, exports, __nccwpck_require__) => {
278
+ 4123: (__unused_webpack_module, exports, __nccwpck_require__) => {
279
279
  "use strict";
280
280
  Object.defineProperty(exports, "__esModule", { value: true });
281
281
  exports["default"] = void 0;
282
282
  var _icssUtils = __nccwpck_require__(4508);
283
- var _utils = __nccwpck_require__(922);
283
+ var _utils = __nccwpck_require__(6563);
284
284
  const plugin = (options = {}) => ({
285
285
  postcssPlugin: "postcss-icss-parser",
286
286
  async OnceExit(root) {
@@ -379,14 +379,14 @@
379
379
  plugin.postcss = true;
380
380
  var _default = (exports["default"] = plugin);
381
381
  },
382
- 5437: (__unused_webpack_module, exports, __nccwpck_require__) => {
382
+ 2760: (__unused_webpack_module, exports, __nccwpck_require__) => {
383
383
  "use strict";
384
384
  Object.defineProperty(exports, "__esModule", { value: true });
385
385
  exports["default"] = void 0;
386
386
  var _postcssValueParser = _interopRequireDefault(
387
387
  __nccwpck_require__(7555),
388
388
  );
389
- var _utils = __nccwpck_require__(922);
389
+ var _utils = __nccwpck_require__(6563);
390
390
  function _interopRequireDefault(obj) {
391
391
  return obj && obj.__esModule ? obj : { default: obj };
392
392
  }
@@ -691,14 +691,14 @@
691
691
  plugin.postcss = true;
692
692
  var _default = (exports["default"] = plugin);
693
693
  },
694
- 8103: (__unused_webpack_module, exports, __nccwpck_require__) => {
694
+ 644: (__unused_webpack_module, exports, __nccwpck_require__) => {
695
695
  "use strict";
696
696
  Object.defineProperty(exports, "__esModule", { value: true });
697
697
  exports["default"] = void 0;
698
698
  var _postcssValueParser = _interopRequireDefault(
699
699
  __nccwpck_require__(7555),
700
700
  );
701
- var _utils = __nccwpck_require__(922);
701
+ var _utils = __nccwpck_require__(6563);
702
702
  function _interopRequireDefault(obj) {
703
703
  return obj && obj.__esModule ? obj : { default: obj };
704
704
  }
@@ -1041,7 +1041,7 @@
1041
1041
  plugin.postcss = true;
1042
1042
  var _default = (exports["default"] = plugin);
1043
1043
  },
1044
- 922: (__unused_webpack_module, exports, __nccwpck_require__) => {
1044
+ 6563: (__unused_webpack_module, exports, __nccwpck_require__) => {
1045
1045
  "use strict";
1046
1046
  Object.defineProperty(exports, "__esModule", { value: true });
1047
1047
  exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
@@ -7968,7 +7968,7 @@
7968
7968
  "use strict";
7969
7969
  module.exports = require("util");
7970
7970
  },
7971
- 1861: (module) => {
7971
+ 3818: (module) => {
7972
7972
  "use strict";
7973
7973
  module.exports = JSON.parse(
7974
7974
  '{"title":"CSS Loader options","additionalProperties":false,"properties":{"url":{"description":"Allows to enables/disables `url()`/`image-set()` functions handling.","link":"https://github.com/webpack-contrib/css-loader#url","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"import":{"description":"Allows to enables/disables `@import` at-rules handling.","link":"https://github.com/webpack-contrib/css-loader#import","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"modules":{"description":"Allows to enable/disable CSS Modules or ICSS and setup configuration.","link":"https://github.com/webpack-contrib/css-loader#modules","anyOf":[{"type":"boolean"},{"enum":["local","global","pure","icss"]},{"type":"object","additionalProperties":false,"properties":{"auto":{"description":"Allows auto enable CSS modules based on filename.","link":"https://github.com/webpack-contrib/css-loader#auto","anyOf":[{"instanceof":"RegExp"},{"instanceof":"Function"},{"type":"boolean"}]},"mode":{"description":"Setup `mode` option.","link":"https://github.com/webpack-contrib/css-loader#mode","anyOf":[{"enum":["local","global","pure","icss"]},{"instanceof":"Function"}]},"localIdentName":{"description":"Allows to configure the generated local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentname","type":"string","minLength":1},"localIdentContext":{"description":"Allows to redefine basic loader context for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentcontext","type":"string","minLength":1},"localIdentHashSalt":{"description":"Allows to add custom hash to generate more unique classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashsalt","type":"string","minLength":1},"localIdentHashFunction":{"description":"Allows to specify hash function to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashfunction","type":"string","minLength":1},"localIdentHashDigest":{"description":"Allows to specify hash digest to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigest","type":"string","minLength":1},"localIdentHashDigestLength":{"description":"Allows to specify hash digest length to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigestlength","type":"number"},"hashStrategy":{"description":"Allows to specify should localName be used when computing the hash.","link":"https://github.com/webpack-contrib/css-loader#hashstrategy","enum":["resource-path-and-local-name","minimal-subset"]},"localIdentRegExp":{"description":"Allows to specify custom RegExp for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentregexp","anyOf":[{"type":"string","minLength":1},{"instanceof":"RegExp"}]},"getLocalIdent":{"description":"Allows to specify a function to generate the classname.","link":"https://github.com/webpack-contrib/css-loader#getlocalident","instanceof":"Function"},"namedExport":{"description":"Enables/disables ES modules named export for locals.","link":"https://github.com/webpack-contrib/css-loader#namedexport","type":"boolean"},"exportGlobals":{"description":"Allows to export names from global class or id, so you can use that as local name.","link":"https://github.com/webpack-contrib/css-loader#exportglobals","type":"boolean"},"exportLocalsConvention":{"description":"Style of exported classnames.","link":"https://github.com/webpack-contrib/css-loader#localsconvention","anyOf":[{"enum":["asIs","as-is","camelCase","camel-case","camelCaseOnly","camel-case-only","dashes","dashesOnly","dashes-only"]},{"instanceof":"Function"}]},"exportOnlyLocals":{"description":"Export only locals.","link":"https://github.com/webpack-contrib/css-loader#exportonlylocals","type":"boolean"},"getJSON":{"description":"Allows outputting of CSS modules mapping through a callback.","link":"https://github.com/webpack-contrib/css-loader#getJSON","instanceof":"Function"}}}]},"sourceMap":{"description":"Allows to enable/disable source maps.","link":"https://github.com/webpack-contrib/css-loader#sourcemap","type":"boolean"},"importLoaders":{"description":"Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports.","link":"https://github.com/webpack-contrib/css-loader#importloaders","anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}]},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"exportType":{"description":"Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).","link":"https://github.com/webpack-contrib/css-loader#exporttype","enum":["array","string","css-style-sheet"]}},"type":"object"}',
@@ -8003,6 +8003,6 @@
8003
8003
  }
8004
8004
  if (typeof __nccwpck_require__ !== "undefined")
8005
8005
  __nccwpck_require__.ab = __dirname + "/";
8006
- var __webpack_exports__ = __nccwpck_require__(2928);
8006
+ var __webpack_exports__ = __nccwpck_require__(3293);
8007
8007
  module.exports = __webpack_exports__;
8008
8008
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 540: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 326: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(534);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(401);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -304,7 +304,7 @@
304
304
  }
305
305
  module.exports = { CachedChildCompilation };
306
306
  },
307
- 534: (module) => {
307
+ 401: (module) => {
308
308
  "use strict";
309
309
  class HtmlWebpackChildCompiler {
310
310
  constructor(templates) {
@@ -473,7 +473,7 @@
473
473
  }
474
474
  module.exports = { HtmlWebpackChildCompiler };
475
475
  },
476
- 556: (module) => {
476
+ 809: (module) => {
477
477
  "use strict";
478
478
  module.exports = {};
479
479
  module.exports.none = (chunks) => chunks;
@@ -492,7 +492,7 @@
492
492
  };
493
493
  module.exports.auto = module.exports.none;
494
494
  },
495
- 171: (module) => {
495
+ 781: (module) => {
496
496
  "use strict";
497
497
  module.exports = function (err) {
498
498
  return {
@@ -513,7 +513,7 @@
513
513
  };
514
514
  };
515
515
  },
516
- 883: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 992: (module, __unused_webpack_exports, __nccwpck_require__) => {
517
517
  "use strict";
518
518
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(348);
519
519
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -539,7 +539,7 @@
539
539
  }
540
540
  module.exports = { getHtmlRspackPluginHooks };
541
541
  },
542
- 798: (module) => {
542
+ 620: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 215: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 522: (module, __unused_webpack_exports, __nccwpck_require__) => {
611
611
  "use strict";
612
612
  const promisify = __nccwpck_require__(837).promisify;
613
613
  const vm = __nccwpck_require__(144);
614
614
  const fs = __nccwpck_require__(147);
615
615
  const path = __nccwpck_require__(17);
616
- const { CachedChildCompilation } = __nccwpck_require__(540);
616
+ const { CachedChildCompilation } = __nccwpck_require__(326);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(798);
619
- const prettyError = __nccwpck_require__(171);
620
- const chunkSorter = __nccwpck_require__(556);
618
+ __nccwpck_require__(620);
619
+ const prettyError = __nccwpck_require__(781);
620
+ const chunkSorter = __nccwpck_require__(809);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(883).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(992).getHtmlRspackPluginHooks;
623
623
  class HtmlRspackPlugin {
624
624
  constructor(userOptions = {}) {
625
625
  this.version = HtmlRspackPlugin.version;
@@ -1578,6 +1578,6 @@
1578
1578
  }
1579
1579
  if (typeof __nccwpck_require__ !== "undefined")
1580
1580
  __nccwpck_require__.ab = __dirname + "/";
1581
- var __webpack_exports__ = __nccwpck_require__(215);
1581
+ var __webpack_exports__ = __nccwpck_require__(522);
1582
1582
  module.exports = __webpack_exports__;
1583
1583
  })();
@@ -1,17 +1,17 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 401: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(315)["default"];
4
+ 57: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(505)["default"];
6
6
  },
7
- 315: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 505: (__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__(17));
12
12
  var _package = _interopRequireDefault(__nccwpck_require__(337));
13
- var _options = _interopRequireDefault(__nccwpck_require__(632));
14
- var _utils = __nccwpck_require__(152);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(268));
14
+ var _utils = __nccwpck_require__(321);
15
15
  function _interopRequireDefault(obj) {
16
16
  return obj && obj.__esModule ? obj : { default: obj };
17
17
  }
@@ -189,7 +189,7 @@
189
189
  callback(null, result.css, map, { ast });
190
190
  }
191
191
  },
192
- 152: (module, exports, __nccwpck_require__) => {
192
+ 321: (module, exports, __nccwpck_require__) => {
193
193
  module = __nccwpck_require__.nmd(module);
194
194
  Object.defineProperty(exports, "__esModule", { value: true });
195
195
  exports.exec = exec;
@@ -691,7 +691,7 @@
691
691
  310: (module) => {
692
692
  module.exports = require("url");
693
693
  },
694
- 632: (module) => {
694
+ 268: (module) => {
695
695
  module.exports = JSON.parse(
696
696
  '{"title":"PostCSS Loader options","type":"object","properties":{"postcssOptions":{"description":"Options to pass through to `Postcss`.","link":"https://github.com/webpack-contrib/postcss-loader#postcssOptions","anyOf":[{"type":"object","additionalProperties":true,"properties":{"config":{"description":"Allows to specify PostCSS config path.","link":"https://github.com/webpack-contrib/postcss-loader#config","anyOf":[{"description":"Allows to specify the path to the configuration file","type":"string"},{"description":"Enables/Disables autoloading config","type":"boolean"}]}}},{"instanceof":"Function"}]},"execute":{"description":"Enables/Disables PostCSS parser support in \'CSS-in-JS\'.","link":"https://github.com/webpack-contrib/postcss-loader#execute","type":"boolean"},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/postcss-loader#sourcemap","type":"boolean"},"implementation":{"description":"The implementation of postcss to use, instead of the locally installed version","link":"https://github.com/webpack-contrib/postcss-loader#implementation","anyOf":[{"type":"string"},{"instanceof":"Function"}]}},"additionalProperties":false}',
697
697
  );
@@ -736,6 +736,6 @@
736
736
  })();
737
737
  if (typeof __nccwpck_require__ !== "undefined")
738
738
  __nccwpck_require__.ab = __dirname + "/";
739
- var __webpack_exports__ = __nccwpck_require__(401);
739
+ var __webpack_exports__ = __nccwpck_require__(57);
740
740
  module.exports = __webpack_exports__;
741
741
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 399: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 500: (__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
- 391: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 407: (__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__(147);
131
131
  const path_1 = __nccwpck_require__(17);
132
132
  const lite_tapable_1 = __nccwpck_require__(348);
133
- const helpers_1 = __nccwpck_require__(399);
133
+ const helpers_1 = __nccwpck_require__(500);
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__(17);
315
- const hooks_1 = __nccwpck_require__(391);
315
+ const hooks_1 = __nccwpck_require__(407);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
package/dist/index.cjs CHANGED
@@ -1434,19 +1434,19 @@ var __webpack_exports__ = {};
1434
1434
  "use strict";
1435
1435
  let pluginHelper_htmlPlugin, cssExtractPlugin, swcHelpersPath;
1436
1436
  __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
1437
- ensureAssetPrefix: ()=>ensureAssetPrefix,
1438
- createRsbuild: ()=>createRsbuild,
1439
- PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
1440
- loadConfig: ()=>config_loadConfig,
1441
- version: ()=>src_rslib_entry_version,
1437
+ defineConfig: ()=>defineConfig,
1442
1438
  PLUGIN_CSS_NAME: ()=>PLUGIN_CSS_NAME,
1439
+ mergeRsbuildConfig: ()=>mergeRsbuildConfig,
1443
1440
  logger: ()=>rslog_index_js_namespaceObject.logger,
1441
+ createRsbuild: ()=>createRsbuild,
1442
+ __internalHelper: ()=>internal_namespaceObject,
1444
1443
  loadEnv: ()=>loadEnv,
1445
- mergeRsbuildConfig: ()=>mergeRsbuildConfig,
1446
1444
  rspack: ()=>core_namespaceObject.rspack,
1447
- __internalHelper: ()=>internal_namespaceObject,
1448
1445
  runCLI: ()=>runCLI,
1449
- defineConfig: ()=>defineConfig
1446
+ version: ()=>src_rslib_entry_version,
1447
+ PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
1448
+ loadConfig: ()=>config_loadConfig,
1449
+ ensureAssetPrefix: ()=>ensureAssetPrefix
1450
1450
  });
1451
1451
  var internal_namespaceObject = {};
1452
1452
  __webpack_require__.r(internal_namespaceObject), __webpack_require__.d(internal_namespaceObject, {
@@ -1469,6 +1469,7 @@ var __webpack_exports__ = {};
1469
1469
  registerBuildHook: ()=>registerBuildHook,
1470
1470
  registerDevHook: ()=>registerDevHook,
1471
1471
  setCssExtractPlugin: ()=>setCssExtractPlugin,
1472
+ setHTMLPlugin: ()=>setHTMLPlugin,
1472
1473
  stringifyConfig: ()=>stringifyConfig
1473
1474
  });
1474
1475
  let core_namespaceObject = require("@rspack/core");
@@ -1955,9 +1956,7 @@ var __webpack_exports__ = {};
1955
1956
  let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
1956
1957
  cwd: getEnvDir(root, commonOpts.envDir),
1957
1958
  mode: commonOpts.envMode
1958
- });
1959
- onBeforeRestartServer(envs.cleanup);
1960
- let { content: config, filePath: configFilePath } = await config_loadConfig({
1959
+ }), { content: config, filePath: configFilePath } = await config_loadConfig({
1961
1960
  cwd: root,
1962
1961
  path: commonOpts.config,
1963
1962
  envMode: commonOpts.envMode
@@ -1973,14 +1972,16 @@ var __webpack_exports__ = {};
1973
1972
  }
1974
1973
  watchFilesForRestart(files, root, isBuildWatch);
1975
1974
  }
1976
- return config.source ||= {}, config.source.define = {
1975
+ config.source ||= {}, config.source.define = {
1977
1976
  ...envs.publicVars,
1978
1977
  ...config.source.define
1979
- }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0), createRsbuild({
1978
+ }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
1979
+ let rsbuild = await createRsbuild({
1980
1980
  cwd: root,
1981
1981
  rsbuildConfig: config,
1982
1982
  environment: commonOpts.environment
1983
1983
  });
1984
+ return rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup), rsbuild;
1984
1985
  } catch (err) {
1985
1986
  if (isRestart) rslog_index_js_namespaceObject.logger.error(err);
1986
1987
  else throw err;
@@ -1990,17 +1991,18 @@ var __webpack_exports__ = {};
1990
1991
  cleaners.push(cleaner);
1991
1992
  }, clearConsole = ()=>{
1992
1993
  isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
1993
- }, beforeRestart = async ({ filePath, clear = !0 } = {})=>{
1994
+ }, beforeRestart = async ({ filePath, clear = !0, id })=>{
1994
1995
  if (clear && clearConsole(), filePath) {
1995
1996
  let filename = external_node_path_default().basename(filePath);
1996
- rslog_index_js_namespaceObject.logger.info(`Restart server because ${index_js_default().yellow(filename)} is changed.\n`);
1997
- } else rslog_index_js_namespaceObject.logger.info('Restarting server...\n');
1997
+ rslog_index_js_namespaceObject.logger.info(`Restart ${id} because ${index_js_default().yellow(filename)} is changed.\n`);
1998
+ } else rslog_index_js_namespaceObject.logger.info(`Restarting ${id}...\n`);
1998
1999
  for (let cleaner of cleaners)await cleaner();
1999
2000
  cleaners = [];
2000
2001
  }, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
2001
2002
  await beforeRestart({
2002
2003
  filePath,
2003
- clear
2004
+ clear,
2005
+ id: 'server'
2004
2006
  });
2005
2007
  let rsbuild = await init({
2006
2008
  isRestart: !0
@@ -2009,7 +2011,8 @@ var __webpack_exports__ = {};
2009
2011
  }, restartBuild = async ({ filePath, clear = !0 } = {})=>{
2010
2012
  await beforeRestart({
2011
2013
  filePath,
2012
- clear
2014
+ clear,
2015
+ id: 'build'
2013
2016
  });
2014
2017
  let rsbuild = await init({
2015
2018
  isRestart: !0,
@@ -2733,7 +2736,7 @@ var __webpack_exports__ = {};
2733
2736
  async function createContext(options, userConfig, bundlerType) {
2734
2737
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2735
2738
  return {
2736
- version: "1.1.9",
2739
+ version: "1.1.10",
2737
2740
  rootPath,
2738
2741
  distPath: '',
2739
2742
  cachePath,
@@ -3314,9 +3317,9 @@ var __webpack_exports__ = {};
3314
3317
  }
3315
3318
  if (!1 !== options.total && assets.length > 1) {
3316
3319
  let totalSizeLabel = `${index_js_default().blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3317
- options.compressed && (log += index_js_default().dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), log += '\n', logs.push(log);
3320
+ options.compressed && (log += index_js_default().dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), logs.push(log);
3318
3321
  }
3319
- return logs;
3322
+ return logs.push(''), logs;
3320
3323
  }
3321
3324
  let pluginFileSize = ()=>({
3322
3325
  name: 'rsbuild:file-size',
@@ -5407,7 +5410,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5407
5410
  let rl = external_node_readline_default().createInterface({
5408
5411
  input: process.stdin
5409
5412
  });
5410
- rl.on('line', (input)=>{
5413
+ return rl.on('line', (input)=>{
5411
5414
  if ('h' === input) {
5412
5415
  let message = `\n ${index_js_default().bold(index_js_default().blue('Shortcuts:'))}\n`;
5413
5416
  for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
@@ -5417,9 +5420,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5417
5420
  shortcut.action();
5418
5421
  return;
5419
5422
  }
5420
- }), onBeforeRestartServer(()=>{
5423
+ }), ()=>{
5421
5424
  rl.close();
5422
- });
5425
+ };
5423
5426
  }
5424
5427
  let isClientCompiler = (compiler)=>{
5425
5428
  let { target } = compiler.options;
@@ -6254,8 +6257,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6254
6257
  ]);
6255
6258
  }, beforeCreateCompiler = ()=>{
6256
6259
  if (printUrls(), cliShortcutsEnabled) {
6257
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts;
6258
- setupCliShortcuts({
6260
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6259
6261
  openPage,
6260
6262
  closeServer,
6261
6263
  printUrls,
@@ -6265,6 +6267,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6265
6267
  help: shortcutsOptions.help,
6266
6268
  customShortcuts: shortcutsOptions.custom
6267
6269
  });
6270
+ options.context.hooks.onCloseDevServer.tap(cleanup);
6268
6271
  }
6269
6272
  !getPortSilently && portTip && rslog_index_js_namespaceObject.logger.info(portTip);
6270
6273
  };
@@ -6344,7 +6347,6 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6344
6347
  return rslog_index_js_namespaceObject.logger.debug('create dev server done'), devServerAPI;
6345
6348
  }
6346
6349
  async function createCompiler_createCompiler(options) {
6347
- var _context_normalizedConfig, _context_normalizedConfig1;
6348
6350
  rslog_index_js_namespaceObject.logger.debug('create compiler');
6349
6351
  let { context } = options, { rspackConfigs } = await initConfigs(options);
6350
6352
  if (await context.hooks.onBeforeCreateCompiler.call({
@@ -6356,7 +6358,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6356
6358
  };
6357
6359
  compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
6358
6360
  logRspackVersion(), !isCompiling && rslog_index_js_namespaceObject.logger.start('Building...'), isCompiling = !0;
6359
- }), (null === (_context_normalizedConfig = context.normalizedConfig) || void 0 === _context_normalizedConfig ? void 0 : _context_normalizedConfig.mode) === 'production' && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6361
+ }), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6360
6362
  let done = (stats)=>{
6361
6363
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6362
6364
  children: !0,
@@ -6381,7 +6383,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6381
6383
  };
6382
6384
  return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
6383
6385
  done(stats);
6384
- }), (null === (_context_normalizedConfig1 = context.normalizedConfig) || void 0 === _context_normalizedConfig1 ? void 0 : _context_normalizedConfig1.mode) === 'development' && registerDevHook({
6386
+ }), 'dev' === context.command && registerDevHook({
6385
6387
  context,
6386
6388
  compiler,
6387
6389
  bundlerConfigs: rspackConfigs,
@@ -6951,7 +6953,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6951
6953
  rsbuildOptions,
6952
6954
  helpers: provider_helpers_namespaceObject
6953
6955
  }), preview = async (options = {})=>{
6954
- !getNodeEnv() && setNodeEnv('production');
6956
+ context.command = 'preview', !getNodeEnv() && setNodeEnv('production');
6955
6957
  let config = await initRsbuildConfig({
6956
6958
  context,
6957
6959
  pluginManager
@@ -6965,7 +6967,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6965
6967
  }
6966
6968
  return startProdServer(context, config, options);
6967
6969
  }, build = async (...args)=>{
6968
- !getNodeEnv() && setNodeEnv('production');
6970
+ context.command = 'build', !getNodeEnv() && setNodeEnv('production');
6969
6971
  let buildInstance = await providerInstance.build(...args);
6970
6972
  return {
6971
6973
  ...buildInstance,
@@ -6976,8 +6978,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6976
6978
  }, rsbuild = {
6977
6979
  build,
6978
6980
  preview,
6979
- startDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
6980
- createDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
6981
+ startDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
6982
+ createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
6981
6983
  ...pick(pluginManager, [
6982
6984
  'addPlugins',
6983
6985
  'getPlugins',
@@ -7043,11 +7045,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7043
7045
  }
7044
7046
  }(), process.title = 'rsbuild-node';
7045
7047
  let { npm_execpath } = process.env;
7046
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.9\n`);
7048
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.10\n`);
7047
7049
  }();
7048
7050
  try {
7049
7051
  !function() {
7050
- program.name('rsbuild').usage('<command> [options]').version("1.1.9");
7052
+ program.name('rsbuild').usage('<command> [options]').version("1.1.10");
7051
7053
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
7052
7054
  [
7053
7055
  devCommand,
@@ -7106,7 +7108,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7106
7108
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7107
7109
  }
7108
7110
  }
7109
- let src_rslib_entry_version = "1.1.9";
7111
+ let src_rslib_entry_version = "1.1.10";
7110
7112
  })();
7111
7113
  var __webpack_export_target__ = exports;
7112
7114
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
package/dist/index.js CHANGED
@@ -1389,6 +1389,7 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
1389
1389
  registerBuildHook: ()=>registerBuildHook,
1390
1390
  registerDevHook: ()=>registerDevHook,
1391
1391
  setCssExtractPlugin: ()=>setCssExtractPlugin,
1392
+ setHTMLPlugin: ()=>setHTMLPlugin,
1392
1393
  stringifyConfig: ()=>stringifyConfig
1393
1394
  });
1394
1395
  let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), setHTMLPlugin = (plugin)=>{
@@ -1865,9 +1866,7 @@ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
1865
1866
  let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
1866
1867
  cwd: getEnvDir(root, commonOpts.envDir),
1867
1868
  mode: commonOpts.envMode
1868
- });
1869
- onBeforeRestartServer(envs.cleanup);
1870
- let { content: config, filePath: configFilePath } = await config_loadConfig({
1869
+ }), { content: config, filePath: configFilePath } = await config_loadConfig({
1871
1870
  cwd: root,
1872
1871
  path: commonOpts.config,
1873
1872
  envMode: commonOpts.envMode
@@ -1883,14 +1882,16 @@ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
1883
1882
  }
1884
1883
  watchFilesForRestart(files, root, isBuildWatch);
1885
1884
  }
1886
- return config.source ||= {}, config.source.define = {
1885
+ config.source ||= {}, config.source.define = {
1887
1886
  ...envs.publicVars,
1888
1887
  ...config.source.define
1889
- }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0), createRsbuild({
1888
+ }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
1889
+ let rsbuild = await createRsbuild({
1890
1890
  cwd: root,
1891
1891
  rsbuildConfig: config,
1892
1892
  environment: commonOpts.environment
1893
1893
  });
1894
+ return rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup), rsbuild;
1894
1895
  } catch (err) {
1895
1896
  if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
1896
1897
  else throw err;
@@ -1900,17 +1901,18 @@ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
1900
1901
  cleaners.push(cleaner);
1901
1902
  }, clearConsole = ()=>{
1902
1903
  isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
1903
- }, beforeRestart = async ({ filePath, clear = !0 } = {})=>{
1904
+ }, beforeRestart = async ({ filePath, clear = !0, id })=>{
1904
1905
  if (clear && clearConsole(), filePath) {
1905
1906
  let filename = external_node_path_.default.basename(filePath);
1906
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart server because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(filename)} is changed.\n`);
1907
- } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info('Restarting server...\n');
1907
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart ${id} because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(filename)} is changed.\n`);
1908
+ } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restarting ${id}...\n`);
1908
1909
  for (let cleaner of cleaners)await cleaner();
1909
1910
  cleaners = [];
1910
1911
  }, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
1911
1912
  await beforeRestart({
1912
1913
  filePath,
1913
- clear
1914
+ clear,
1915
+ id: 'server'
1914
1916
  });
1915
1917
  let rsbuild = await init({
1916
1918
  isRestart: !0
@@ -1919,7 +1921,8 @@ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
1919
1921
  }, restartBuild = async ({ filePath, clear = !0 } = {})=>{
1920
1922
  await beforeRestart({
1921
1923
  filePath,
1922
- clear
1924
+ clear,
1925
+ id: 'build'
1923
1926
  });
1924
1927
  let rsbuild = await init({
1925
1928
  isRestart: !0,
@@ -2643,7 +2646,7 @@ async function updateEnvironmentContext(context, configs) {
2643
2646
  async function createContext(options, userConfig, bundlerType) {
2644
2647
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2645
2648
  return {
2646
- version: "1.1.9",
2649
+ version: "1.1.10",
2647
2650
  rootPath,
2648
2651
  distPath: '',
2649
2652
  cachePath,
@@ -3221,9 +3224,9 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
3221
3224
  }
3222
3225
  if (!1 !== options.total && assets.length > 1) {
3223
3226
  let totalSizeLabel = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3224
- options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), log += '\n', logs.push(log);
3227
+ options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), logs.push(log);
3225
3228
  }
3226
- return logs;
3229
+ return logs.push(''), logs;
3227
3230
  }
3228
3231
  let pluginFileSize = ()=>({
3229
3232
  name: 'rsbuild:file-size',
@@ -5303,7 +5306,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5303
5306
  let rl = __WEBPACK_EXTERNAL_MODULE_node_readline__.default.createInterface({
5304
5307
  input: process.stdin
5305
5308
  });
5306
- rl.on('line', (input)=>{
5309
+ return rl.on('line', (input)=>{
5307
5310
  if ('h' === input) {
5308
5311
  let message = `\n ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.blue('Shortcuts:'))}\n`;
5309
5312
  for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
@@ -5313,9 +5316,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5313
5316
  shortcut.action();
5314
5317
  return;
5315
5318
  }
5316
- }), onBeforeRestartServer(()=>{
5319
+ }), ()=>{
5317
5320
  rl.close();
5318
- });
5321
+ };
5319
5322
  }
5320
5323
  let isClientCompiler = (compiler)=>{
5321
5324
  let { target } = compiler.options;
@@ -6145,8 +6148,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6145
6148
  ]);
6146
6149
  }, beforeCreateCompiler = ()=>{
6147
6150
  if (printUrls(), cliShortcutsEnabled) {
6148
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts;
6149
- setupCliShortcuts({
6151
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6150
6152
  openPage,
6151
6153
  closeServer,
6152
6154
  printUrls,
@@ -6156,6 +6158,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6156
6158
  help: shortcutsOptions.help,
6157
6159
  customShortcuts: shortcutsOptions.custom
6158
6160
  });
6161
+ options.context.hooks.onCloseDevServer.tap(cleanup);
6159
6162
  }
6160
6163
  !getPortSilently && portTip && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(portTip);
6161
6164
  };
@@ -6235,7 +6238,6 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6235
6238
  return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug('create dev server done'), devServerAPI;
6236
6239
  }
6237
6240
  async function createCompiler_createCompiler(options) {
6238
- var _context_normalizedConfig, _context_normalizedConfig1;
6239
6241
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug('create compiler');
6240
6242
  let { context } = options, { rspackConfigs } = await initConfigs(options);
6241
6243
  if (await context.hooks.onBeforeCreateCompiler.call({
@@ -6247,7 +6249,7 @@ async function createCompiler_createCompiler(options) {
6247
6249
  };
6248
6250
  compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
6249
6251
  logRspackVersion(), !isCompiling && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.start('Building...'), isCompiling = !0;
6250
- }), (null === (_context_normalizedConfig = context.normalizedConfig) || void 0 === _context_normalizedConfig ? void 0 : _context_normalizedConfig.mode) === 'production' && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6252
+ }), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6251
6253
  let done = (stats)=>{
6252
6254
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6253
6255
  children: !0,
@@ -6272,7 +6274,7 @@ async function createCompiler_createCompiler(options) {
6272
6274
  };
6273
6275
  return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
6274
6276
  done(stats);
6275
- }), (null === (_context_normalizedConfig1 = context.normalizedConfig) || void 0 === _context_normalizedConfig1 ? void 0 : _context_normalizedConfig1.mode) === 'development' && registerDevHook({
6277
+ }), 'dev' === context.command && registerDevHook({
6276
6278
  context,
6277
6279
  compiler,
6278
6280
  bundlerConfigs: rspackConfigs,
@@ -6842,7 +6844,7 @@ async function createRsbuild(options = {}) {
6842
6844
  rsbuildOptions,
6843
6845
  helpers: provider_helpers_namespaceObject
6844
6846
  }), preview = async (options = {})=>{
6845
- !getNodeEnv() && setNodeEnv('production');
6847
+ context.command = 'preview', !getNodeEnv() && setNodeEnv('production');
6846
6848
  let config = await initRsbuildConfig({
6847
6849
  context,
6848
6850
  pluginManager
@@ -6856,7 +6858,7 @@ async function createRsbuild(options = {}) {
6856
6858
  }
6857
6859
  return startProdServer(context, config, options);
6858
6860
  }, build = async (...args)=>{
6859
- !getNodeEnv() && setNodeEnv('production');
6861
+ context.command = 'build', !getNodeEnv() && setNodeEnv('production');
6860
6862
  let buildInstance = await providerInstance.build(...args);
6861
6863
  return {
6862
6864
  ...buildInstance,
@@ -6867,8 +6869,8 @@ async function createRsbuild(options = {}) {
6867
6869
  }, rsbuild = {
6868
6870
  build,
6869
6871
  preview,
6870
- startDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
6871
- createDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
6872
+ startDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
6873
+ createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
6872
6874
  ...pick(pluginManager, [
6873
6875
  'addPlugins',
6874
6876
  'getPlugins',
@@ -6934,11 +6936,11 @@ async function runCLI() {
6934
6936
  }
6935
6937
  }(), process.title = 'rsbuild-node';
6936
6938
  let { npm_execpath } = process.env;
6937
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.9\n`);
6939
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.10\n`);
6938
6940
  }();
6939
6941
  try {
6940
6942
  !function() {
6941
- program.name('rsbuild').usage('<command> [options]').version("1.1.9");
6943
+ program.name('rsbuild').usage('<command> [options]').version("1.1.10");
6942
6944
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6943
6945
  [
6944
6946
  devCommand,
@@ -6997,6 +6999,6 @@ async function runCLI() {
6997
6999
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
6998
7000
  }
6999
7001
  }
7000
- let src_version = "1.1.9";
7002
+ let src_version = "1.1.10";
7001
7003
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
7002
7004
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, internal_namespaceObject as __internalHelper, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -21,5 +21,6 @@ export type { ChainIdentifier } from './configChain';
21
21
  export {
22
22
  /**
23
23
  * @private
24
+ * TODO: remove this in Rspack v1.2.0
24
25
  */
25
26
  __internalHelper, };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Helpers for `@rsbuild/webpack`.
3
3
  */
4
- export { setCssExtractPlugin } from '../pluginHelper';
4
+ export { setCssExtractPlugin, setHTMLPlugin } from '../pluginHelper';
5
5
  export { initRsbuildConfig } from './initConfigs';
6
6
  export { stringifyConfig, getRsbuildInspectConfig, outputInspectConfigFiles, } from '../config';
7
7
  export { getHTMLPlugin } from '../pluginHelper';
@@ -7,4 +7,4 @@ export declare function setupCliShortcuts({ help, openPage, closeServer, printUr
7
7
  printUrls: () => void;
8
8
  restartServer?: () => Promise<void>;
9
9
  customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
10
- }): void;
10
+ }): () => void;
@@ -356,13 +356,16 @@ export type PrintFileSizeOptions = {
356
356
  exclude?: (asset: PrintFileSizeAsset) => boolean;
357
357
  };
358
358
  export interface PreconnectOption {
359
+ /**
360
+ * The URL of the resource to preconnect to.
361
+ */
359
362
  href: string;
363
+ /**
364
+ * Whether to add `crossorigin` attribute to the `<link>` element.
365
+ */
360
366
  crossorigin?: boolean;
361
367
  }
362
368
  export type Preconnect = Array<string | PreconnectOption>;
363
- export interface DnsPrefetchOption {
364
- href: string;
365
- }
366
369
  export type DnsPrefetch = string[];
367
370
  export type PreloadIncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
368
371
  export type Filter = Array<string | RegExp> | ((filename: string) => boolean);
@@ -41,4 +41,12 @@ export type InternalContext = RsbuildContext & {
41
41
  environments: Record<string, EnvironmentContext>;
42
42
  /** Only build specified environment. */
43
43
  specifiedEnvironments?: string[];
44
+ /**
45
+ * The command type.
46
+ *
47
+ * - dev: `rsbuild dev` or `rsbuild.startDevServer()`
48
+ * - build: `rsbuild build` or `rsbuild.build()`
49
+ * - preview: `rsbuild preview` or `rsbuild.preview()`
50
+ */
51
+ command?: 'dev' | 'build' | 'preview';
44
52
  };
@@ -79,12 +79,19 @@ export type InspectConfigResult<B extends 'rspack' | 'webpack' = 'rspack'> = {
79
79
  };
80
80
  export type CreateCompiler = <C = Compiler | MultiCompiler>() => Promise<C>;
81
81
  export type CreateRsbuildOptions = {
82
- /** The root path of current project. */
82
+ /**
83
+ * The root path of current project.
84
+ * @default process.cwd()
85
+ */
83
86
  cwd?: string;
84
- /** Configurations of Rsbuild. */
85
- rsbuildConfig?: RsbuildConfig;
86
- /** Only build specified environment. */
87
+ /**
88
+ * Only build specified environments.
89
+ */
87
90
  environment?: string[];
91
+ /**
92
+ * Rsbuild configurations.
93
+ */
94
+ rsbuildConfig?: RsbuildConfig;
88
95
  };
89
96
  export type ResolvedCreateRsbuildOptions = CreateRsbuildOptions & Required<Omit<CreateRsbuildOptions, 'environment'>>;
90
97
  export type CreateDevServer = (options?: CreateDevServerOptions) => Promise<RsbuildDevServer>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,7 +46,7 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "~1.1.5",
49
+ "@rspack/core": "~1.1.6",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.15",
52
52
  "core-js": "~3.39.0"