@ohos-ports/rsbuild-core 2.2.9-beta.0

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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/bin/rsbuild.js +20 -0
  4. package/compiled/@rstackjs/load-config/index.d.ts +87 -0
  5. package/compiled/@rstackjs/load-config/license +21 -0
  6. package/compiled/@rstackjs/load-config/package.json +1 -0
  7. package/compiled/chokidar/index.d.ts +385 -0
  8. package/compiled/chokidar/license +21 -0
  9. package/compiled/chokidar/package.json +1 -0
  10. package/compiled/connect-next/index.d.ts +57 -0
  11. package/compiled/connect-next/license +26 -0
  12. package/compiled/connect-next/package.json +1 -0
  13. package/compiled/cors/index.d.ts +56 -0
  14. package/compiled/cors/license +22 -0
  15. package/compiled/cors/package.json +1 -0
  16. package/compiled/css-loader/api.js +85 -0
  17. package/compiled/css-loader/getUrl.js +26 -0
  18. package/compiled/css-loader/index.d.ts +1 -0
  19. package/compiled/css-loader/index.js +2 -0
  20. package/compiled/css-loader/license +20 -0
  21. package/compiled/css-loader/noSourceMaps.js +5 -0
  22. package/compiled/css-loader/package.json +1 -0
  23. package/compiled/css-loader/sourceMaps.js +16 -0
  24. package/compiled/html-rspack-plugin/default_index.ejs +9 -0
  25. package/compiled/html-rspack-plugin/htmlLoader.js +157 -0
  26. package/compiled/html-rspack-plugin/index.d.ts +395 -0
  27. package/compiled/html-rspack-plugin/index.js +2400 -0
  28. package/compiled/html-rspack-plugin/license +20 -0
  29. package/compiled/html-rspack-plugin/package.json +1 -0
  30. package/compiled/http-proxy-middleware/index.d.ts +455 -0
  31. package/compiled/http-proxy-middleware/license +22 -0
  32. package/compiled/http-proxy-middleware/package.json +1 -0
  33. package/compiled/jiti/LICENSE +21 -0
  34. package/compiled/jiti/README.md +258 -0
  35. package/compiled/jiti/dist/babel.cjs +47446 -0
  36. package/compiled/jiti/dist/jiti.cjs +5990 -0
  37. package/compiled/jiti/lib/jiti-cli.mjs +19 -0
  38. package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
  39. package/compiled/jiti/lib/jiti-native.mjs +76 -0
  40. package/compiled/jiti/lib/jiti-register.d.mts +1 -0
  41. package/compiled/jiti/lib/jiti-register.mjs +2 -0
  42. package/compiled/jiti/lib/jiti-static.mjs +19 -0
  43. package/compiled/jiti/lib/jiti.cjs +24 -0
  44. package/compiled/jiti/lib/jiti.d.cts +8 -0
  45. package/compiled/jiti/lib/jiti.d.mts +8 -0
  46. package/compiled/jiti/lib/jiti.mjs +23 -0
  47. package/compiled/jiti/lib/types.d.ts +420 -0
  48. package/compiled/jiti/package.json +146 -0
  49. package/compiled/postcss/index.js +1 -0
  50. package/compiled/postcss/lib/at-rule.d.ts +139 -0
  51. package/compiled/postcss/lib/comment.d.ts +67 -0
  52. package/compiled/postcss/lib/container.d.ts +474 -0
  53. package/compiled/postcss/lib/css-syntax-error.d.ts +247 -0
  54. package/compiled/postcss/lib/declaration.d.ts +150 -0
  55. package/compiled/postcss/lib/document.d.ts +68 -0
  56. package/compiled/postcss/lib/fromJSON.d.ts +9 -0
  57. package/compiled/postcss/lib/input.d.ts +226 -0
  58. package/compiled/postcss/lib/lazy-result.d.ts +189 -0
  59. package/compiled/postcss/lib/list.d.ts +60 -0
  60. package/compiled/postcss/lib/no-work-result.d.ts +45 -0
  61. package/compiled/postcss/lib/node.d.ts +555 -0
  62. package/compiled/postcss/lib/parse.d.ts +9 -0
  63. package/compiled/postcss/lib/postcss.d.ts +464 -0
  64. package/compiled/postcss/lib/previous-map.d.ts +80 -0
  65. package/compiled/postcss/lib/processor.d.ts +114 -0
  66. package/compiled/postcss/lib/result.d.ts +204 -0
  67. package/compiled/postcss/lib/root.d.ts +86 -0
  68. package/compiled/postcss/lib/rule.d.ts +126 -0
  69. package/compiled/postcss/lib/source-map-js.d.ts +4 -0
  70. package/compiled/postcss/lib/stringifier.d.ts +45 -0
  71. package/compiled/postcss/lib/stringify.d.ts +9 -0
  72. package/compiled/postcss/lib/warning.d.ts +146 -0
  73. package/compiled/postcss/license +20 -0
  74. package/compiled/postcss/package.json +1 -0
  75. package/compiled/postcss-loader/index.d.ts +1 -0
  76. package/compiled/postcss-loader/index.js +721 -0
  77. package/compiled/postcss-loader/license +20 -0
  78. package/compiled/postcss-loader/package.json +1 -0
  79. package/compiled/rslog/index.d.ts +98 -0
  80. package/compiled/rslog/license +21 -0
  81. package/compiled/rslog/package.json +1 -0
  82. package/compiled/rspack-chain/license +22 -0
  83. package/compiled/rspack-chain/package.json +1 -0
  84. package/compiled/rspack-chain/types/index.d.ts +515 -0
  85. package/compiled/rspack-manifest-plugin/index.d.ts +52 -0
  86. package/compiled/rspack-manifest-plugin/license +21 -0
  87. package/compiled/rspack-manifest-plugin/package.json +1 -0
  88. package/compiled/style-loader/index.d.ts +1 -0
  89. package/compiled/style-loader/index.js +370 -0
  90. package/compiled/style-loader/license +20 -0
  91. package/compiled/style-loader/package.json +1 -0
  92. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  93. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  94. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  95. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  96. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  97. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  98. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  99. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  100. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  101. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  102. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  103. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  104. package/compiled/ws/index.d.ts +445 -0
  105. package/compiled/ws/license +21 -0
  106. package/compiled/ws/package.json +1 -0
  107. package/dist/build.d.ts +4 -0
  108. package/dist/c.js +10 -0
  109. package/dist/chokidar.js +2 -0
  110. package/dist/chokidar.js.LICENSE.txt +1 -0
  111. package/dist/cli/commands.d.ts +31 -0
  112. package/dist/cli/index.d.ts +7 -0
  113. package/dist/cli/init.d.ts +7 -0
  114. package/dist/client/f~0.js +22 -0
  115. package/dist/client/hmr.js +267 -0
  116. package/dist/client/overlay.js +214 -0
  117. package/dist/configChain.d.ts +84 -0
  118. package/dist/connect-next.js +2 -0
  119. package/dist/connect-next.js.LICENSE.txt +57 -0
  120. package/dist/constants.d.ts +67 -0
  121. package/dist/cors.js +188 -0
  122. package/dist/cors.js.LICENSE.txt +11 -0
  123. package/dist/createCompiler.d.ts +6 -0
  124. package/dist/createContext.d.ts +12 -0
  125. package/dist/createRsbuild.d.ts +4 -0
  126. package/dist/cssUrlLoader.mjs +34 -0
  127. package/dist/defaultConfig.d.ts +23 -0
  128. package/dist/freshImport.js +90 -0
  129. package/dist/helpers/cachedImport.d.ts +2 -0
  130. package/dist/helpers/compiler.d.ts +5 -0
  131. package/dist/helpers/css.d.ts +3 -0
  132. package/dist/helpers/exitHook.d.ts +3 -0
  133. package/dist/helpers/format.d.ts +4 -0
  134. package/dist/helpers/fs.d.ts +16 -0
  135. package/dist/helpers/html.d.ts +2 -0
  136. package/dist/helpers/index.d.ts +29 -0
  137. package/dist/helpers/overlayConfig.d.ts +4 -0
  138. package/dist/helpers/packageJson.d.ts +9 -0
  139. package/dist/helpers/path.d.ts +22 -0
  140. package/dist/helpers/restartManager.d.ts +15 -0
  141. package/dist/helpers/stats.d.ts +17 -0
  142. package/dist/helpers/url.d.ts +11 -0
  143. package/dist/helpers/vendors.d.ts +12 -0
  144. package/dist/helpers/version.d.ts +7 -0
  145. package/dist/hooks.d.ts +41 -0
  146. package/dist/http-proxy-middleware.js +14 -0
  147. package/dist/http-proxy-middleware.js.LICENSE.txt +34 -0
  148. package/dist/ignoreCssLoader.mjs +9 -0
  149. package/dist/index.d.ts +28 -0
  150. package/dist/index.js +1 -0
  151. package/dist/initConfigs.d.ts +18 -0
  152. package/dist/initPlugins.d.ts +7 -0
  153. package/dist/inspectConfig.d.ts +7 -0
  154. package/dist/launch-editor-middleware.js +1 -0
  155. package/dist/loadConfig.d.ts +31 -0
  156. package/dist/loadEnv.d.ts +54 -0
  157. package/dist/loader/cssUrlLoader.d.ts +9 -0
  158. package/dist/loader/ignoreCssLoader.d.ts +10 -0
  159. package/dist/loader/transformLoader.d.ts +8 -0
  160. package/dist/loader/transformRawLoader.d.ts +4 -0
  161. package/dist/loader/workerLoader.d.ts +6 -0
  162. package/dist/logger.d.ts +24 -0
  163. package/dist/m.js +10348 -0
  164. package/dist/m.js.LICENSE.txt +26 -0
  165. package/dist/manifest-plugin.js +1 -0
  166. package/dist/memfs.js +1 -0
  167. package/dist/mergeConfig.d.ts +7 -0
  168. package/dist/open.js +2 -0
  169. package/dist/pluginHelper.d.ts +4 -0
  170. package/dist/pluginManager.d.ts +19 -0
  171. package/dist/plugins/appIcon.d.ts +2 -0
  172. package/dist/plugins/asset.d.ts +3 -0
  173. package/dist/plugins/basic.d.ts +4 -0
  174. package/dist/plugins/cache.d.ts +2 -0
  175. package/dist/plugins/cleanOutput.d.ts +2 -0
  176. package/dist/plugins/css.d.ts +8 -0
  177. package/dist/plugins/define.d.ts +2 -0
  178. package/dist/plugins/entry.d.ts +2 -0
  179. package/dist/plugins/externals.d.ts +9 -0
  180. package/dist/plugins/fileSize.d.ts +7 -0
  181. package/dist/plugins/html.d.ts +9 -0
  182. package/dist/plugins/inlineChunk.d.ts +6 -0
  183. package/dist/plugins/lazyCompilation.d.ts +2 -0
  184. package/dist/plugins/manifest.d.ts +2 -0
  185. package/dist/plugins/minimize.d.ts +10 -0
  186. package/dist/plugins/moduleFederation.d.ts +2 -0
  187. package/dist/plugins/nodeAddons.d.ts +2 -0
  188. package/dist/plugins/nonce.d.ts +2 -0
  189. package/dist/plugins/output.d.ts +2 -0
  190. package/dist/plugins/progress.d.ts +2 -0
  191. package/dist/plugins/resolve.d.ts +2 -0
  192. package/dist/plugins/resourceHints.d.ts +2 -0
  193. package/dist/plugins/rsdoctor.d.ts +2 -0
  194. package/dist/plugins/rspackProfile.d.ts +4 -0
  195. package/dist/plugins/server.d.ts +3 -0
  196. package/dist/plugins/sourceMap.d.ts +2 -0
  197. package/dist/plugins/splitChunks.d.ts +4 -0
  198. package/dist/plugins/sri.d.ts +2 -0
  199. package/dist/plugins/swc.d.ts +4 -0
  200. package/dist/plugins/target.d.ts +2 -0
  201. package/dist/plugins/wasm.d.ts +2 -0
  202. package/dist/plugins/worker.d.ts +2 -0
  203. package/dist/r.js +7 -0
  204. package/dist/range-parser.js +55 -0
  205. package/dist/range-parser.js.LICENSE.txt +6 -0
  206. package/dist/remapping.js +201 -0
  207. package/dist/restart.d.ts +15 -0
  208. package/dist/rslib-runtime.js +49 -0
  209. package/dist/rspack-plugins/RsbuildHtmlPlugin.d.ts +37 -0
  210. package/dist/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +36 -0
  211. package/dist/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +27 -0
  212. package/dist/rspack-plugins/resource-hints/extractChunks.d.ts +22 -0
  213. package/dist/rspack-plugins/resource-hints/getResourceType.d.ts +21 -0
  214. package/dist/rspackConfig.d.ts +8 -0
  215. package/dist/server/ansiHTML.d.ts +3 -0
  216. package/dist/server/assets-middleware/getFileFromUrl.d.ts +11 -0
  217. package/dist/server/assets-middleware/index.d.ts +35 -0
  218. package/dist/server/assets-middleware/memoryFileSystem.d.ts +2 -0
  219. package/dist/server/assets-middleware/middleware.d.ts +7 -0
  220. package/dist/server/assets-middleware/parseTokenList.d.ts +1 -0
  221. package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
  222. package/dist/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
  223. package/dist/server/browserLogs.d.ts +8 -0
  224. package/dist/server/buildManager.d.ts +32 -0
  225. package/dist/server/cliShortcuts.d.ts +19 -0
  226. package/dist/server/compileState.d.ts +5 -0
  227. package/dist/server/devMiddlewares.d.ts +18 -0
  228. package/dist/server/devServer.d.ts +47 -0
  229. package/dist/server/environment.d.ts +8 -0
  230. package/dist/server/gracefulShutdown.d.ts +8 -0
  231. package/dist/server/gzipMiddleware.d.ts +2 -0
  232. package/dist/server/helper.d.ts +118 -0
  233. package/dist/server/historyApiFallback.d.ts +10 -0
  234. package/dist/server/hmrFallback.d.ts +1 -0
  235. package/dist/server/httpServer.d.ts +7 -0
  236. package/dist/server/middlewares.d.ts +31 -0
  237. package/dist/server/open.d.ts +12 -0
  238. package/dist/server/overlay.d.ts +3 -0
  239. package/dist/server/previewServer.d.ts +4 -0
  240. package/dist/server/proxy.d.ts +7 -0
  241. package/dist/server/publicPathnames.d.ts +2 -0
  242. package/dist/server/runner/asModule.d.ts +2 -0
  243. package/dist/server/runner/basic.d.ts +25 -0
  244. package/dist/server/runner/cjs.d.ts +10 -0
  245. package/dist/server/runner/esm.d.ts +6 -0
  246. package/dist/server/runner/index.d.ts +6 -0
  247. package/dist/server/runner/type.d.ts +42 -0
  248. package/dist/server/serverSetup.d.ts +2 -0
  249. package/dist/server/socketServer.d.ts +113 -0
  250. package/dist/server/watchFiles.d.ts +15 -0
  251. package/dist/sirv.js +122 -0
  252. package/dist/tinyglobby.js +1 -0
  253. package/dist/trace-mapping.js +548 -0
  254. package/dist/transformLoader.mjs +36 -0
  255. package/dist/transformRawLoader.mjs +4 -0
  256. package/dist/types/config.d.ts +1796 -0
  257. package/dist/types/context.d.ts +89 -0
  258. package/dist/types/hooks.d.ts +261 -0
  259. package/dist/types/index.d.ts +8 -0
  260. package/dist/types/plugin.d.ts +479 -0
  261. package/dist/types/rsbuild.d.ts +241 -0
  262. package/dist/types/rspack.d.ts +10 -0
  263. package/dist/types/thirdParty.d.ts +161 -0
  264. package/dist/types/utils.d.ts +16 -0
  265. package/dist/workerLoader.mjs +94 -0
  266. package/dist/ws.js +2 -0
  267. package/package.json +107 -0
  268. package/static/openChrome.applescript +95 -0
  269. package/types.d.ts +422 -0
