@rsbuild/core 2.1.7 → 2.1.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.
Files changed (160) hide show
  1. package/compiled/cors/index.d.ts +1 -1
  2. package/compiled/css-loader/index.js +2 -2
  3. package/compiled/html-rspack-plugin/index.d.ts +1 -1
  4. package/compiled/html-rspack-plugin/index.js +14 -14
  5. package/compiled/postcss/index.js +1 -1
  6. package/compiled/postcss/lib/node.d.ts +2 -2
  7. package/compiled/postcss/package.json +1 -1
  8. package/compiled/postcss-loader/index.js +6 -6
  9. package/dist/{711.js → 626.js} +106 -84
  10. package/dist/build.d.ts +4 -0
  11. package/dist/chokidar.js +1 -1046
  12. package/{dist-types → dist}/cli/commands.d.ts +2 -2
  13. package/{dist-types → dist}/cli/init.d.ts +2 -2
  14. package/dist/client/hmr.js +1 -1
  15. package/dist/client/overlay.js +1 -1
  16. package/{dist-types → dist}/configChain.d.ts +2 -2
  17. package/dist/connect-next.js +1 -876
  18. package/dist/cors.js +1 -1
  19. package/{dist-types → dist}/createCompiler.d.ts +2 -2
  20. package/{dist-types → dist}/createContext.d.ts +3 -3
  21. package/{dist-types → dist}/createRsbuild.d.ts +1 -1
  22. package/{dist-types → dist}/defaultConfig.d.ts +1 -1
  23. package/{dist-types → dist}/helpers/compiler.d.ts +1 -1
  24. package/{dist-types → dist}/helpers/css.d.ts +1 -1
  25. package/{dist-types → dist}/helpers/format.d.ts +1 -1
  26. package/{dist-types → dist}/helpers/fs.d.ts +2 -2
  27. package/{dist-types → dist}/helpers/index.d.ts +4 -4
  28. package/{dist-types → dist}/helpers/overlayConfig.d.ts +1 -1
  29. package/{dist-types → dist}/helpers/path.d.ts +1 -1
  30. package/{dist-types → dist}/helpers/restartManager.d.ts +2 -2
  31. package/{dist-types → dist}/helpers/stats.d.ts +2 -2
  32. package/{dist-types → dist}/helpers/url.d.ts +2 -2
  33. package/{dist-types → dist}/helpers/vendors.d.ts +1 -1
  34. package/{dist-types → dist}/hooks.d.ts +1 -1
  35. package/dist/http-proxy-middleware.js +5 -3010
  36. package/{dist-types → dist}/index.d.ts +14 -14
  37. package/dist/index.js +1 -1
  38. package/{dist-types → dist}/initConfigs.d.ts +1 -1
  39. package/{dist-types → dist}/initPlugins.d.ts +2 -2
  40. package/{dist-types → dist}/inspectConfig.d.ts +2 -2
  41. package/dist/launch-editor-middleware.js +1 -544
  42. package/{dist-types → dist}/loadConfig.d.ts +6 -6
  43. package/{dist-types → dist}/loader/cssUrlLoader.d.ts +1 -1
  44. package/{dist-types → dist}/loader/ignoreCssLoader.d.ts +1 -1
  45. package/{dist-types → dist}/loader/transformLoader.d.ts +1 -1
  46. package/{dist-types → dist}/loader/transformRawLoader.d.ts +1 -1
  47. package/{dist-types → dist}/logger.d.ts +1 -1
  48. package/dist/manifest-plugin.js +1 -692
  49. package/dist/memfs.js +1 -5695
  50. package/{dist-types → dist}/mergeConfig.d.ts +1 -1
  51. package/dist/open.js +2 -439
  52. package/{dist-types → dist}/pluginHelper.d.ts +1 -1
  53. package/{dist-types → dist}/pluginManager.d.ts +2 -2
  54. package/{dist-types → dist}/plugins/appIcon.d.ts +1 -1
  55. package/{dist-types → dist}/plugins/asset.d.ts +1 -1
  56. package/{dist-types → dist}/plugins/basic.d.ts +1 -1
  57. package/dist/plugins/cache.d.ts +2 -0
  58. package/{dist-types → dist}/plugins/cleanOutput.d.ts +1 -1
  59. package/{dist-types → dist}/plugins/css.d.ts +1 -1
  60. package/{dist-types → dist}/plugins/define.d.ts +1 -1
  61. package/dist/plugins/entry.d.ts +2 -0
  62. package/{dist-types → dist}/plugins/externals.d.ts +2 -2
  63. package/{dist-types → dist}/plugins/fileSize.d.ts +1 -1
  64. package/{dist-types → dist}/plugins/html.d.ts +1 -1
  65. package/{dist-types → dist}/plugins/inlineChunk.d.ts +1 -1
  66. package/{dist-types → dist}/plugins/lazyCompilation.d.ts +1 -1
  67. package/{dist-types → dist}/plugins/manifest.d.ts +1 -1
  68. package/{dist-types → dist}/plugins/minimize.d.ts +2 -2
  69. package/{dist-types → dist}/plugins/moduleFederation.d.ts +1 -1
  70. package/{dist-types → dist}/plugins/nodeAddons.d.ts +1 -1
  71. package/dist/plugins/nonce.d.ts +2 -0
  72. package/{dist-types → dist}/plugins/output.d.ts +1 -1
  73. package/{dist-types → dist}/plugins/progress.d.ts +1 -1
  74. package/{dist-types → dist}/plugins/resolve.d.ts +1 -1
  75. package/{dist-types → dist}/plugins/resourceHints.d.ts +1 -1
  76. package/{dist-types → dist}/plugins/rsdoctor.d.ts +1 -1
  77. package/{dist-types → dist}/plugins/rspackProfile.d.ts +1 -1
  78. package/{dist-types → dist}/plugins/server.d.ts +1 -1
  79. package/{dist-types → dist}/plugins/sourceMap.d.ts +1 -1
  80. package/{dist-types → dist}/plugins/splitChunks.d.ts +1 -1
  81. package/dist/plugins/sri.d.ts +2 -0
  82. package/{dist-types → dist}/plugins/swc.d.ts +1 -1
  83. package/{dist-types → dist}/plugins/target.d.ts +1 -1
  84. package/dist/plugins/wasm.d.ts +2 -0
  85. package/{dist-types → dist}/plugins/worker.d.ts +1 -1
  86. package/dist/range-parser.js +1 -1
  87. package/dist/restart.d.ts +15 -0
  88. package/{dist-types → dist}/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -1
  89. package/{dist-types → dist}/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +1 -1
  90. package/{dist-types → dist}/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +1 -1
  91. package/{dist-types → dist}/rspack-plugins/resource-hints/extractChunks.d.ts +1 -1
  92. package/{dist-types → dist}/rspackConfig.d.ts +1 -1
  93. package/{dist-types → dist}/server/assets-middleware/getFileFromUrl.d.ts +1 -1
  94. package/{dist-types → dist}/server/assets-middleware/index.d.ts +2 -2
  95. package/{dist-types → dist}/server/assets-middleware/middleware.d.ts +1 -1
  96. package/{dist-types → dist}/server/assets-middleware/setupOutputFileSystem.d.ts +1 -1
  97. package/{dist-types → dist}/server/assets-middleware/setupWriteToDisk.d.ts +2 -2
  98. package/{dist-types → dist}/server/browserLogs.d.ts +1 -1
  99. package/{dist-types → dist}/server/buildManager.d.ts +3 -3
  100. package/{dist-types → dist}/server/cliShortcuts.d.ts +2 -2
  101. package/{dist-types → dist}/server/devMiddlewares.d.ts +4 -4
  102. package/{dist-types → dist}/server/devServer.d.ts +4 -4
  103. package/{dist-types → dist}/server/environment.d.ts +1 -1
  104. package/{dist-types → dist}/server/gzipMiddleware.d.ts +1 -1
  105. package/{dist-types → dist}/server/helper.d.ts +4 -4
  106. package/{dist-types → dist}/server/historyApiFallback.d.ts +2 -2
  107. package/{dist-types → dist}/server/httpServer.d.ts +1 -1
  108. package/{dist-types → dist}/server/middlewares.d.ts +2 -2
  109. package/{dist-types → dist}/server/open.d.ts +2 -2
  110. package/{dist-types → dist}/server/previewServer.d.ts +2 -2
  111. package/{dist-types → dist}/server/proxy.d.ts +3 -3
  112. package/{dist-types → dist}/server/runner/basic.d.ts +1 -1
  113. package/{dist-types → dist}/server/runner/cjs.d.ts +2 -2
  114. package/{dist-types → dist}/server/runner/esm.d.ts +2 -2
  115. package/{dist-types → dist}/server/runner/index.d.ts +1 -1
  116. package/{dist-types → dist}/server/serverSetup.d.ts +1 -1
  117. package/{dist-types → dist}/server/socketServer.d.ts +1 -1
  118. package/{dist-types → dist}/server/watchFiles.d.ts +4 -3
  119. package/dist/sirv.js +1 -1
  120. package/dist/tinyglobby.js +1 -1670
  121. package/{dist-types → dist}/types/config.d.ts +24 -15
  122. package/{dist-types → dist}/types/context.d.ts +9 -9
  123. package/{dist-types → dist}/types/hooks.d.ts +31 -15
  124. package/dist/types/index.d.ts +8 -0
  125. package/{dist-types → dist}/types/plugin.d.ts +7 -7
  126. package/{dist-types → dist}/types/rsbuild.d.ts +15 -14
  127. package/{dist-types → dist}/types/rspack.d.ts +2 -2
  128. package/{dist-types → dist}/types/thirdParty.d.ts +5 -5
  129. package/dist/ws.js +2 -1524
  130. package/package.json +9 -10
  131. package/dist-types/build.d.ts +0 -4
  132. package/dist-types/package.json +0 -1
  133. package/dist-types/plugins/cache.d.ts +0 -2
  134. package/dist-types/plugins/entry.d.ts +0 -2
  135. package/dist-types/plugins/nonce.d.ts +0 -2
  136. package/dist-types/plugins/sri.d.ts +0 -2
  137. package/dist-types/plugins/wasm.d.ts +0 -2
  138. package/dist-types/restart.d.ts +0 -14
  139. package/dist-types/types/index.d.ts +0 -8
  140. /package/dist/{711.js.LICENSE.txt → 626.js.LICENSE.txt} +0 -0
  141. /package/{dist-types → dist}/cli/index.d.ts +0 -0
  142. /package/dist/client/{307.js → 307~0.js} +0 -0
  143. /package/{dist-types → dist}/constants.d.ts +0 -0
  144. /package/{dist-types → dist}/helpers/exitHook.d.ts +0 -0
  145. /package/{dist-types → dist}/helpers/packageJson.d.ts +0 -0
  146. /package/{dist-types → dist}/helpers/version.d.ts +0 -0
  147. /package/{dist-types → dist}/loadEnv.d.ts +0 -0
  148. /package/{dist-types → dist}/loader/workerLoader.d.ts +0 -0
  149. /package/dist/{1~rslib-runtime.js → rslib-runtime.js} +0 -0
  150. /package/{dist-types → dist}/rspack-plugins/resource-hints/getResourceType.d.ts +0 -0
  151. /package/{dist-types → dist}/server/ansiHTML.d.ts +0 -0
  152. /package/{dist-types → dist}/server/assets-middleware/parseTokenList.d.ts +0 -0
  153. /package/{dist-types → dist}/server/compileState.d.ts +0 -0
  154. /package/{dist-types → dist}/server/gracefulShutdown.d.ts +0 -0
  155. /package/{dist-types → dist}/server/hmrFallback.d.ts +0 -0
  156. /package/{dist-types → dist}/server/overlay.d.ts +0 -0
  157. /package/{dist-types → dist}/server/publicPathnames.d.ts +0 -0
  158. /package/{dist-types → dist}/server/runner/asModule.d.ts +0 -0
  159. /package/{dist-types → dist}/server/runner/type.d.ts +0 -0
  160. /package/{dist-types → dist}/types/utils.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- /*! LICENSE: 711.js.LICENSE.txt */
