@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,23 @@
1
+ /**
2
+ * This method is modified based on source found in
3
+ * https://github.com/vuejs/preload-webpack-plugin/blob/master/src/lib/extract-chunks.js
4
+ *
5
+ * Copyright 2018 Google Inc.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import type { Chunk, Compilation } from '@rspack/core';
19
+ import type { ResourceHintsIncludeType } from '../../types';
20
+ export declare function extractChunks(compilation: Compilation, includeType?: ResourceHintsIncludeType): Chunk[] | {
21
+ files: string[];
22
+ auxiliaryFiles?: string[];
23
+ }[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This method is modified based on source found in
3
+ * https://github.com/vuejs/preload-webpack-plugin/blob/master/src/lib/determine-as-value.js
4
+ *
5
+ * Copyright 2018 Google Inc.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
19
+ export declare function getResourceType({ href, file, }: {
20
+ href: string;
21
+ file: string;
22
+ }): ResourceType;
@@ -0,0 +1,2 @@
1
+ declare const rspack: (typeof import('@rspack/core'))['rspack'];
2
+ export { rspack };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Converts text with ANSI color codes to HTML markup
3
+ */
4
+ export declare function ansiHTML(text: string): string;
@@ -0,0 +1,12 @@
1
+ import type { Stats as FSStats } from 'node:fs';
2
+ import type { InternalContext, Rspack } from '../../types';
3
+ /**
4
+ * Resolves URL to file path with security checks and retrieves file from
5
+ * the build output directories.
6
+ */
7
+ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
8
+ filename: string;
9
+ fsStats: FSStats;
10
+ } | {
11
+ errorCode: number;
12
+ } | undefined>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The assets middleware is modified based on
3
+ * https://github.com/webpack/webpack-dev-middleware
4
+ *
5
+ * MIT Licensed
6
+ * Copyright JS Foundation and other contributors
7
+ * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
+ */
9
+ import type { Compiler, MultiCompiler } from '@rspack/core';
10
+ import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
11
+ import type { SocketServer } from '../socketServer';
12
+ export type MultiWatching = ReturnType<MultiCompiler['watch']>;
13
+ export type AssetsMiddlewareClose = (callback: (err?: Error | null) => void) => void;
14
+ export type AssetsMiddleware = RequestHandler & {
15
+ watch: () => void;
16
+ close: AssetsMiddlewareClose;
17
+ };
18
+ export declare const isClientCompiler: (compiler: Compiler) => boolean;
19
+ export declare const setupServerHooks: ({ context, compiler, token, socketServer, }: {
20
+ context: InternalContext;
21
+ compiler: Compiler;
22
+ token: string;
23
+ socketServer: SocketServer;
24
+ }) => void;
25
+ /**
26
+ * The assets middleware handles compiler setup for development:
27
+ * - Call `compiler.watch`
28
+ * - Inject the HMR client path into page
29
+ * - Notify server when compiler hooks are triggered
30
+ */
31
+ export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort, }: {
32
+ config: NormalizedConfig;
33
+ compiler: Compiler | MultiCompiler;
34
+ context: InternalContext;
35
+ socketServer: SocketServer;
36
+ resolvedPort: number;
37
+ }) => Promise<AssetsMiddleware>;
@@ -0,0 +1,2 @@
1
+ import type { InternalContext, RequestHandler, Rspack } from '../../types';
2
+ export declare function createMiddleware(context: InternalContext, ready: (callback: () => void) => void, outputFileSystem: Rspack.OutputFileSystem): RequestHandler;
@@ -0,0 +1 @@
1
+ export declare function parseTokenList(str: string): string[];
@@ -0,0 +1,3 @@
1
+ import type { Compiler, OutputFileSystem } from '@rspack/core';
2
+ import type { ResolvedWriteToDisk } from './setupWriteToDisk';
3
+ export declare function setupOutputFileSystem(writeToDisk: ResolvedWriteToDisk, compilers: Compiler[]): OutputFileSystem;
@@ -0,0 +1,15 @@
1
+ import type { Compiler } from '@rspack/core';
2
+ import type { EnvironmentContext, NormalizedDevConfig } from '../../types';
3
+ declare module '@rspack/core' {
4
+ interface Compiler {
5
+ __hasRsbuildAssetEmittedCallback?: boolean;
6
+ }
7
+ }
8
+ export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) => boolean);
9
+ /**
10
+ * Resolve writeToDisk config across multiple environments.
11
+ * Returns the unified config if all environments have the same value,
12
+ * otherwise returns a function that resolves config based on compilation.
13
+ */
14
+ export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
15
+ export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk): void;
@@ -0,0 +1,9 @@
1
+ import type { StackFrame } from 'stacktrace-parser';
2
+ import type { TraceMap } from '../../compiled/@jridgewell/trace-mapping';
3
+ import type { BrowserLogsStackTrace, InternalContext, Rspack } from '../types';
4
+ export type CachedTraceMap = Map<string, TraceMap>;
5
+ /**
6
+ * Formats error messages received from the browser into a log string with
7
+ * source location information.
8
+ */
9
+ export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cachedTraceMap: CachedTraceMap) => Promise<string>;
@@ -0,0 +1,33 @@
1
+ import type { InternalContext, NormalizedConfig, Rspack } from '../types';
2
+ import { type AssetsMiddleware } from './assets-middleware';
3
+ import { SocketServer } from './socketServer';
4
+ type Options = {
5
+ context: InternalContext;
6
+ config: NormalizedConfig;
7
+ compiler: Rspack.Compiler | Rspack.MultiCompiler;
8
+ resolvedPort: number;
9
+ };
10
+ /**
11
+ * Setup compiler related logic:
12
+ * 1. setup assets middleware
13
+ * 2. establish webSocket connect
14
+ */
15
+ export declare class BuildManager {
16
+ assetsMiddleware: AssetsMiddleware;
17
+ outputFileSystem: Rspack.OutputFileSystem;
18
+ socketServer: SocketServer;
19
+ compiler: Rspack.Compiler | Rspack.MultiCompiler;
20
+ private config;
21
+ private resolvedPort;
22
+ private context;
23
+ constructor({ config, context, compiler, resolvedPort }: Options);
24
+ init(): Promise<void>;
25
+ /**
26
+ * Call `compiler.watch()` to start compiling.
27
+ */
28
+ watch(): void;
29
+ close(): Promise<void>;
30
+ readFileSync: (fileName: string) => string;
31
+ private setupCompilationMiddleware;
32
+ }
33
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { CliShortcut, NormalizedConfig } from '../types/config';
2
+ export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
3
+ export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, }: {
4
+ help?: boolean | string;
5
+ openPage: () => Promise<void>;
6
+ closeServer: () => Promise<void>;
7
+ printUrls: () => void;
8
+ restartServer?: () => Promise<boolean>;
9
+ customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
10
+ }): Promise<() => void>;
@@ -0,0 +1,21 @@
1
+ import type { InternalContext, NormalizedConfig, RequestHandler } from '../types';
2
+ import type { BuildManager } from './buildManager';
3
+ import type { RsbuildDevServer } from './devServer';
4
+ import type { UpgradeEvent } from './helper';
5
+ export type RsbuildDevMiddlewareOptions = {
6
+ config: NormalizedConfig;
7
+ context: InternalContext;
8
+ buildManager?: BuildManager;
9
+ devServerAPI: RsbuildDevServer;
10
+ /**
11
+ * Callbacks returned by the `onBeforeStartDevServer` hook.
12
+ */
13
+ postCallbacks: (() => void)[];
14
+ };
15
+ export type Middlewares = (RequestHandler | [string, RequestHandler])[];
16
+ export type GetDevMiddlewaresResult = {
17
+ close: () => Promise<void>;
18
+ onUpgrade: UpgradeEvent;
19
+ middlewares: Middlewares;
20
+ };
21
+ export declare const getDevMiddlewares: (options: RsbuildDevMiddlewareOptions) => GetDevMiddlewaresResult;
@@ -0,0 +1,79 @@
1
+ import type { Server } from 'node:http';
2
+ import type { Http2SecureServer } from 'node:http2';
3
+ import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
4
+ import type { ServerMessage } from './socketServer';
5
+ type HTTPServer = Server | Http2SecureServer;
6
+ type ExtractSocketMessageData<T extends ServerMessage['type']> = Extract<ServerMessage, {
7
+ type: T;
8
+ }> extends {
9
+ data: infer D;
10
+ } ? D : undefined;
11
+ export type SockWrite = <T extends ServerMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
12
+ export type RsbuildDevServer = {
13
+ /**
14
+ * The `connect` app instance.
15
+ * Can be used to attach custom middlewares to the dev server.
16
+ */
17
+ middlewares: Connect.Server;
18
+ /**
19
+ * The Node.js HTTP server instance.
20
+ * - Will be `Http2SecureServer` if `server.https` config is used.
21
+ * - Will be `null` if `server.middlewareMode` is enabled.
22
+ */
23
+ httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
24
+ /**
25
+ * Start listening on the Rsbuild dev server.
26
+ * Do not call this method if you are using a custom server.
27
+ */
28
+ listen: () => Promise<{
29
+ port: number;
30
+ urls: string[];
31
+ server: {
32
+ close: () => Promise<void>;
33
+ };
34
+ }>;
35
+ /**
36
+ * Environment API of Rsbuild server.
37
+ */
38
+ environments: EnvironmentAPI;
39
+ /**
40
+ * The resolved port.
41
+ * By default, Rsbuild server listens on port `3000` and automatically increments
42
+ * the port number if the port is occupied.
43
+ */
44
+ port: number;
45
+ /**
46
+ * Notifies Rsbuild that the custom server has successfully started.
47
+ * Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
48
+ */
49
+ afterListen: () => Promise<void>;
50
+ /**
51
+ * Activate socket connection.
52
+ * This ensures that HMR works properly.
53
+ */
54
+ connectWebSocket: (options: {
55
+ server: HTTPServer;
56
+ }) => void;
57
+ /**
58
+ * Close the Rsbuild server.
59
+ */
60
+ close: () => Promise<void>;
61
+ /**
62
+ * Print the server URLs.
63
+ */
64
+ printUrls: () => void;
65
+ /**
66
+ * Open URL in the browser after starting the server.
67
+ */
68
+ open: () => Promise<void>;
69
+ /**
70
+ * Allows middleware to send some message to HMR client, and then the HMR
71
+ * client will take different actions depending on the message type.
72
+ * - `static-changed`: The page will reload.
73
+ */
74
+ sockWrite: SockWrite;
75
+ };
76
+ export declare function createDevServer<Options extends {
77
+ context: InternalContext;
78
+ }>(options: Options, createCompiler: CreateCompiler, config: NormalizedConfig, { compiler: customCompiler, getPortSilently, runCompile, }?: CreateDevServerOptions): Promise<RsbuildDevServer>;
79
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { EnvironmentContext, Rspack } from '../types';
2
+ export type ServerUtils = {
3
+ readFileSync: (fileName: string) => string;
4
+ environment: EnvironmentContext;
5
+ };
6
+ export declare const loadBundle: <T>(stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T>;
7
+ export declare const getTransformedHtml: (entryName: string, utils: ServerUtils) => string;
8
+ export declare const createCacheableFunction: <T>(getter: (stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T> | T) => (stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Registers a cleanup callback to be executed before process termination
3
+ */
4
+ export declare const registerCleanup: (callback: () => Promise<void>) => void;
5
+ export declare const removeCleanup: (callback: () => Promise<void>) => void;
6
+ /**
7
+ * Sets up listeners for termination signals and stdin end event
8
+ * This should be called once during application initialization
9
+ */
10
+ export declare const setupGracefulShutdown: () => (() => void);
@@ -0,0 +1,2 @@
1
+ import type { CompressOptions, RequestHandler } from '../types';
2
+ export declare const gzipMiddleware: ({ filter, level, }?: CompressOptions) => RequestHandler;
@@ -0,0 +1,91 @@
1
+ import type { IncomingMessage, Server } from 'node:http';
2
+ import type { Http2SecureServer } from 'node:http2';
3
+ import type { Socket } from 'node:net';
4
+ import type { InternalContext, NormalizedConfig, OutputStructure, PrintUrls, Routes, RsbuildEntry } from '../types';
5
+ /**
6
+ * It used to subscribe http upgrade event
7
+ */
8
+ export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
9
+ export type StartServerResult = {
10
+ /**
11
+ * The URLs that server is listening on.
12
+ */
13
+ urls: string[];
14
+ /**
15
+ * The actual port used by the server.
16
+ */
17
+ port: number;
18
+ server: {
19
+ /**
20
+ * Close the server.
21
+ * In development mode, this will call the `onCloseDevServer` hook.
22
+ */
23
+ close: () => Promise<void>;
24
+ };
25
+ };
26
+ export declare const normalizeUrl: (url: string) => string;
27
+ export declare const joinUrlSegments: (s1: string, s2: string) => string;
28
+ export declare const stripBase: (path: string, base: string) => string;
29
+ export declare const getRoutes: (context: InternalContext) => Routes;
30
+ export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
31
+ export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, }: {
32
+ urls: {
33
+ url: string;
34
+ label: string;
35
+ }[];
36
+ port: number;
37
+ routes: Routes;
38
+ protocol: string;
39
+ printUrls?: PrintUrls;
40
+ trailingLineBreak?: boolean;
41
+ }): string | null;
42
+ /**
43
+ * Get available free port.
44
+ * @param port - Current port want to use.
45
+ * @param tryLimits - Maximum number of retries.
46
+ * @param strictPort - Whether to throw an error when the port is occupied.
47
+ * @returns Available port number.
48
+ */
49
+ export declare const getPort: ({ host, port, strictPort, tryLimits, }: {
50
+ host: string;
51
+ port: string | number;
52
+ strictPort: boolean;
53
+ tryLimits?: number;
54
+ }) => Promise<number>;
55
+ export declare const getServerConfig: ({ config, }: {
56
+ config: NormalizedConfig;
57
+ }) => Promise<{
58
+ port: number;
59
+ host: string;
60
+ https: boolean;
61
+ portTip: string | undefined;
62
+ }>;
63
+ export declare const isWildcardHost: (host: string) => boolean;
64
+ export declare const getHostInUrl: (host: string) => Promise<string>;
65
+ type AddressUrl = {
66
+ label: string;
67
+ url: string;
68
+ };
69
+ export declare const getAddressUrls: ({ protocol, port, host, }: {
70
+ protocol?: string;
71
+ port: number;
72
+ host?: string;
73
+ }) => Promise<AddressUrl[]>;
74
+ export declare function getServerTerminator(server: Server | Http2SecureServer): () => Promise<void>;
75
+ /**
76
+ * Escape HTML characters
77
+ * @example
78
+ * escapeHtml('<div>Hello</div>') // '&lt;div&gt;Hello&lt;/div&gt;'
79
+ */
80
+ export declare function escapeHtml(text: string | null | undefined): string;
81
+ export declare const HttpCode: {
82
+ readonly Ok: 200;
83
+ readonly NotModified: 304;
84
+ readonly BadRequest: 400;
85
+ readonly Forbidden: 403;
86
+ readonly NotFound: 404;
87
+ readonly PreconditionFailed: 412;
88
+ readonly RangeNotSatisfiable: 416;
89
+ readonly InternalServerError: 500;
90
+ };
91
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { HistoryApiFallbackOptions, RequestHandler } from '../types';
2
+ export declare function historyApiFallbackMiddleware(options?: HistoryApiFallbackOptions): RequestHandler;
@@ -0,0 +1 @@
1
+ export declare function resolveHostname(host?: string | undefined): Promise<string>;
@@ -0,0 +1,7 @@
1
+ import type { Server } from 'node:http';
2
+ import type { Http2SecureServer } from 'node:http2';
3
+ import type { Connect, ServerConfig } from '../types';
4
+ export declare const createHttpServer: ({ serverConfig, middlewares, }: {
5
+ serverConfig: ServerConfig;
6
+ middlewares: Connect.Server;
7
+ }) => Promise<Http2SecureServer | Server>;
@@ -0,0 +1,33 @@
1
+ import type { Connect, EnvironmentAPI, HtmlFallback, RequestHandler } from '../types';
2
+ import type { BuildManager } from './buildManager';
3
+ export declare const faviconFallbackMiddleware: RequestHandler;
4
+ export declare const getRequestLoggerMiddleware: () => Connect.NextHandleFunction;
5
+ export declare const notFoundMiddleware: RequestHandler;
6
+ export declare const optionsFallbackMiddleware: RequestHandler;
7
+ /**
8
+ * Support access HTML without suffix
9
+ */
10
+ export declare const getHtmlCompletionMiddleware: (params: {
11
+ distPath: string;
12
+ buildManager: BuildManager;
13
+ }) => RequestHandler;
14
+ /**
15
+ * handle `server.base`
16
+ */
17
+ export declare const getBaseUrlMiddleware: (params: {
18
+ base: string;
19
+ }) => RequestHandler;
20
+ /**
21
+ * support HTML fallback in some edge cases
22
+ */
23
+ export declare const getHtmlFallbackMiddleware: (params: {
24
+ distPath: string;
25
+ buildManager: BuildManager;
26
+ htmlFallback?: HtmlFallback;
27
+ }) => RequestHandler;
28
+ /**
29
+ * Support viewing served files via `/rsbuild-dev-server` route
30
+ */
31
+ export declare const viewingServedFilesMiddleware: (params: {
32
+ environments: EnvironmentAPI;
33
+ }) => RequestHandler;
@@ -0,0 +1,10 @@
1
+ import type { NormalizedConfig, Routes } from '../types';
2
+ export declare const replacePortPlaceholder: (url: string, port: number) => string;
3
+ export declare function resolveUrl(str: string, base: string): string;
4
+ export declare function open({ https, port, routes, config, clearCache, }: {
5
+ https?: boolean;
6
+ port: number;
7
+ routes: Routes;
8
+ config: NormalizedConfig;
9
+ clearCache?: boolean;
10
+ }): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export declare function formatDisplayPath(filePath: string, isAbsolute: boolean, root?: string): string;
2
+ export declare function convertLinksInHtml(text: string, root?: string): string;
3
+ export declare function renderErrorToHtml(error: string, root?: string): string;
@@ -0,0 +1,24 @@
1
+ import type { Server } from 'node:http';
2
+ import type { Http2SecureServer } from 'node:http2';
3
+ import type { Connect, InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
4
+ import { type StartServerResult } from './helper';
5
+ type RsbuildProdServerOptions = {
6
+ pwd: string;
7
+ output: {
8
+ path: string;
9
+ assetPrefixes: string[];
10
+ };
11
+ serverConfig: ServerConfig;
12
+ };
13
+ export declare class RsbuildProdServer {
14
+ private app;
15
+ private options;
16
+ middlewares: Connect.Server;
17
+ constructor(options: RsbuildProdServerOptions, middlewares: Connect.Server);
18
+ onInit(app: Server | Http2SecureServer): Promise<void>;
19
+ private applyDefaultMiddlewares;
20
+ private applyStaticAssetMiddleware;
21
+ close(): Promise<void>;
22
+ }
23
+ export declare function startProdServer(context: InternalContext, config: NormalizedConfig, { getPortSilently }?: PreviewOptions): Promise<StartServerResult>;
24
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { RequestHandler as Middleware, ProxyConfig } from '../types';
2
+ import { type UpgradeEvent } from './helper';
3
+ export declare const createProxyMiddleware: (proxyOptions: ProxyConfig) => {
4
+ middlewares: Middleware[];
5
+ upgrade: UpgradeEvent;
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { Module, SyntheticModule } from 'node:vm';
2
+ export declare const asModule: (something: Record<string, any>, context: Record<string, any>, unlinked?: boolean) => Promise<Module | SyntheticModule>;
@@ -0,0 +1,29 @@
1
+ import type { BasicGlobalContext, BasicModuleScope, BasicRunnerFile, CompilerOptions, ModuleObject, Runner, RunnerRequirer } from './type';
2
+ export interface IBasicRunnerOptions {
3
+ name: string;
4
+ isBundleOutput: (modulePath: string) => boolean;
5
+ readFileSync: (path: string) => string;
6
+ dist: string;
7
+ compilerOptions: CompilerOptions;
8
+ }
9
+ export declare abstract class BasicRunner implements Runner {
10
+ protected _options: IBasicRunnerOptions;
11
+ protected globalContext: BasicGlobalContext | null;
12
+ protected baseModuleScope: BasicModuleScope | null;
13
+ protected requirers: Map<string, RunnerRequirer>;
14
+ constructor(_options: IBasicRunnerOptions);
15
+ run(file: string): Promise<unknown>;
16
+ getRequire(): RunnerRequirer;
17
+ protected abstract createGlobalContext(): BasicGlobalContext;
18
+ protected abstract createBaseModuleScope(): BasicModuleScope;
19
+ protected abstract createModuleScope(requireFn: RunnerRequirer, m: ModuleObject, file: BasicRunnerFile): BasicModuleScope;
20
+ /**
21
+ * Get the file information for a given module path.
22
+ *
23
+ * @returns An object containing the file path, content, and subPath, or null if the module is not an rspack output.
24
+ */
25
+ protected getFile(modulePath: string[] | string, currentDirectory: string): BasicRunnerFile | null;
26
+ protected preExecute(_code: string, _file: BasicRunnerFile): void;
27
+ protected postExecute(_m: Record<string, any>, _file: BasicRunnerFile): void;
28
+ protected createRunner(): void;
29
+ }
@@ -0,0 +1,10 @@
1
+ import { BasicRunner } from './basic';
2
+ import type { BasicGlobalContext, BasicModuleScope, BasicRunnerFile, ModuleObject, RunnerRequirer } from './type';
3
+ export declare class CommonJsRunner extends BasicRunner {
4
+ protected createGlobalContext(): BasicGlobalContext;
5
+ protected createBaseModuleScope(): BasicModuleScope;
6
+ protected createModuleScope(requireFn: RunnerRequirer, m: ModuleObject, file: BasicRunnerFile): BasicModuleScope;
7
+ protected createRunner(): void;
8
+ protected createMissRequirer(): RunnerRequirer;
9
+ protected createCjsRequirer(): RunnerRequirer;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { CommonJsRunner } from './cjs';
2
+ import { type RunnerRequirer } from './type';
3
+ export declare class EsmRunner extends CommonJsRunner {
4
+ protected createRunner(): void;
5
+ protected createEsmRequirer(): RunnerRequirer;
6
+ }
@@ -0,0 +1,4 @@
1
+ import type { RunnerFactoryOptions } from './type';
2
+ export declare const run: <T>({ bundlePath, ...runnerFactoryOptions }: RunnerFactoryOptions & {
3
+ bundlePath: string;
4
+ }) => Promise<T>;
@@ -0,0 +1,42 @@
1
+ import type { RspackOptionsNormalized } from '@rspack/core';
2
+ export type RunnerRequirer = (currentDirectory: string, modulePath: string[] | string, context?: {
3
+ file?: BasicRunnerFile;
4
+ esmMode?: EsmMode;
5
+ }) => Record<string, any> | Promise<Record<string, any>>;
6
+ export type BasicRunnerFile = {
7
+ path: string;
8
+ content: string;
9
+ subPath: string;
10
+ };
11
+ export declare enum EsmMode {
12
+ Unknown = 0,
13
+ Evaluated = 1,
14
+ Unlinked = 2
15
+ }
16
+ export interface BasicModuleScope {
17
+ console: Console;
18
+ [key: string]: any;
19
+ }
20
+ export interface BasicGlobalContext {
21
+ console: Console;
22
+ setTimeout: typeof setTimeout;
23
+ clearTimeout: typeof clearTimeout;
24
+ [key: string]: any;
25
+ }
26
+ export type ModuleObject = {
27
+ exports: unknown;
28
+ };
29
+ export type CompilerOptions = RspackOptionsNormalized;
30
+ export interface Runner {
31
+ run(file: string): Promise<unknown>;
32
+ getRequire(): RunnerRequirer;
33
+ }
34
+ export type RunnerFactoryOptions = {
35
+ dist: string;
36
+ compilerOptions: CompilerOptions;
37
+ readFileSync: (path: string) => string;
38
+ isBundleOutput: (modulePath: string) => boolean;
39
+ };
40
+ export interface RunnerFactory {
41
+ create(options: RunnerFactoryOptions): Runner;
42
+ }