@ohos-ports/rsbuild-core 1.7.2-beta.1

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 (279) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/bin/rsbuild.js +20 -0
  4. package/compiled/@jridgewell/remapping/index.d.ts +1 -0
  5. package/compiled/@jridgewell/remapping/index.js +1222 -0
  6. package/compiled/@jridgewell/remapping/license +19 -0
  7. package/compiled/@jridgewell/remapping/package.json +1 -0
  8. package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
  9. package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
  10. package/compiled/@jridgewell/trace-mapping/license +19 -0
  11. package/compiled/@jridgewell/trace-mapping/package.json +1 -0
  12. package/compiled/chokidar/index.d.ts +384 -0
  13. package/compiled/chokidar/index.js +1793 -0
  14. package/compiled/chokidar/license +21 -0
  15. package/compiled/chokidar/package.json +1 -0
  16. package/compiled/connect/index.d.ts +90 -0
  17. package/compiled/connect/index.js +1240 -0
  18. package/compiled/connect/license +25 -0
  19. package/compiled/connect/package.json +1 -0
  20. package/compiled/cors/index.d.ts +56 -0
  21. package/compiled/cors/index.js +371 -0
  22. package/compiled/cors/license +22 -0
  23. package/compiled/cors/package.json +1 -0
  24. package/compiled/css-loader/api.js +85 -0
  25. package/compiled/css-loader/getUrl.js +26 -0
  26. package/compiled/css-loader/index.d.ts +1 -0
  27. package/compiled/css-loader/index.js +2 -0
  28. package/compiled/css-loader/license +20 -0
  29. package/compiled/css-loader/noSourceMaps.js +5 -0
  30. package/compiled/css-loader/package.json +1 -0
  31. package/compiled/css-loader/sourceMaps.js +16 -0
  32. package/compiled/html-rspack-plugin/default_index.ejs +9 -0
  33. package/compiled/html-rspack-plugin/index.d.ts +290 -0
  34. package/compiled/html-rspack-plugin/index.js +1602 -0
  35. package/compiled/html-rspack-plugin/license +20 -0
  36. package/compiled/html-rspack-plugin/loader.js +166 -0
  37. package/compiled/html-rspack-plugin/package.json +1 -0
  38. package/compiled/http-proxy-middleware/index.d.ts +319 -0
  39. package/compiled/http-proxy-middleware/index.js +5284 -0
  40. package/compiled/http-proxy-middleware/license +22 -0
  41. package/compiled/http-proxy-middleware/package.json +1 -0
  42. package/compiled/launch-editor-middleware/index.d.ts +1 -0
  43. package/compiled/launch-editor-middleware/index.js +719 -0
  44. package/compiled/launch-editor-middleware/license +21 -0
  45. package/compiled/launch-editor-middleware/package.json +1 -0
  46. package/compiled/memfs/index.d.ts +1462 -0
  47. package/compiled/memfs/index.js +1 -0
  48. package/compiled/memfs/license +201 -0
  49. package/compiled/memfs/package.json +1 -0
  50. package/compiled/mrmime/index.d.ts +4 -0
  51. package/compiled/mrmime/index.js +456 -0
  52. package/compiled/mrmime/package.json +1 -0
  53. package/compiled/picocolors/index.d.ts +55 -0
  54. package/compiled/picocolors/index.js +108 -0
  55. package/compiled/picocolors/license +15 -0
  56. package/compiled/picocolors/package.json +1 -0
  57. package/compiled/postcss/index.js +1 -0
  58. package/compiled/postcss/lib/at-rule.d.ts +140 -0
  59. package/compiled/postcss/lib/comment.d.ts +68 -0
  60. package/compiled/postcss/lib/container.d.ts +483 -0
  61. package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
  62. package/compiled/postcss/lib/declaration.d.ts +151 -0
  63. package/compiled/postcss/lib/document.d.ts +69 -0
  64. package/compiled/postcss/lib/fromJSON.d.ts +9 -0
  65. package/compiled/postcss/lib/input.d.ts +227 -0
  66. package/compiled/postcss/lib/lazy-result.d.ts +190 -0
  67. package/compiled/postcss/lib/list.d.ts +60 -0
  68. package/compiled/postcss/lib/no-work-result.d.ts +46 -0
  69. package/compiled/postcss/lib/node.d.ts +556 -0
  70. package/compiled/postcss/lib/parse.d.ts +9 -0
  71. package/compiled/postcss/lib/postcss.d.ts +458 -0
  72. package/compiled/postcss/lib/previous-map.d.ts +81 -0
  73. package/compiled/postcss/lib/processor.d.ts +115 -0
  74. package/compiled/postcss/lib/result.d.ts +205 -0
  75. package/compiled/postcss/lib/root.d.ts +87 -0
  76. package/compiled/postcss/lib/rule.d.ts +126 -0
  77. package/compiled/postcss/lib/source-map-js.d.ts +4 -0
  78. package/compiled/postcss/lib/stringifier.d.ts +46 -0
  79. package/compiled/postcss/lib/stringify.d.ts +9 -0
  80. package/compiled/postcss/lib/warning.d.ts +147 -0
  81. package/compiled/postcss/license +20 -0
  82. package/compiled/postcss/package.json +1 -0
  83. package/compiled/postcss-loader/index.d.ts +1 -0
  84. package/compiled/postcss-loader/index.js +720 -0
  85. package/compiled/postcss-loader/license +20 -0
  86. package/compiled/postcss-loader/package.json +1 -0
  87. package/compiled/rslog/index.d.ts +67 -0
  88. package/compiled/rslog/license +21 -0
  89. package/compiled/rslog/package.json +1 -0
  90. package/compiled/rspack-chain/license +22 -0
  91. package/compiled/rspack-chain/package.json +1 -0
  92. package/compiled/rspack-chain/types/index.d.ts +545 -0
  93. package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
  94. package/compiled/rspack-manifest-plugin/index.js +409 -0
  95. package/compiled/rspack-manifest-plugin/license +21 -0
  96. package/compiled/rspack-manifest-plugin/package.json +1 -0
  97. package/compiled/sirv/index.d.ts +1 -0
  98. package/compiled/sirv/index.js +274 -0
  99. package/compiled/sirv/package.json +1 -0
  100. package/compiled/style-loader/index.d.ts +1 -0
  101. package/compiled/style-loader/index.js +427 -0
  102. package/compiled/style-loader/license +20 -0
  103. package/compiled/style-loader/package.json +1 -0
  104. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  105. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  106. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  107. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  108. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  109. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  110. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  111. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  112. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  113. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  114. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  115. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  116. package/compiled/tinyglobby/index.d.ts +46 -0
  117. package/compiled/tinyglobby/index.js +2664 -0
  118. package/compiled/tinyglobby/license +21 -0
  119. package/compiled/tinyglobby/package.json +1 -0
  120. package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
  121. package/compiled/webpack-bundle-analyzer/index.js +23 -0
  122. package/compiled/webpack-bundle-analyzer/license +20 -0
  123. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  124. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  125. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  126. package/compiled/webpack-merge/index.d.ts +31 -0
  127. package/compiled/webpack-merge/index.js +1200 -0
  128. package/compiled/webpack-merge/license +20 -0
  129. package/compiled/webpack-merge/package.json +1 -0
  130. package/compiled/ws/index.d.ts +437 -0
  131. package/compiled/ws/index.js +3161 -0
  132. package/compiled/ws/license +20 -0
  133. package/compiled/ws/package.json +1 -0
  134. package/dist/0~open.js +427 -0
  135. package/dist/0~range-parser.js +49 -0
  136. package/dist/0~range-parser.js.LICENSE.txt +6 -0
  137. package/dist/131.js +9305 -0
  138. package/dist/131.js.LICENSE.txt +26 -0
  139. package/dist/136.mjs +42 -0
  140. package/dist/2~open.cjs +436 -0
  141. package/dist/2~range-parser.cjs +52 -0
  142. package/dist/2~range-parser.cjs.LICENSE.txt +6 -0
  143. package/dist/client/59.js +22 -0
  144. package/dist/client/hmr.js +206 -0
  145. package/dist/client/overlay.js +203 -0
  146. package/dist/ignoreCssLoader.mjs +3 -0
  147. package/dist/index.cjs +9456 -0
  148. package/dist/index.cjs.LICENSE.txt +26 -0
  149. package/dist/index.js +1 -0
  150. package/dist/rslib-runtime.js +44 -0
  151. package/dist/transformLoader.mjs +1 -0
  152. package/dist/transformRawLoader.mjs +4 -0
  153. package/dist-types/cli/commands.d.ts +28 -0
  154. package/dist-types/cli/index.d.ts +1 -0
  155. package/dist-types/cli/init.d.ts +7 -0
  156. package/dist-types/client/hmr.d.ts +3 -0
  157. package/dist-types/client/log.d.ts +13 -0
  158. package/dist-types/client/overlay.d.ts +1 -0
  159. package/dist-types/configChain.d.ts +154 -0
  160. package/dist-types/constants.d.ts +52 -0
  161. package/dist-types/createContext.d.ts +11 -0
  162. package/dist-types/createRsbuild.d.ts +5 -0
  163. package/dist-types/defaultConfig.d.ts +25 -0
  164. package/dist-types/helpers/compiler.d.ts +5 -0
  165. package/dist-types/helpers/exitHook.d.ts +3 -0
  166. package/dist-types/helpers/format.d.ts +2 -0
  167. package/dist-types/helpers/fs.d.ts +17 -0
  168. package/dist-types/helpers/index.d.ts +29 -0
  169. package/dist-types/helpers/path.d.ts +26 -0
  170. package/dist-types/helpers/stats.d.ts +18 -0
  171. package/dist-types/helpers/url.d.ts +11 -0
  172. package/dist-types/helpers/vendors.d.ts +29 -0
  173. package/dist-types/helpers/version.d.ts +7 -0
  174. package/dist-types/hooks.d.ts +44 -0
  175. package/dist-types/index.d.ts +22 -0
  176. package/dist-types/initPlugins.d.ts +6 -0
  177. package/dist-types/inspectConfig.d.ts +35 -0
  178. package/dist-types/loadConfig.d.ts +60 -0
  179. package/dist-types/loadEnv.d.ts +63 -0
  180. package/dist-types/loader/ignoreCssLoader.d.ts +3 -0
  181. package/dist-types/loader/transformLoader.d.ts +8 -0
  182. package/dist-types/loader/transformRawLoader.d.ts +3 -0
  183. package/dist-types/logger.d.ts +19 -0
  184. package/dist-types/mergeConfig.d.ts +2 -0
  185. package/dist-types/package.json +1 -0
  186. package/dist-types/pluginHelper.d.ts +12 -0
  187. package/dist-types/pluginManager.d.ts +21 -0
  188. package/dist-types/plugins/appIcon.d.ts +2 -0
  189. package/dist-types/plugins/asset.d.ts +3 -0
  190. package/dist-types/plugins/basic.d.ts +5 -0
  191. package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
  192. package/dist-types/plugins/cache.d.ts +2 -0
  193. package/dist-types/plugins/cleanOutput.d.ts +2 -0
  194. package/dist-types/plugins/css.d.ts +4 -0
  195. package/dist-types/plugins/define.d.ts +2 -0
  196. package/dist-types/plugins/entry.d.ts +2 -0
  197. package/dist-types/plugins/esm.d.ts +2 -0
  198. package/dist-types/plugins/externals.d.ts +2 -0
  199. package/dist-types/plugins/fileSize.d.ts +6 -0
  200. package/dist-types/plugins/html.d.ts +9 -0
  201. package/dist-types/plugins/inlineChunk.d.ts +6 -0
  202. package/dist-types/plugins/lazyCompilation.d.ts +2 -0
  203. package/dist-types/plugins/manifest.d.ts +2 -0
  204. package/dist-types/plugins/minimize.d.ts +10 -0
  205. package/dist-types/plugins/moduleFederation.d.ts +2 -0
  206. package/dist-types/plugins/moment.d.ts +2 -0
  207. package/dist-types/plugins/nodeAddons.d.ts +2 -0
  208. package/dist-types/plugins/nonce.d.ts +2 -0
  209. package/dist-types/plugins/output.d.ts +2 -0
  210. package/dist-types/plugins/performance.d.ts +5 -0
  211. package/dist-types/plugins/progress.d.ts +2 -0
  212. package/dist-types/plugins/resolve.d.ts +2 -0
  213. package/dist-types/plugins/resourceHints.d.ts +2 -0
  214. package/dist-types/plugins/rsdoctor.d.ts +2 -0
  215. package/dist-types/plugins/rspackProfile.d.ts +2 -0
  216. package/dist-types/plugins/server.d.ts +2 -0
  217. package/dist-types/plugins/sourceMap.d.ts +2 -0
  218. package/dist-types/plugins/splitChunks.d.ts +4 -0
  219. package/dist-types/plugins/sri.d.ts +2 -0
  220. package/dist-types/plugins/swc.d.ts +5 -0
  221. package/dist-types/plugins/target.d.ts +2 -0
  222. package/dist-types/plugins/wasm.d.ts +2 -0
  223. package/dist-types/provider/build.d.ts +4 -0
  224. package/dist-types/provider/createCompiler.d.ts +6 -0
  225. package/dist-types/provider/helpers.d.ts +12 -0
  226. package/dist-types/provider/initConfigs.d.ts +19 -0
  227. package/dist-types/provider/provider.d.ts +2 -0
  228. package/dist-types/provider/rspackConfig.d.ts +8 -0
  229. package/dist-types/restart.d.ts +18 -0
  230. package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +38 -0
  231. package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +32 -0
  232. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +28 -0
  233. package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +23 -0
  234. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +22 -0
  235. package/dist-types/rspack.d.ts +2 -0
  236. package/dist-types/server/ansiHTML.d.ts +4 -0
  237. package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +12 -0
  238. package/dist-types/server/assets-middleware/index.d.ts +37 -0
  239. package/dist-types/server/assets-middleware/middleware.d.ts +2 -0
  240. package/dist-types/server/assets-middleware/parseTokenList.d.ts +1 -0
  241. package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
  242. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
  243. package/dist-types/server/browserLogs.d.ts +9 -0
  244. package/dist-types/server/buildManager.d.ts +33 -0
  245. package/dist-types/server/cliShortcuts.d.ts +10 -0
  246. package/dist-types/server/devMiddlewares.d.ts +21 -0
  247. package/dist-types/server/devServer.d.ts +79 -0
  248. package/dist-types/server/environment.d.ts +8 -0
  249. package/dist-types/server/gracefulShutdown.d.ts +10 -0
  250. package/dist-types/server/gzipMiddleware.d.ts +2 -0
  251. package/dist-types/server/helper.d.ts +91 -0
  252. package/dist-types/server/historyApiFallback.d.ts +2 -0
  253. package/dist-types/server/hmrFallback.d.ts +1 -0
  254. package/dist-types/server/httpServer.d.ts +7 -0
  255. package/dist-types/server/middlewares.d.ts +33 -0
  256. package/dist-types/server/open.d.ts +10 -0
  257. package/dist-types/server/overlay.d.ts +3 -0
  258. package/dist-types/server/prodServer.d.ts +24 -0
  259. package/dist-types/server/proxy.d.ts +6 -0
  260. package/dist-types/server/runner/asModule.d.ts +2 -0
  261. package/dist-types/server/runner/basic.d.ts +29 -0
  262. package/dist-types/server/runner/cjs.d.ts +10 -0
  263. package/dist-types/server/runner/esm.d.ts +6 -0
  264. package/dist-types/server/runner/index.d.ts +4 -0
  265. package/dist-types/server/runner/type.d.ts +42 -0
  266. package/dist-types/server/socketServer.d.ts +81 -0
  267. package/dist-types/server/watchFiles.d.ts +14 -0
  268. package/dist-types/types/config.d.ts +1882 -0
  269. package/dist-types/types/context.d.ts +110 -0
  270. package/dist-types/types/hooks.d.ts +275 -0
  271. package/dist-types/types/index.d.ts +8 -0
  272. package/dist-types/types/plugin.d.ts +585 -0
  273. package/dist-types/types/rsbuild.d.ts +286 -0
  274. package/dist-types/types/rspack.d.ts +16 -0
  275. package/dist-types/types/thirdParty.d.ts +186 -0
  276. package/dist-types/types/utils.d.ts +19 -0
  277. package/package.json +114 -0
  278. package/static/openChrome.applescript +95 -0
  279. package/types.d.ts +349 -0