1
+ /*! LICENSE: 626.js.LICENSE.txt */
2
2
  let runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin;
3
3
  import { rspack as core_rspack } from "@rspack/core";
4
4
  import node_util, { stripVTControlCharacters } from "node:util";
@@ -11,7 +11,7 @@ import { URL as external_node_url_URL, pathToFileURL, fileURLToPath as __rspack_
11
11
  import { isPromise, isRegExp } from "node:util/types";
12
12
  import { readFile } from "node:fs/promises";
13
13
  import node_zlib from "node:zlib";
14
- import { __webpack_require__ } from "./1~rslib-runtime.js";
14
+ import { __webpack_require__ } from "./rslib-runtime.js";
15
15
  var superClass, superClass1, __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
16
16
  let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
17
17
  __webpack_require__.add({
@@ -151,7 +151,7 @@ __webpack_require__.add({
151
151
  };
152
152
  },
153
153
  "../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
154
- let path = __webpack_require__("path?aeb1"), fs = __webpack_require__("fs?8b28"), os = __webpack_require__("os"), url = __webpack_require__("url?b918"), fsReadFileAsync = fs.promises.readFile;
154
+ let path = __webpack_require__("path?37f5"), fs = __webpack_require__("fs?cdbd"), os = __webpack_require__("os"), url = __webpack_require__("url?5f07"), fsReadFileAsync = fs.promises.readFile;
155
155
  function getDefaultSearchPlaces(name, sync) {
156
156
  return [
157
157
  'package.json',
@@ -386,8 +386,8 @@ __webpack_require__.add({
386
386
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
387
387
  }
388
388
  },
389
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
390
- let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js");
389
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
390
+ let yaml, { resolve } = __webpack_require__("node:path?815c"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/req.js");
391
391
  async function processResult(ctx, result) {
392
392
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
393
393
  default: obj
@@ -460,8 +460,8 @@ __webpack_require__.add({
460
460
  });
461
461
  };
462
462
  },
463
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
464
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js");
463
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
464
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/req.js");
465
465
  module.exports = async function options(config, file) {
466
466
  if (config.parser && 'string' == typeof config.parser) try {
467
467
  config.parser = await req(config.parser, file);
@@ -481,8 +481,8 @@ __webpack_require__.add({
481
481
  return config;
482
482
  };
483
483
  },
484
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
485
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js");
484
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
485
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/req.js");
486
486
  async function load(plugin, options, file) {
487
487
  try {
488
488
  if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
@@ -498,8 +498,8 @@ __webpack_require__.add({
498
498
  }), list;
499
499
  };
500
500
  },
501
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
502
- let tsx, jiti, { createRequire } = __webpack_require__("node:module?1bcb"), { pathToFileURL } = __webpack_require__("node:url?b4ec"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
501
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
502
+ let tsx, jiti, { createRequire } = __webpack_require__("node:module?f56b"), { pathToFileURL } = __webpack_require__("node:url?5295"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
503
503
  module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
504
504
  let url = createRequire(rootFile).resolve(name);
505
505
  try {
@@ -539,7 +539,7 @@ __webpack_require__.add({
539
539
  crypto (module) {
540
540
  module.exports = __rspack_createRequire_require("crypto");
541
541
  },
542
- "fs?8b28" (module) {
542
+ "fs?cdbd" (module) {
543
543
  module.exports = __rspack_createRequire_require("fs");
544
544
  },
545
545
  http (module) {
@@ -551,31 +551,31 @@ __webpack_require__.add({
551
551
  net (module) {
552
552
  module.exports = __rspack_createRequire_require("net");
553
553
  },
554
- "node:buffer?1cd0" (module) {
554
+ "node:buffer?4a79" (module) {
555
555
  module.exports = __rspack_createRequire_require("node:buffer");
556
556
  },
557
- "node:events?3ec9" (module) {
557
+ events (module) {
558
558
  module.exports = __rspack_createRequire_require("node:events");
559
559
  },
560
- "node:fs?9592" (module) {
560
+ "node:fs?31c0" (module) {
561
561
  module.exports = __rspack_createRequire_require("node:fs");
562
562
  },
563
- "node:module?1bcb" (module) {
563
+ "node:module?f56b" (module) {
564
564
  module.exports = __rspack_createRequire_require("node:module");
565
565
  },
566
- "node:path?435f" (module) {
566
+ "node:path?815c" (module) {
567
567
  module.exports = __rspack_createRequire_require("node:path");
568
568
  },
569
- "node:stream?3c93" (module) {
569
+ "node:stream?be04" (module) {
570
570
  module.exports = __rspack_createRequire_require("node:stream");
571
571
  },
572
- "node:url?b4ec" (module) {
572
+ "node:url?5295" (module) {
573
573
  module.exports = __rspack_createRequire_require("node:url");
574
574
  },
575
575
  os (module) {
576
576
  module.exports = __rspack_createRequire_require("os");
577
577
  },
578
- "path?aeb1" (module) {
578
+ "path?37f5" (module) {
579
579
  module.exports = __rspack_createRequire_require("path");
580
580
  },
581
581
  process (module) {
@@ -584,13 +584,16 @@ __webpack_require__.add({
584
584
  stream (module) {
585
585
  module.exports = __rspack_createRequire_require("stream");
586
586
  },
587
+ "supports-color" (module) {
588
+ module.exports = __rspack_createRequire_require("supports-color");
589
+ },
587
590
  tls (module) {
588
591
  module.exports = __rspack_createRequire_require("tls");
589
592
  },
590
593
  tty (module) {
591
594
  module.exports = __rspack_createRequire_require("tty");
592
595
  },
593
- "url?b918" (module) {
596
+ "url?5f07" (module) {
594
597
  module.exports = __rspack_createRequire_require("url");
595
598
  },
596
599
  util (module) {
@@ -598,12 +601,6 @@ __webpack_require__.add({
598
601
  },
599
602
  zlib (module) {
600
603
  module.exports = __rspack_createRequire_require("zlib");
601
- },
602
- events (module) {
603
- module.exports = __rspack_createRequire_require("node:events");
604
- },
605
- "supports-color" (module) {
606
- module.exports = __rspack_createRequire_require("supports-color");
607
604
  }
608
605
  }), function checkNodeVersion() {
609
606
  let { versions } = process;
@@ -3410,7 +3407,7 @@ function createPublicContext(context) {
3410
3407
  async function createContext(options, userConfig, logger, loadConfigResult) {
3411
3408
  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, hooks = initHooks();
3412
3409
  return {
3413
- version: "2.1.7",
3410
+ version: "2.1.9",
3414
3411
  rootPath,
3415
3412
  configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
3416
3413
  configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
@@ -3510,7 +3507,6 @@ function stringifyConfig(config, verbose) {
3510
3507
  });
3511
3508
  }
3512
3509
  async function inspectConfig_inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions = {} }) {
3513
- inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : process.env.NODE_ENV || setNodeEnv('development');
3514
3510
  let stringifiedBundlerConfigs = bundlerConfigs.map((config, index)=>({
3515
3511
  name: config.name || String(index),
3516
3512
  content: stringifyConfig(config, inspectOptions.verbose)
@@ -4187,6 +4183,11 @@ async function createCompiler_createCompiler(options) {
4187
4183
  rspackConfigs
4188
4184
  };
4189
4185
  }
4186
+ let DEFAULT_WATCH_FILE_EVENTS = [
4187
+ 'add',
4188
+ 'change',
4189
+ 'unlink'
4190
+ ];
4190
4191
  async function setupWatchFiles(options) {
4191
4192
  let { config, root, buildManager } = options, { hmr, liveReload } = config.dev;
4192
4193
  if (!hmr && !liveReload || !buildManager) return;
@@ -4204,8 +4205,8 @@ async function watchDevFiles(devConfig, buildManager, root) {
4204
4205
  let { watchFiles } = devConfig;
4205
4206
  if (!watchFiles) return;
4206
4207
  let watchers = [];
4207
- for (let { paths, options, type } of helpers_castArray(watchFiles)){
4208
- let watchOptions = prepareWatchOptions(paths, options, type), watcher = await startWatchFiles(watchOptions, buildManager, root);
4208
+ for (let { paths, events, options, type } of helpers_castArray(watchFiles)){
4209
+ let watchOptions = prepareWatchOptions(paths, options, type, events), watcher = await startWatchFiles(watchOptions, buildManager, root);
4209
4210
  watcher && watchers.push(watcher);
4210
4211
  }
4211
4212
  return async ()=>{
@@ -4217,11 +4218,12 @@ function watchServerFiles({ publicDir }, buildManager, root) {
4217
4218
  let watchPaths = publicDir.filter((item)=>item.watch).map((item)=>item.name);
4218
4219
  if (watchPaths.length) return startWatchFiles(prepareWatchOptions(watchPaths), buildManager, root);
4219
4220
  }
4220
- function prepareWatchOptions(paths, options = {}, type) {
4221
+ function prepareWatchOptions(paths, options = {}, type, events) {
4221
4222
  return {
4222
4223
  paths: 'string' == typeof paths ? [
4223
4224
  paths
4224
4225
  ] : paths,
4226
+ events,
4225
4227
  options,
4226
4228
  type
4227
4229
  };
@@ -4238,16 +4240,21 @@ async function createChokidar(pathOrGlobs, root, options) {
4238
4240
  }
4239
4241
  return chokidar.watch(Array.from(watchFiles), options);
4240
4242
  }
4241
- async function startWatchFiles({ paths, options, type = 'reload-page' }, buildManager, root) {
4242
- if ('reload-page' !== type) return;
4243
- let watcher = await createChokidar(paths, root, options);
4244
- return watcher.on('change', ()=>{
4243
+ async function startWatchFiles({ paths, events, options, type = 'reload-page' }, buildManager, root) {
4244
+ if ('reload-page' !== type || events?.length === 0) return;
4245
+ let watcher = await createChokidar(paths, root, {
4246
+ ignoreInitial: !0,
4247
+ ...options
4248
+ }), reloadPage = ()=>{
4245
4249
  buildManager.socketServer.sendMessage({
4246
4250
  type: 'full-reload'
4247
4251
  });
4248
- }), watcher;
4252
+ };
4253
+ for (let event of events ? new Set(events) : DEFAULT_WATCH_FILE_EVENTS)watcher.on(event, reloadPage);
4254
+ return watcher;
4249
4255
  }
4250
- let requestRestart = ({ filePath, clear = !0, action, logger, restartManager })=>{
4256
+ let requestRestart = ({ clear = !0, logger, restartContext, restartManager })=>{
4257
+ let { action, filePath } = restartContext;
4251
4258
  if (restartManager.canRestart) {
4252
4259
  clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
4253
4260
  let id = 'dev' === action ? 'server' : 'build';
@@ -4256,53 +4263,55 @@ let requestRestart = ({ filePath, clear = !0, action, logger, restartManager })=
4256
4263
  logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
4257
4264
  } else logger.info(`restarting ${id}...\n`);
4258
4265
  }
4259
- return restartManager.requestRestart({
4260
- action,
4261
- filePath
4262
- });
4266
+ return restartManager.requestRestart(restartContext);
4263
4267
  };
4264
- function watchFilesForRestart({ watchFiles, context, action }) {
4268
+ function watchFilesForRestart({ watchFiles, context, restartContext }) {
4265
4269
  let closePromise, defaultFiles = context.configFile ? [
4266
4270
  context.configFile,
4267
4271
  ...context.configFileDependencies
4268
4272
  ] : [];
4269
4273
  if (!watchFiles.length && !defaultFiles.length) return;
4270
4274
  let watchGroups = [];
4271
- for (let { paths, options, type } of watchFiles){
4272
- if ('restart' !== type && 'reload-server' !== type) continue;
4275
+ for (let { paths, events, options, type } of watchFiles){
4276
+ if ('restart' !== type && 'reload-server' !== type || events?.length === 0) continue;
4273
4277
  let files = helpers_castArray(paths);
4274
- files.length && (options ? watchGroups.push({
4278
+ files.length && (options || events ? watchGroups.push({
4275
4279
  files,
4280
+ events,
4276
4281
  options
4277
4282
  }) : defaultFiles.push(...files));
4278
4283
  }
4279
4284
  if (defaultFiles.length && watchGroups.push({
4280
4285
  files: defaultFiles
4281
4286
  }), !watchGroups.length) return;
4282
- let { logger, restartManager, rootPath: root } = context, restarting = !1, onChange = async (filePath, cwd)=>{
4287
+ let { logger, restartManager, rootPath: root } = context, restarting = !1, onWatchEvent = async (event, filePath, cwd)=>{
4283
4288
  if (restarting || closePromise) return;
4284
4289
  restarting = !0;
4285
4290
  let absoluteFilePath = node_path.resolve(cwd, filePath);
4286
4291
  try {
4287
4292
  await requestRestart({
4288
- action,
4289
- filePath: absoluteFilePath,
4293
+ restartContext: {
4294
+ ...restartContext,
4295
+ event,
4296
+ filePath: absoluteFilePath
4297
+ },
4290
4298
  logger,
4291
4299
  restartManager
4292
- }) ? await close() : restartManager.canRestart && logger.error('build' === action ? 'Restart build failed.' : 'Restart server failed.');
4300
+ }) ? await close() : restartManager.canRestart && logger.error('build' === restartContext.action ? 'Restart build failed.' : 'Restart server failed.');
4293
4301
  } catch (error) {
4294
4302
  logger.error(error);
4295
4303
  } finally{
4296
4304
  restarting = !1;
4297
4305
  }
4298
- }, watchersPromise = Promise.all(watchGroups.map(async ({ files, options })=>{
4306
+ }, watchersPromise = Promise.all(watchGroups.map(async ({ files, events, options })=>{
4299
4307
  try {
4300
4308
  let watcher = await createChokidar(files, root, {
4301
4309
  ignoreInitial: !0,
4302
4310
  ignorePermissionErrors: !0,
4303
4311
  ...options
4304
- }), cwd = options?.cwd || root, handleChange = (filePath)=>void onChange(filePath, cwd);
4305
- return watcher.on('add', handleChange), watcher.on('change', handleChange), watcher.on('unlink', handleChange), watcher;
4312
+ }), cwd = options?.cwd ?? root;
4313
+ for (let event of events ? new Set(events) : DEFAULT_WATCH_FILE_EVENTS)watcher.on(event, (filePath)=>onWatchEvent(event, filePath, cwd));
4314
+ return watcher;
4306
4315
  } catch (error) {
4307
4316
  logger.error(error);
4308
4317
  }
@@ -4311,8 +4320,8 @@ function watchFilesForRestart({ watchFiles, context, action }) {
4311
4320
  close
4312
4321
  };
4313
4322
  }
4314
- let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, { watch } = {})=>{
4315
- let stats, closeCompiler, closingPromise, unregisterRestart, restartWatcher, { context } = initOptions, { logger } = context, { compiler, rspackConfigs } = await createCompiler_createCompiler(initOptions);
4323
+ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, buildOptions = {})=>{
4324
+ let stats, closeCompiler, closingPromise, unregisterRestart, restartWatcher, { watch } = buildOptions, { context } = initOptions, { logger } = context, { compiler, rspackConfigs } = await createCompiler_createCompiler(initOptions);
4316
4325
  if ((({ context, isWatch, compiler, rspackConfigs, MultiStatsCtor })=>{
4317
4326
  let isFirstCompile = !0, { environmentList } = context, onDone = async (stats)=>{
4318
4327
  let promise = context.hooks.onAfterBuild.callBatch({
@@ -4394,7 +4403,10 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
4394
4403
  return watch && (unregisterRestart = context.restartManager.registerCleanup(closeBuild), restartWatcher = watchFilesForRestart({
4395
4404
  watchFiles: context.normalizedConfig.dev.watchFiles,
4396
4405
  context,
4397
- action: 'build'
4406
+ restartContext: {
4407
+ action: 'build',
4408
+ options: buildOptions
4409
+ }
4398
4410
  })), {
4399
4411
  stats,
4400
4412
  close: async ()=>{
@@ -5016,7 +5028,7 @@ function parseMinifyOptions(config) {
5016
5028
  cssOptions: minify.cssOptions
5017
5029
  };
5018
5030
  }
5019
- let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/index.js");
5031
+ let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23/node_modules/postcss-load-config/src/index.js");
5020
5032
  var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
5021
5033
  async function getLightningCSSLoaderOptions(config, targets, minify) {
5022
5034
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
@@ -8128,9 +8140,14 @@ async function applyServerSetup(setup, context) {
8128
8140
  }
8129
8141
  return postCallbacks;
8130
8142
  }
8131
- async function devServer_createDevServer(options, createCompiler, config, { getPortSilently, runCompile = !0 } = {}) {
8143
+ async function devServer_createDevServer(options, createCompiler, config, devServerOptions = {}) {
8132
8144
  var environmentCount;
8133
- let closingPromise, unregisterRestart, stats, waiters, { context } = options, { logger } = context;
8145
+ let closingPromise, unregisterRestart, stats, waiters, { getPortSilently, runCompile = !0 } = devServerOptions, restartContext = {
8146
+ action: 'dev',
8147
+ options: pick(devServerOptions, [
8148
+ 'getPortSilently'
8149
+ ])
8150
+ }, { context } = options, { logger } = context;
8134
8151
  logger.debug('create dev server');
8135
8152
  let { port, portTip } = await resolvePort(config), { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
8136
8153
  context.devServer = {
@@ -8210,7 +8227,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
8210
8227
  await state.restartWatcher?.close(), await closeServerResources();
8211
8228
  }, restartServer = async ()=>{
8212
8229
  let restarted = await requestRestart({
8213
- action: 'dev',
8230
+ restartContext,
8214
8231
  clear: !1,
8215
8232
  logger,
8216
8233
  restartManager: context.restartManager
@@ -8330,7 +8347,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
8330
8347
  }), state.buildManager?.watch(), unregisterRestart = context.restartManager.registerCleanup(closeServerResources), state.restartWatcher = watchFilesForRestart({
8331
8348
  watchFiles: config.dev.watchFiles,
8332
8349
  context,
8333
- action: 'dev'
8350
+ restartContext
8334
8351
  }), logger.debug('create dev server done'), devServer;
8335
8352
  }
8336
8353
  async function startPreviewServer(context, config, { getPortSilently } = {}) {
@@ -9186,8 +9203,8 @@ try {
9186
9203
  chain.optimization.minimizer(minimizerId).use(rspack.SwcJsMinimizerRspackPlugin, [
9187
9204
  getSwcMinimizerOptions(config, jsOptionsItem)
9188
9205
  ]).end();
9189
- }, jsOptionsList = helpers_castArray(jsOptions);
9190
- jsOptionsList.length > 0 ? jsOptionsList.forEach(registerJsMinimizer) : registerJsMinimizer();
9206
+ };
9207
+ Array.isArray(jsOptions) ? 0 === jsOptions.length ? registerJsMinimizer() : jsOptions.forEach(registerJsMinimizer) : registerJsMinimizer(jsOptions);
9191
9208
  }
9192
9209
  if (minifyCss) {
9193
9210
  let loaderOptions = await getLightningCSSLoaderOptions(config, environment.browserslist, !0), defaultOptions = {
@@ -9203,10 +9220,13 @@ try {
9203
9220
  'errorRecovery'
9204
9221
  ])
9205
9222
  }
9206
- }, mergedOptions = cssOptions ? cjs_0_default()(defaultOptions, cssOptions) : defaultOptions;
9207
- chain.optimization.minimizer(CHAIN_ID.MINIMIZER.CSS).use(rspack.LightningCssMinimizerRspackPlugin, [
9208
- mergedOptions
9209
- ]).end();
9223
+ }, registerCssMinimizer = (cssOptionsItem, index = 0)=>{
9224
+ let options = cssOptionsItem ? cjs_0_default()(defaultOptions, cssOptionsItem) : defaultOptions, minimizerId = 0 === index ? CHAIN_ID.MINIMIZER.CSS : `${CHAIN_ID.MINIMIZER.CSS}-${index}`;
9225
+ chain.optimization.minimizer(minimizerId).use(rspack.LightningCssMinimizerRspackPlugin, [
9226
+ options
9227
+ ]).end();
9228
+ };
9229
+ Array.isArray(cssOptions) ? 0 === cssOptions.length ? registerCssMinimizer() : cssOptions.forEach(registerCssMinimizer) : registerCssMinimizer(cssOptions);
9210
9230
  }
9211
9231
  });
9212
9232
  }
@@ -9551,7 +9571,7 @@ try {
9551
9571
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
9552
9572
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
9553
9573
  if (!1 === manifest) return;
9554
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1.5/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
9574
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1.7/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
9555
9575
  manifestFilenames.set(environment.name, manifestOptions.filename);
9556
9576
  let pluginOptions = {
9557
9577
  fileName: manifestOptions.filename,
@@ -9755,8 +9775,8 @@ async function createRsbuild(options = {}) {
9755
9775
  cwd: options.cwd,
9756
9776
  ...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
9757
9777
  }) : null, configOrFactory = options.config ?? options.rsbuildConfig, config = isFunction(configOrFactory) ? await configOrFactory() : configOrFactory;
9758
- isLoadConfigResult(config) && (loadConfigResult = config, config = config.content);
9759
- let logger = (config ||= {}).customLogger ?? logger_createLogger({
9778
+ isLoadConfigResult(config) && (loadConfigResult = config, config = config.content), config ||= {};
9779
+ let logger = config.customLogger ?? logger_createLogger({
9760
9780
  ...src_logger.options,
9761
9781
  level: src_logger.level
9762
9782
  });
@@ -9788,11 +9808,13 @@ async function createRsbuild(options = {}) {
9788
9808
  if (isEmptyDir(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} is empty, please build the project before previewing.`);
9789
9809
  }
9790
9810
  return startPreviewServer(context, config, options);
9791
- }, build = async (options)=>(context.action = 'build', process.env.NODE_ENV || setNodeEnv('production'), build_build({
9811
+ }, build = async (options = {})=>(context.action = 'build', process.env.NODE_ENV || setNodeEnv('production'), build_build({
9792
9812
  context,
9793
9813
  pluginManager,
9794
9814
  rsbuildOptions: resolvedOptions
9795
- }, options)), startDevServer = async (options)=>{
9815
+ }, {
9816
+ ...options
9817
+ })), startDevServer = async (options = {})=>{
9796
9818
  context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
9797
9819
  let config = await initRsbuildConfig({
9798
9820
  context,
@@ -9802,7 +9824,9 @@ async function createRsbuild(options = {}) {
9802
9824
  context,
9803
9825
  pluginManager,
9804
9826
  rsbuildOptions: resolvedOptions
9805
- }, createCompiler, config, options)).listen();
9827
+ }, createCompiler, config, {
9828
+ ...options
9829
+ })).listen();
9806
9830
  }, createDevServer = async (options)=>{
9807
9831
  context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
9808
9832
  let config = await initRsbuildConfig({
@@ -9814,10 +9838,10 @@ async function createRsbuild(options = {}) {
9814
9838
  pluginManager,
9815
9839
  rsbuildOptions: resolvedOptions
9816
9840
  }, createCompiler, config, options);
9817
- }, initAction = ()=>{
9818
- context.action || (context.action = 'development' === config.mode ? 'dev' : 'build');
9819
- }, inspectConfig = async (inspectOptions)=>{
9820
- initAction();
9841
+ }, initAction = (mode = config.mode)=>{
9842
+ context.action || (context.action = 'development' === mode ? 'dev' : 'build');
9843
+ }, inspectConfig = async (inspectOptions = {})=>{
9844
+ inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : process.env.NODE_ENV || setNodeEnv('development'), initAction(config.mode ?? (process.env.NODE_ENV || ''));
9821
9845
  let { rspackConfigs } = await initConfigs_initConfigs({
9822
9846
  context,
9823
9847
  pluginManager,
@@ -10059,13 +10083,11 @@ let cliState = {
10059
10083
  config.output ||= {}, config.output.sourceMap = sourceMap;
10060
10084
  }
10061
10085
  return void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), result;
10062
- }, init_restart = async ({ action })=>{
10086
+ }, init_restart = async (context)=>{
10063
10087
  let rsbuild = await init_init({
10064
10088
  isRestart: !0
10065
10089
  });
10066
- return !!rsbuild && ('build' === action ? await rsbuild.build({
10067
- watch: !0
10068
- }) : await rsbuild.startDevServer(), !0);
10090
+ return !!rsbuild && ('build' === context.action ? await rsbuild.build(context.options) : await rsbuild.startDevServer(context.options), !0);
10069
10091
  };
10070
10092
  async function init_init({ isRestart } = {}) {
10071
10093
  let logger = src_logger, { options } = cliState;
@@ -10092,7 +10114,7 @@ let applyServerOptions = (command)=>{
10092
10114
  };
10093
10115
  function setupCommands(argv) {
10094
10116
  let cli = ((name = "")=>new CAC(name))('rsbuild');
10095
- cli.version("2.1.7"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
10117
+ cli.version("2.1.9"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
10096
10118
  default: 'auto'
10097
10119
  }).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
10098
10120
  type: [
@@ -10157,7 +10179,7 @@ function setupCommands(argv) {
10157
10179
  }
10158
10180
  function showGreeting() {
10159
10181
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10160
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.7\n`);
10182
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.9\n`);
10161
10183
  }
10162
10184
  function setupLogLevel(argv) {
10163
10185
  if (argv.length <= 3) return;
@@ -10179,5 +10201,5 @@ function runCLI({ argv = process.argv } = {}) {
10179
10201
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10180
10202
  }
10181
10203
  }
10182
- let src_version = "2.1.7";
10204
+ let src_version = "2.1.9";
10183
10205
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
@@ -0,0 +1,4 @@
1
+ import type { InitConfigsOptions } from './initConfigs.js';
2
+ import type { Build, BuildOptions } from './types/index.js';
3
+ export declare const RSPACK_BUILD_ERROR = 'Rspack build failed.';
4
+ export declare const build: (initOptions: InitConfigsOptions, buildOptions?: BuildOptions) => Promise<ReturnType<Build>>;