@@ -0,0 +1,89 @@
1
+ import type { Hooks } from '../hooks.js';
2
+ import type { RestartManager } from '../helpers/restartManager.js';
3
+ import type { Logger } from '../logger.js';
4
+ import type { SocketServer } from '../server/socketServer.js';
5
+ import type { NormalizedConfig, RsbuildConfig } from './config.js';
6
+ import type { EnvironmentContext } from './hooks.js';
7
+ import type { RsbuildPluginAPI } from './plugin.js';
8
+ import type { RsbuildStats } from './rsbuild.js';
9
+ export type BundlerType = 'rspack';
10
+ export type ActionType = 'dev' | 'build' | 'preview';
11
+ /** The public context */ export type RsbuildContext = {
12
+ /** The Rsbuild core version. */ version: string;
13
+ /** The root path of current project. */ rootPath: string;
14
+ /** Absolute path to the loaded configuration file. */ configFile?: string;
15
+ /** Absolute paths of files imported by the configuration file. */ configFileDependencies: readonly string[];
16
+ /** Absolute path of output files. */ distPath: string;
17
+ /** Absolute path of cache files. */ cachePath: string;
18
+ /**
19
+ * Dev server information when running in dev mode.
20
+ * Available after the dev server has been created.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createRsbuild } from '@rsbuild/core';
25
+ *
26
+ * async function main() {
27
+ * const rsbuild = await createRsbuild({
28
+ * // ...
29
+ * });
30
+ * await rsbuild.startDevServer();
31
+ * console.log(rsbuild.context.devServer);
32
+ * // { hostname: 'localhost', port: 3000, https: false }
33
+ * }
34
+ * ```
35
+ */ devServer?: {
36
+ /** The hostname the server is running on. */ hostname: string;
37
+ /** The actual port number the server is listening on. */ port: number;
38
+ /** Whether the server is using HTTPS protocol. */ https: boolean;
39
+ };
40
+ /**
41
+ * The current action type.
42
+ * - dev: will be set when running `rsbuild dev` or `rsbuild.startDevServer()`
43
+ * - build: will be set when running `rsbuild build` or `rsbuild.build()`
44
+ * - preview: will be set when running `rsbuild preview` or `rsbuild.preview()`
45
+ */ action?: ActionType;
46
+ /**
47
+ * The bundler type, currently only `rspack` is supported.
48
+ * @deprecated Do not use this field, it will be removed in future versions.
49
+ */ bundlerType: BundlerType;
50
+ /**
51
+ * The name of the framework or tool that is currently invoking Rsbuild,
52
+ * same as the `callerName` option in the `createRsbuild` method.
53
+ * @example
54
+ * - `rslib` is set when Rslib calls Rsbuild.
55
+ * - `rspress` is set when Rspress calls Rsbuild.
56
+ */ callerName: string;
57
+ };
58
+ export type BuildStatus = /** No build is running yet, or the previous result has been invalidated. */ 'idle' | 'building' | 'done' | 'failed';
59
+ export type BuildState = {
60
+ /**
61
+ * The stats object of the last build.
62
+ * Available after the build has been done.
63
+ */ stats: RsbuildStats | null;
64
+ /** Current build status */ status: BuildStatus;
65
+ /** Whether there are build errors */ hasErrors: boolean;
66
+ /** The build time of each environment */ time: Record<string, number>;
67
+ };
68
+ /** The inner context. */ export type InternalContext = RsbuildContext & {
69
+ /** The logger associated with current Rsbuild instance. */ logger: Logger;
70
+ /** All hooks. */ hooks: Readonly<Hooks>;
71
+ /** Manage callbacks for restarting the current Rsbuild instance. */ restartManager: RestartManager;
72
+ /** Current Rsbuild config. */ config: Readonly<RsbuildConfig>;
73
+ /** The original Rsbuild config passed from the createRsbuild method. */ originalConfig: Readonly<RsbuildConfig>;
74
+ /** The normalized Rsbuild config. */ normalizedConfig?: NormalizedConfig;
75
+ /**
76
+ * Get the plugin API.
77
+ * When environment is undefined, the global plugin API is returned, which
78
+ * can be used in all environments.
79
+ */ getPluginAPI?: (environment?: string) => RsbuildPluginAPI;
80
+ /** Context information for all environments. */ environments: Record<string, EnvironmentContext>;
81
+ /** Array of all environments. */ environmentList: EnvironmentContext[];
82
+ /** Only build specified environment. */ specifiedEnvironments?: string[];
83
+ /** Build state information */ buildState: BuildState;
84
+ /** The socket server instance. */ socketServer?: SocketServer;
85
+ /**
86
+ * Pathnames derived from public paths, stripped of `server.base`.
87
+ * Used for static asset serving.
88
+ */ publicPathnames: string[];
89
+ };
@@ -0,0 +1,261 @@
1
+ import type { rspack } from '@rspack/core';
2
+ import type { ChainIdentifier, ManifestData } from '../index.js';
3
+ import type { RsbuildDevServer } from '../server/devServer.js';
4
+ import type { RsbuildPreviewServer } from '../server/previewServer.js';
5
+ import type { RspackChain } from '../types/index.js';
6
+ import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config.js';
7
+ import type { BuildOptions, RsbuildEntry, RsbuildTarget, StartDevServerOptions } from './rsbuild.js';
8
+ import type { Rspack } from './rspack.js';
9
+ import type { HtmlRspackPlugin } from './thirdParty.js';
10
+ import type { MaybePromise } from './utils.js';
11
+ type CompileCommonParams = {
12
+ isFirstCompile: boolean;
13
+ isWatch: boolean;
14
+ };
15
+ export type OnBeforeEnvironmentCompileFn = (params: CompileCommonParams & {
16
+ environment: EnvironmentContext;
17
+ bundlerConfig?: Rspack.Configuration;
18
+ }) => MaybePromise<void>;
19
+ export type OnCloseBuildFn = () => MaybePromise<void>;
20
+ export type OnBeforeBuildFn = (params: CompileCommonParams & {
21
+ /**
22
+ * Context information for all environments.
23
+ */ environments: Record<string, EnvironmentContext>;
24
+ bundlerConfigs?: Rspack.Configuration[];
25
+ }) => MaybePromise<void>;
26
+ export type OnBeforeDevCompileFn = (params: CompileCommonParams & {
27
+ /**
28
+ * Context information for all environments.
29
+ */ environments: Record<string, EnvironmentContext>;
30
+ bundlerConfigs?: Rspack.Configuration[];
31
+ }) => MaybePromise<void>;
32
+ export type OnAfterEnvironmentCompileFn = (params: CompileCommonParams & {
33
+ stats?: Rspack.Stats;
34
+ /**
35
+ * The time it takes to build the current environment in milliseconds.
36
+ */ time: number;
37
+ environment: EnvironmentContext;
38
+ }) => MaybePromise<void>;
39
+ export type OnAfterBuildFn = (params: CompileCommonParams & {
40
+ stats?: Rspack.Stats | Rspack.MultiStats;
41
+ /**
42
+ * Context information for all environments.
43
+ */ environments: Record<string, EnvironmentContext>;
44
+ }) => MaybePromise<void>;
45
+ export type OnCloseDevServerFn = () => MaybePromise<void>;
46
+ export type OnAfterDevCompileFn = (params: {
47
+ isFirstCompile: boolean;
48
+ stats: Rspack.Stats | Rspack.MultiStats;
49
+ /**
50
+ * Context information for all environments.
51
+ */ environments: Record<string, EnvironmentContext>;
52
+ }) => MaybePromise<void>;
53
+ /**
54
+ * @deprecated Use `OnAfterDevCompileFn` instead.
55
+ */ export type OnDevCompileDoneFn = OnAfterDevCompileFn;
56
+ export type OnBeforeStartDevServerFn = (params: {
57
+ /**
58
+ * The dev server instance, the same as the return value of `createDevServer`.
59
+ */ server: RsbuildDevServer;
60
+ /**
61
+ * Context information for all environments.
62
+ */ environments: Record<string, EnvironmentContext>;
63
+ }) => MaybePromise<(() => MaybePromise<void>) | void>;
64
+ export type OnBeforeStartPreviewServerFn = (params: {
65
+ /**
66
+ * The preview server instance.
67
+ */ server: RsbuildPreviewServer;
68
+ /**
69
+ * Context information for all environments.
70
+ */ environments: Record<string, EnvironmentContext>;
71
+ }) => MaybePromise<void>;
72
+ export type Routes = {
73
+ entryName: string;
74
+ pathname: string;
75
+ }[];
76
+ export type ReadonlyRoutes = ReadonlyArray<Readonly<Routes[number]>>;
77
+ export type OnAfterStartDevServerFn = (params: {
78
+ port: number;
79
+ routes: ReadonlyRoutes;
80
+ /**
81
+ * Context information for all environments.
82
+ */ environments: Record<string, EnvironmentContext>;
83
+ }) => MaybePromise<void>;
84
+ export type OnAfterStartPreviewServerFn = (params: {
85
+ port: number;
86
+ routes: ReadonlyRoutes;
87
+ /**
88
+ * Context information for all environments.
89
+ */ environments: Record<string, EnvironmentContext>;
90
+ }) => MaybePromise<void>;
91
+ export type OnBeforeCreateCompilerFn = (params: {
92
+ bundlerConfigs: Rspack.Configuration[];
93
+ /**
94
+ * Context information for all environments.
95
+ */ environments: Record<string, EnvironmentContext>;
96
+ }) => MaybePromise<void>;
97
+ export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCompiler> = (params: {
98
+ compiler: Compiler;
99
+ /**
100
+ * Context information for all environments.
101
+ */ environments: Record<string, EnvironmentContext>;
102
+ }) => MaybePromise<void>;
103
+ export type OnExitFn = (context: {
104
+ exitCode: number;
105
+ }) => void;
106
+ export type WatchFileEvent = 'add' | 'change' | 'unlink';
107
+ export type RestartContext = {
108
+ /**
109
+ * The absolute path of the file that triggered the restart.
110
+ * It is undefined when the restart is manually triggered.
111
+ */ filePath?: string;
112
+ /**
113
+ * The file event that triggered the restart.
114
+ * It is undefined when the restart is manually triggered.
115
+ */ event?: WatchFileEvent;
116
+ } & ({
117
+ /**
118
+ * The current Rsbuild action being restarted.
119
+ */ action: 'build';
120
+ /**
121
+ * The options passed to `rsbuild.build()`.
122
+ */ options: BuildOptions;
123
+ } | {
124
+ /**
125
+ * The current Rsbuild action being restarted.
126
+ */ action: 'dev';
127
+ /**
128
+ * The options passed to `rsbuild.startDevServer()`.
129
+ */ options: StartDevServerOptions;
130
+ });
131
+ /** Restart the current Rsbuild task and return whether the restart succeeded. */ export type RestartFn = (context: RestartContext) => MaybePromise<boolean>;
132
+ export type OnRestartFn = (context: RestartContext) => MaybePromise<void>;
133
+ export type ModifyHTMLContext = {
134
+ /**
135
+ * The Compilation object of Rspack.
136
+ */ compilation: Rspack.Compilation;
137
+ /**
138
+ * The Compiler object of Rspack.
139
+ */ compiler: Rspack.Compiler;
140
+ /**
141
+ * The name of the HTML file, relative to the dist directory.
142
+ * @example 'index.html'
143
+ */ filename: string;
144
+ /**
145
+ * The environment context for current build.
146
+ */ environment: EnvironmentContext;
147
+ };
148
+ export type ModifyHTMLFn = (html: string, context: ModifyHTMLContext) => MaybePromise<string>;
149
+ type HTMLTags = {
150
+ headTags: HtmlBasicTag[];
151
+ bodyTags: HtmlBasicTag[];
152
+ };
153
+ export type ModifyHTMLTagsContext = Pick<ModifyHTMLContext, 'compilation' | 'compiler' | 'filename' | 'environment'> & {
154
+ /**
155
+ * URL prefix of assets.
156
+ * @example 'https://example.com/'
157
+ */ assetPrefix: string;
158
+ };
159
+ export type ModifyHTMLTagsFn = (tags: HTMLTags, context: ModifyHTMLTagsContext) => MaybePromise<HTMLTags>;
160
+ export type ModifyRsbuildConfigUtils = {
161
+ /** Merge multiple Rsbuild config objects into one. */ mergeRsbuildConfig: (...configs: RsbuildConfig[]) => RsbuildConfig;
162
+ };
163
+ type ArrayAtLeastOne<A, B> = [A, ...(A | B)[]] | [...(A | B)[], A];
164
+ export type ModifyEnvironmentConfigUtils = {
165
+ /** environment name. */ name: string;
166
+ /** Merge multiple Rsbuild environment config objects into one. */ mergeEnvironmentConfig: (...configs: ArrayAtLeastOne<MergedEnvironmentConfig, EnvironmentConfig>) => MergedEnvironmentConfig;
167
+ };
168
+ export type ModifyRsbuildConfigFn = (config: RsbuildConfig, utils: ModifyRsbuildConfigUtils) => MaybePromise<RsbuildConfig | void>;
169
+ export type ModifyEnvironmentConfigFn = (config: MergedEnvironmentConfig, utils: ModifyEnvironmentConfigUtils) => MaybePromise<MergedEnvironmentConfig | void>;
170
+ export type EnvironmentContext = {
171
+ /**
172
+ * The index of the current environment.
173
+ */ index: number;
174
+ /**
175
+ * The unique name of the current environment is used to distinguish and locate the
176
+ * environment, corresponds to the key in the `environments` configuration.
177
+ */ name: string;
178
+ /**
179
+ * The entry object from the `source.entry` option.
180
+ */ entry: RsbuildEntry;
181
+ /**
182
+ * The path information for all HTML assets.
183
+ * This value is an object, the key is the entry name and the value is the relative
184
+ * path of the HTML file in the dist directory.
185
+ */ htmlPaths: Record<string, string>;
186
+ /**
187
+ * The absolute path of the output directory, corresponding to the `output.distPath.root`
188
+ * config of Rsbuild.
189
+ */ distPath: string;
190
+ /**
191
+ * The browserslist configuration of the current environment.
192
+ */ browserslist: string[];
193
+ /**
194
+ * The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file
195
+ * does not exist in current project.
196
+ */ tsconfigPath?: string;
197
+ /**
198
+ * The normalized Rsbuild config for the current environment.
199
+ */ config: NormalizedEnvironmentConfig;
200
+ /**
201
+ * Manifest data. Only available when:
202
+ * - The `output.manifest` config is enabled
203
+ * - The build has completed, accessible in hooks like `onAfterBuild`,
204
+ * `onAfterDevCompile` and `onAfterEnvironmentCompile` or via the environment API
205
+ */ manifest?: Record<string, unknown> | ManifestData;
206
+ /**
207
+ * WebSocket authentication token, used to authenticate WebSocket connections and
208
+ * prevent unauthorized access. It contains a token when running the `dev` action
209
+ * and is an empty string for other actions.
210
+ */ webSocketToken: string;
211
+ };
212
+ export type ModifyChainUtils = {
213
+ /**
214
+ * The value of `process.env.NODE_ENV`
215
+ */ env: string;
216
+ /**
217
+ * A boolean value indicating whether this is a development build.
218
+ * Set to `true` when the `mode` is `development`.
219
+ */ isDev: boolean;
220
+ /**
221
+ * A boolean value indicating whether this is a production build.
222
+ * Set to `true` when the `mode` is `production`.
223
+ */ isProd: boolean;
224
+ /**
225
+ * The current build target.
226
+ */ target: RsbuildTarget;
227
+ /**
228
+ * A boolean value indicating whether the build target is `node`.
229
+ * Equivalent to `target === 'node'`.
230
+ */ isServer: boolean;
231
+ /**
232
+ * A boolean value indicating whether the build target is `web-worker`.
233
+ * Equivalent to `target === 'web-worker'`.
234
+ */ isWebWorker: boolean;
235
+ /**
236
+ * Predefined chain IDs.
237
+ */ CHAIN_ID: ChainIdentifier;
238
+ /**
239
+ * The environment context for current build.
240
+ */ environment: EnvironmentContext;
241
+ /**
242
+ * Context information for all environments.
243
+ */ environments: Record<string, EnvironmentContext>;
244
+ /**
245
+ * The Rspack instance, same as `import { rspack } from '@rsbuild/core'`.
246
+ */ rspack: typeof rspack;
247
+ /**
248
+ * The default export of `html-rspack-plugin`.
249
+ */ HtmlPlugin: typeof HtmlRspackPlugin;
250
+ };
251
+ export type ModifyBundlerChainUtils = ModifyChainUtils & {
252
+ /**
253
+ * @deprecated Use `rspack` instead.
254
+ */ bundler: typeof rspack;
255
+ };
256
+ export type ModifyBundlerChainFn = (chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>;
257
+ export type CreateAsyncHook<Callback extends (...args: any[]) => any> = {
258
+ tap: (cb: Callback) => void;
259
+ call: (...args: Parameters<Callback>) => Promise<Parameters<Callback>>;
260
+ };
261
+ export { };
@@ -0,0 +1,8 @@
1
+ export type * from './config.js';
2
+ export type * from './context.js';
3
+ export type * from './hooks.js';
4
+ export type * from './plugin.js';
5
+ export type * from './rsbuild.js';
6
+ export type * from './rspack.js';
7
+ export type * from './thirdParty.js';
8
+ export type * from './utils.js';