@@ -0,0 +1,286 @@
1
+ import type { Compiler, MultiCompiler } from '@rspack/core';
2
+ import type { LoadEnvOptions } from '../loadEnv';
3
+ import type * as providerHelpers from '../provider/helpers';
4
+ import type { RsbuildDevServer } from '../server/devServer';
5
+ import type { StartServerResult } from '../server/helper';
6
+ import type { NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
7
+ import type { InternalContext, RsbuildContext } from './context';
8
+ import type { PluginManager, RsbuildPlugin, RsbuildPluginAPI } from './plugin';
9
+ import type { Rspack } from './rspack';
10
+ import type { WebpackConfig } from './thirdParty';
11
+ import type { Falsy } from './utils';
12
+ export type Bundler = 'rspack' | 'webpack';
13
+ export type StartDevServerOptions = {
14
+ /**
15
+ * Using a custom Rspack Compiler object.
16
+ * @deprecated This is no longer supported and will be removed in a future version.
17
+ */
18
+ compiler?: Compiler | MultiCompiler;
19
+ /**
20
+ * Whether to get port silently and not print any logs.
21
+ * @default false
22
+ */
23
+ getPortSilently?: boolean;
24
+ };
25
+ export type CreateDevServerOptions = StartDevServerOptions & {
26
+ /**
27
+ * Whether to trigger Rsbuild compilation
28
+ * @default true
29
+ */
30
+ runCompile?: boolean;
31
+ };
32
+ export type PreviewOptions = {
33
+ /**
34
+ * Whether to get port silently and not print any logs.
35
+ * @default false
36
+ */
37
+ getPortSilently?: boolean;
38
+ /**
39
+ * Whether to check if the dist directory exists and is not empty.
40
+ * @default true
41
+ */
42
+ checkDistDir?: boolean;
43
+ };
44
+ export type BuildOptions = {
45
+ /**
46
+ * Whether to watch for file changes and rebuild.
47
+ * @default false
48
+ */
49
+ watch?: boolean;
50
+ /**
51
+ * Using a custom Rspack Compiler object.
52
+ * @deprecated This is no longer supported and will be removed in a future version.
53
+ */
54
+ compiler?: Compiler | MultiCompiler;
55
+ };
56
+ export type Build = (options?: BuildOptions) => Promise<BuildResult>;
57
+ export type BuildResult = {
58
+ /**
59
+ * Close the build and call the `onCloseBuild` hook.
60
+ * In watch mode, this method will stop watching.
61
+ */
62
+ close: () => Promise<void>;
63
+ /**
64
+ * Rspack's [stats](https://rspack.rs/api/javascript-api/stats) object.
65
+ */
66
+ stats?: Rspack.Stats | Rspack.MultiStats;
67
+ };
68
+ export type InitConfigsOptions = Pick<RsbuildContext, 'action'>;
69
+ export type InspectConfigOptions = {
70
+ /**
71
+ * Inspect the config in the specified mode.
72
+ * Available options: 'development' or 'production'.
73
+ * @default 'development'
74
+ */
75
+ mode?: RsbuildMode;
76
+ /**
77
+ * Enables verbose mode to display the complete function
78
+ * content in the configuration.
79
+ * @default false
80
+ */
81
+ verbose?: boolean;
82
+ /**
83
+ * Specify the output path for inspection results.
84
+ * @default 'output.distPath.root'
85
+ */
86
+ outputPath?: string;
87
+ /**
88
+ * Whether to write the inspection results to disk.
89
+ * @default false
90
+ */
91
+ writeToDisk?: boolean;
92
+ /**
93
+ * Extra configurations to be output.
94
+ * - key: The name of the configuration
95
+ * - value: The configuration object
96
+ * @example
97
+ * extraConfigs: {
98
+ * // Output `rstest.config.mjs` file
99
+ * 'rstest': {
100
+ * // ...
101
+ * },
102
+ * }
103
+ */
104
+ extraConfigs?: Record<string, unknown>;
105
+ };
106
+ export type InspectConfigResult<B extends 'rspack' | 'webpack' = 'rspack'> = {
107
+ rsbuildConfig: string;
108
+ bundlerConfigs: string[];
109
+ environmentConfigs: string[];
110
+ origin: {
111
+ rsbuildConfig: Omit<NormalizedConfig, 'environments'>;
112
+ environmentConfigs: Record<string, NormalizedEnvironmentConfig>;
113
+ bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
114
+ };
115
+ };
116
+ export type CreateCompiler = <C = Compiler | MultiCompiler>() => Promise<C>;
117
+ export type CreateRsbuildOptions = {
118
+ /**
119
+ * The root path of current project.
120
+ * @default process.cwd()
121
+ */
122
+ cwd?: string;
123
+ /**
124
+ * The name of the framework or tool that is currently invoking Rsbuild.
125
+ * This allows plugins to tailor their behavior based on the calling context.
126
+ * Rsbuild plugins can access this value via `api.context.callerName`.
127
+ * @default 'rsbuild'
128
+ */
129
+ callerName?: string;
130
+ /**
131
+ * Only build specified environments.
132
+ * For example, passing `['web']` will only build the `web` environment.
133
+ * If not specified or passing an empty array, all environments will be built.
134
+ */
135
+ environment?: string[];
136
+ /**
137
+ * Alias for `config`.
138
+ * This option will be deprecated in the future.
139
+ */
140
+ rsbuildConfig?: RsbuildConfig | (() => Promise<RsbuildConfig>);
141
+ /**
142
+ * Rsbuild configurations.
143
+ * Passing a function to load the config asynchronously with custom logic.
144
+ */
145
+ config?: RsbuildConfig | (() => Promise<RsbuildConfig>);
146
+ /**
147
+ * Whether to call `loadEnv` to load environment variables and define them
148
+ * as global variables via `source.define`.
149
+ * @default false
150
+ */
151
+ loadEnv?: boolean | LoadEnvOptions;
152
+ };
153
+ export type ResolvedCreateRsbuildOptions = Required<Pick<CreateRsbuildOptions, 'cwd' | 'callerName'>> & Pick<CreateRsbuildOptions, 'loadEnv' | 'environment'> & {
154
+ rsbuildConfig: RsbuildConfig;
155
+ };
156
+ export type CreateDevServer = (options?: CreateDevServerOptions) => Promise<RsbuildDevServer>;
157
+ export type StartDevServer = (options?: StartDevServerOptions) => Promise<StartServerResult>;
158
+ export type InspectConfig<B extends 'rspack' | 'webpack' = 'rspack'> = (options?: InspectConfigOptions) => Promise<InspectConfigResult<B>>;
159
+ export type ProviderInstance<B extends 'rspack' | 'webpack' = 'rspack'> = Pick<RsbuildInstance, 'build' | 'createCompiler' | 'createDevServer' | 'startDevServer'> & {
160
+ readonly bundler: Bundler;
161
+ initConfigs: (options?: InitConfigsOptions) => Promise<B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[]>;
162
+ inspectConfig: InspectConfig<B>;
163
+ };
164
+ export type RsbuildProviderHelpers = typeof providerHelpers;
165
+ export type RsbuildProvider<B extends 'rspack' | 'webpack' = 'rspack'> = (options: {
166
+ context: InternalContext;
167
+ pluginManager: PluginManager;
168
+ rsbuildOptions: ResolvedCreateRsbuildOptions;
169
+ helpers: RsbuildProviderHelpers;
170
+ }) => Promise<ProviderInstance<B>> | ProviderInstance<B>;
171
+ export type AddPluginsOptions = {
172
+ /**
173
+ * Insert before the specified plugin.
174
+ */
175
+ before?: string;
176
+ /**
177
+ * Specify the environment that the plugin will be applied to.
178
+ * If not specified, the plugin will be be registered as a global plugin and
179
+ * applied to all environments.
180
+ */
181
+ environment?: string;
182
+ };
183
+ export type AddPlugins = (plugins: (RsbuildPlugin | Falsy)[], options?: AddPluginsOptions) => void;
184
+ export type RsbuildInstance = {
185
+ /**
186
+ * Register one or more Rsbuild plugins, which can be called multiple times.
187
+ * This method needs to be called before compiling. If it is called after
188
+ * compiling, it will not affect the compilation result.
189
+ */
190
+ addPlugins: AddPlugins;
191
+ /**
192
+ * Get all the Rsbuild plugins registered in the current Rsbuild instance.
193
+ */
194
+ getPlugins: (options?: {
195
+ /**
196
+ * Get the plugins in the specified environment.
197
+ * If environment is not specified, get the global plugins.
198
+ */
199
+ environment: string;
200
+ }) => RsbuildPlugin[];
201
+ /**
202
+ * Removes one or more Rsbuild plugins, which can be called multiple times.
203
+ * This method needs to be called before compiling. If it is called after
204
+ * compiling, it will not affect the compilation result.
205
+ */
206
+ removePlugins: (pluginNames: string[], options?: {
207
+ /**
208
+ * Remove the plugin in the specified environment.
209
+ * If environment is not specified, remove it in all environments.
210
+ */
211
+ environment: string;
212
+ }) => void;
213
+ /**
214
+ * Perform a production mode build. This method will generate optimized
215
+ * production bundles and emit them to the output directory.
216
+ */
217
+ build: Build;
218
+ /**
219
+ * Start a server to preview the production build locally.
220
+ * This method should be executed after `rsbuild.build`.
221
+ */
222
+ preview: (options?: PreviewOptions) => Promise<StartServerResult>;
223
+ /**
224
+ * Initialize and return the internal Rspack configurations used by Rsbuild.
225
+ * This method processes all plugins and configurations to generate the final
226
+ * Rspack configs. Note: You typically don't need to call this method directly
227
+ * since it's automatically invoked by methods like `rsbuild.build` and
228
+ * `rsbuild.startDevServer`.
229
+ */
230
+ initConfigs: (options?: InitConfigsOptions) => Promise<Rspack.Configuration[]>;
231
+ /**
232
+ * Inspect and debug Rsbuild's internal configurations. It provides access to:
233
+ * - The resolved Rsbuild configuration
234
+ * - The environment-specific Rsbuild configurations
235
+ * - The generated Rspack configurations
236
+ *
237
+ * The method serializes these configurations to strings and optionally writes
238
+ * them to disk for inspection.
239
+ */
240
+ inspectConfig: (options?: InspectConfigOptions) => Promise<InspectConfigResult>;
241
+ /**
242
+ * Create an Rspack [Compiler](https://rspack.rs/api/javascript-api/compiler)
243
+ * instance. If there are multiple [environments](/config/environments) for
244
+ * this build, the return value is `MultiCompiler`.
245
+ */
246
+ createCompiler: CreateCompiler;
247
+ /**
248
+ * Rsbuild includes a built-in dev server designed to improve the development
249
+ * experience. When you run the `rsbuild dev` command, the server starts
250
+ * automatically and provides features such as page preview, routing, and hot
251
+ * module reloading.
252
+ *
253
+ * If you want to integrate the Rsbuild dev server into a custom server, you
254
+ * can use the `createDevServer` method to create a dev server instance and
255
+ * call its methods as needed.
256
+ *
257
+ * If you want to directly start the Rsbuild dev server, use the
258
+ * `rsbuild.startDevServer` method.
259
+ */
260
+ createDevServer: CreateDevServer;
261
+ /**
262
+ * Start the local dev server. This method will:
263
+ *
264
+ * 1. Start a development server that serves your application.
265
+ * 2. Watch for file changes and trigger recompilation.
266
+ */
267
+ startDevServer: StartDevServer;
268
+ } & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartProdServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartProdServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit'>;
269
+ export type RsbuildTarget = 'web' | 'node' | 'web-worker';
270
+ export type RsbuildEntryDescription = Rspack.EntryDescription & {
271
+ /**
272
+ * Whether to generate an HTML file for the entry.
273
+ *
274
+ * @default true
275
+ */
276
+ html?: boolean;
277
+ };
278
+ export type RsbuildEntry = Record<string, string | string[] | RsbuildEntryDescription>;
279
+ export type RsbuildMode = 'development' | 'production' | 'none';
280
+ export type RsbuildStatsItem = Pick<Rspack.StatsCompilation, 'errors' | 'warnings' | 'entrypoints' | 'hash'>;
281
+ /**
282
+ * A subset of Rspack's StatsCompilation with only the fields we need
283
+ */
284
+ export type RsbuildStats = RsbuildStatsItem & {
285
+ children: RsbuildStatsItem[];
286
+ };
@@ -0,0 +1,16 @@
1
+ import type * as Rspack from '@rspack/core';
2
+ import type RspackChain from '../../compiled/rspack-chain/types';
3
+ import type { TransformHandler } from './plugin';
4
+ export type { Rspack, RspackChain };
5
+ declare module '@rspack/core' {
6
+ interface Compiler {
7
+ __rsbuildTransformer?: Record<string, TransformHandler>;
8
+ }
9
+ }
10
+ export interface BundlerPluginInstance {
11
+ [index: string]: any;
12
+ apply: (compiler: any) => void;
13
+ }
14
+ /** T[] => T */
15
+ type GetElementType<T extends any[]> = T extends (infer U)[] ? U : never;
16
+ export type RspackRule = GetElementType<Rspack.RuleSetRules>;
@@ -0,0 +1,186 @@
1
+ import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
2
+ /** @ts-ignore `webpack` type only exists when `@rsbuild/webpack` is installed */
3
+ import type { Configuration as WebpackConfig } from 'webpack';
4
+ import type Connect from '../../compiled/connect/index.js';
5
+ import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin/index.js';
6
+ import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss';
7
+ import type { Rspack } from './rspack';
8
+ import type { LiteralUnion } from './utils';
9
+ export type { Connect };
10
+ export type { HtmlRspackPlugin };
11
+ export interface CSSExtractOptions {
12
+ pluginOptions?: CssExtractRspackPluginOptions;
13
+ loaderOptions?: CssExtractRspackLoaderOptions;
14
+ }
15
+ export type { WebpackConfig };
16
+ /**
17
+ * A loose PostCSS plugin type that accepts plugins from different
18
+ * PostCSS versions. This helps avoid type conflicts when user
19
+ * projects use different PostCSS versions.
20
+ */
21
+ export type LoosePostCSSPlugin = any;
22
+ export type PostCSSOptions = ProcessOptions & {
23
+ config?: boolean;
24
+ plugins?: LoosePostCSSPlugin[];
25
+ };
26
+ export type PostCSSLoaderOptions = {
27
+ /**
28
+ * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
29
+ * @default undefined
30
+ */
31
+ execute?: boolean;
32
+ /**
33
+ * Whether to generate source maps.
34
+ * @default `rsbuildConfig.output.sourceMap.css`
35
+ */
36
+ sourceMap?: boolean;
37
+ /**
38
+ * The special implementation option determines which implementation of PostCSS to use.
39
+ * @default `@rsbuild/core/compiled/postcss`
40
+ */
41
+ implementation?: unknown;
42
+ /**
43
+ * Allows to set PostCSS options and plugins.
44
+ * @default undefined
45
+ */
46
+ postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
47
+ };
48
+ export type PostCSSPlugin = AcceptedPlugin;
49
+ export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
50
+ export type CSSLoaderExportLocalsConvention = 'asIs' | 'as-is' | 'camelCase' | 'camel-case' | 'camelCaseOnly' | 'camel-case-only' | 'dashes' | 'dashesOnly' | 'dashes-only' | ((name: string) => string);
51
+ export interface CSSLoaderModulesOptions {
52
+ /**
53
+ * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment.
54
+ */
55
+ auto?: boolean | RegExp | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => boolean);
56
+ /**
57
+ * Allow `css-loader` to export names from global class or id, so you can use that as local name.
58
+ */
59
+ exportGlobals?: boolean;
60
+ /**
61
+ * Style of exported class names.
62
+ */
63
+ exportLocalsConvention?: CSSLoaderExportLocalsConvention;
64
+ /**
65
+ * Export only locals.
66
+ */
67
+ exportOnlyLocals?: boolean;
68
+ /**
69
+ * Allows to specify a function to generate the classname.
70
+ */
71
+ getLocalIdent?: (context: Rspack.LoaderContext, localIdentName: string, localName: string) => string;
72
+ /**
73
+ * Allows to configure the generated local ident name.
74
+ */
75
+ localIdentName?: string;
76
+ /**
77
+ * Allows to redefine basic loader context for local ident name.
78
+ */
79
+ localIdentContext?: string;
80
+ /**
81
+ * Allows to add custom hash to generate more unique classes.
82
+ */
83
+ localIdentHashSalt?: string;
84
+ /**
85
+ * Allows to specify hash function to generate classes.
86
+ */
87
+ localIdentHashFunction?: string;
88
+ /**
89
+ * Allows to specify hash digest to generate classes.
90
+ */
91
+ localIdentHashDigest?: string;
92
+ /**
93
+ * Allows to specify custom RegExp for local ident name.
94
+ */
95
+ localIdentRegExp?: string | RegExp;
96
+ /**
97
+ * Controls the level of compilation applied to the input styles.
98
+ */
99
+ mode?: CSSLoaderModulesMode;
100
+ /**
101
+ * Enables/disables ES modules named export for locals.
102
+ */
103
+ namedExport?: boolean;
104
+ /**
105
+ * Enables a callback to output the CSS Modules mapping JSON.
106
+ */
107
+ getJSON?: (context: {
108
+ resourcePath: string;
109
+ imports: object[];
110
+ exports: object[];
111
+ replacements: object[];
112
+ }) => Promise<void> | void;
113
+ }
114
+ export interface CSSLoaderOptions {
115
+ /**
116
+ * Allow to enable/disables handling the CSS functions url and image-set.
117
+ * If set to false, css-loader will not parse any paths specified in url or image-set
118
+ * @default true
119
+ */
120
+ url?: boolean | {
121
+ filter: (url: string, resourcePath: string) => boolean;
122
+ };
123
+ /**
124
+ * Allows to enables/disables @import at-rules handling.
125
+ * @default true
126
+ */
127
+ import?: boolean | {
128
+ filter: (url: string, media: string, resourcePath: string, supports?: string, layer?: string) => boolean;
129
+ };
130
+ /**
131
+ * Allows to enable/disable CSS Modules or ICSS and setup configuration:
132
+ */
133
+ modules?: boolean | LiteralUnion<'local' | 'global' | 'pure' | 'icss', string> | CSSLoaderModulesOptions;
134
+ /**
135
+ * By default generation of source maps depends on the devtool option.
136
+ */
137
+ sourceMap?: boolean;
138
+ /**
139
+ * Allows to enables/disables or setups number of loaders applied before CSS loader for @import at-rules,
140
+ * CSS Modules and ICSS imports, i.e. @import/composes/@value value from './values.css'/etc.
141
+ * @default 0
142
+ */
143
+ importLoaders?: number;
144
+ /**
145
+ * By default, css-loader generates JS modules that use the ES modules syntax.
146
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
147
+ * @default true
148
+ */
149
+ esModule?: boolean;
150
+ /**
151
+ * Allows exporting styles as array with modules, string or constructable stylesheet (i.e. CSSStyleSheet)
152
+ * @default 'array'
153
+ */
154
+ exportType?: 'array' | 'string' | 'css-style-sheet';
155
+ }
156
+ export type StyleLoaderInjectType = 'styleTag' | 'singletonStyleTag' | 'lazyStyleTag' | 'lazySingletonStyleTag' | 'linkTag';
157
+ export interface StyleLoaderOptions {
158
+ /**
159
+ * By default, style-loader generates JS modules that use the ES modules syntax.
160
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
161
+ * @default true
162
+ */
163
+ esModule?: boolean;
164
+ /**
165
+ * Allows to setup how styles will be injected into the DOM.
166
+ * @default 'styleTag'
167
+ */
168
+ injectType?: StyleLoaderInjectType;
169
+ /**
170
+ * If defined, the style-loader will attach given attributes with their values on <style> / <link> element.
171
+ * @default {}
172
+ */
173
+ attributes?: Record<string, string>;
174
+ /**
175
+ * By default, the style-loader appends <style>/<link> elements to the end of the style target, which is the <head> tag of the page unless specified by insert.
176
+ * This will cause CSS created by the loader to take priority over CSS already present in the target.
177
+ * You can use other values if the standard behavior is not suitable for you, but we do not recommend doing this.
178
+ *
179
+ * @default 'head'
180
+ */
181
+ insert?: LiteralUnion<'head' | 'body', string> | ((element: HTMLElement) => void);
182
+ /**
183
+ * Allows to setup absolute path to custom function that allows to override default behavior styleTagTransform.
184
+ */
185
+ styleTagTransform?: string | ((css: string, styleElement: HTMLStyleElement, options: Record<string, any>) => void);
186
+ }
@@ -0,0 +1,19 @@
1
+ export type Falsy = false | null | undefined;
2
+ export type OneOrMany<T> = T | T[];
3
+ export type MaybePromise<T> = T | Promise<T>;
4
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+ export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
6
+ /**
7
+ * Creates a type with readonly properties at the first and second levels only.
8
+ */
9
+ export type TwoLevelReadonly<T> = keyof T extends never ? T : {
10
+ readonly [k in keyof T]: T[k] extends object ? {
11
+ readonly [p in keyof T[k]]: T[k][p];
12
+ } : T[k];
13
+ };
14
+ export type ConfigChain<T> = OneOrMany<T | ((config: T) => T | void)>;
15
+ export type ConfigChainWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => T | void)>;
16
+ export type ConfigChainAsyncWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => MaybePromise<T | void>)>;
17
+ export type ConfigChainMergeContext<T, Ctx> = OneOrMany<T | ((merged: {
18
+ value: T;
19
+ } & Ctx) => T | void)>;
package/package.json ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "name": "@ohos-ports/rsbuild-core",
3
+ "version": "1.7.2-beta.1",
4
+ "description": "The Rspack-based build tool.",
5
+ "homepage": "https://rsbuild.rs",
6
+ "bugs": {
7
+ "url": "https://github.com/ohos-ports/ohos-ports/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
12
+ "directory": "ports/rsbuild-core/1.7.2"
13
+ },
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist-types/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./client/hmr": {
23
+ "types": "./dist-types/client/hmr.d.ts",
24
+ "default": "./dist/client/hmr.js"
25
+ },
26
+ "./client/overlay": {
27
+ "types": "./dist-types/client/overlay.d.ts",
28
+ "default": "./dist/client/overlay.js"
29
+ },
30
+ "./types": {
31
+ "types": "./types.d.ts"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "main": "./dist/index.cjs",
36
+ "types": "./dist-types/index.d.ts",
37
+ "bin": {
38
+ "rsbuild": "./bin/rsbuild.js"
39
+ },
40
+ "files": [
41
+ "bin",
42
+ "dist",
43
+ "dist-types",
44
+ "static",
45
+ "compiled",
46
+ "types.d.ts"
47
+ ],
48
+ "dependencies": {
49
+ "@rspack/core": "npm:@ohos-ports/rspack-core@1.7.11-beta.1",
50
+ "@rspack/lite-tapable": "~1.1.0",
51
+ "@swc/helpers": "^0.5.18",
52
+ "core-js": "~3.47.0",
53
+ "jiti": "^2.6.1"
54
+ },
55
+ "devDependencies": {
56
+ "@jridgewell/remapping": "^2.3.5",
57
+ "@jridgewell/trace-mapping": "^0.3.31",
58
+ "@rslib/core": "0.19.1",
59
+ "@types/connect": "3.4.38",
60
+ "@types/cors": "^2.8.19",
61
+ "@types/node": "^24.10.4",
62
+ "@types/on-finished": "2.3.5",
63
+ "@types/range-parser": "^1.2.7",
64
+ "@types/webpack-bundle-analyzer": "4.7.0",
65
+ "@types/ws": "^8.18.1",
66
+ "browserslist-load-config": "1.0.1",
67
+ "cac": "^6.7.14",
68
+ "chokidar": "^4.0.3",
69
+ "connect": "3.7.0",
70
+ "cors": "^2.8.5",
71
+ "css-loader": "7.1.2",
72
+ "deepmerge": "^4.3.1",
73
+ "dotenv-expand": "12.0.3",
74
+ "html-rspack-plugin": "6.1.4",
75
+ "http-proxy-middleware": "^2.0.9",
76
+ "launch-editor-middleware": "^2.12.0",
77
+ "memfs": "^4.51.1",
78
+ "mrmime": "^2.0.1",
79
+ "on-finished": "2.4.1",
80
+ "open": "^11.0.0",
81
+ "picocolors": "^1.1.1",
82
+ "postcss": "^8.5.6",
83
+ "postcss-load-config": "6.0.1",
84
+ "postcss-loader": "8.2.0",
85
+ "prebundle": "1.6.0",
86
+ "range-parser": "^1.2.1",
87
+ "reduce-configs": "^1.1.1",
88
+ "rslog": "^1.3.2",
89
+ "rspack-chain": "^1.4.3",
90
+ "rspack-manifest-plugin": "5.2.0",
91
+ "sirv": "^3.0.2",
92
+ "stacktrace-parser": "^0.1.11",
93
+ "style-loader": "3.3.4",
94
+ "tinyglobby": "0.2.14",
95
+ "typescript": "^5.9.3",
96
+ "webpack": "^5.104.1",
97
+ "webpack-bundle-analyzer": "^4.10.2",
98
+ "webpack-merge": "6.0.1",
99
+ "ws": "^8.18.3"
100
+ },
101
+ "engines": {
102
+ "node": ">=18.12.0"
103
+ },
104
+ "publishConfig": {
105
+ "access": "public",
106
+ "registry": "https://registry.npmjs.org/"
107
+ },
108
+ "scripts": {
109
+ "build": "rslib build",
110
+ "dev": "rslib build -w",
111
+ "prebundle": "prebundle",
112
+ "bump": "pnpx bumpp --no-tag"
113
+ }
114
+ }