@ohos-ports/rsbuild-core 1.1.14-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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/bin/rsbuild.js +20 -0
  4. package/compiled/chokidar/index.d.ts +345 -0
  5. package/compiled/chokidar/index.js +1778 -0
  6. package/compiled/chokidar/license +21 -0
  7. package/compiled/chokidar/package.json +1 -0
  8. package/compiled/connect/index.d.ts +90 -0
  9. package/compiled/connect/index.js +1240 -0
  10. package/compiled/connect/license +25 -0
  11. package/compiled/connect/package.json +1 -0
  12. package/compiled/connect-history-api-fallback/index.d.ts +1 -0
  13. package/compiled/connect-history-api-fallback/index.js +149 -0
  14. package/compiled/connect-history-api-fallback/license +21 -0
  15. package/compiled/connect-history-api-fallback/package.json +1 -0
  16. package/compiled/cors/index.d.ts +1 -0
  17. package/compiled/cors/index.js +371 -0
  18. package/compiled/cors/license +22 -0
  19. package/compiled/cors/package.json +1 -0
  20. package/compiled/css-loader/api.js +85 -0
  21. package/compiled/css-loader/getUrl.js +26 -0
  22. package/compiled/css-loader/index.d.ts +1 -0
  23. package/compiled/css-loader/index.js +8008 -0
  24. package/compiled/css-loader/license +20 -0
  25. package/compiled/css-loader/noSourceMaps.js +5 -0
  26. package/compiled/css-loader/package.json +1 -0
  27. package/compiled/css-loader/sourceMaps.js +16 -0
  28. package/compiled/html-rspack-plugin/default_index.ejs +9 -0
  29. package/compiled/html-rspack-plugin/index.d.ts +289 -0
  30. package/compiled/html-rspack-plugin/index.js +1583 -0
  31. package/compiled/html-rspack-plugin/license +20 -0
  32. package/compiled/html-rspack-plugin/loader.js +162 -0
  33. package/compiled/html-rspack-plugin/package.json +1 -0
  34. package/compiled/http-proxy-middleware/index.d.ts +318 -0
  35. package/compiled/http-proxy-middleware/index.js +5280 -0
  36. package/compiled/http-proxy-middleware/license +22 -0
  37. package/compiled/http-proxy-middleware/package.json +1 -0
  38. package/compiled/jiti/index.d.ts +1 -0
  39. package/compiled/jiti/index.js +416 -0
  40. package/compiled/jiti/license +21 -0
  41. package/compiled/jiti/package.json +1 -0
  42. package/compiled/launch-editor-middleware/index.d.ts +1 -0
  43. package/compiled/launch-editor-middleware/index.js +694 -0
  44. package/compiled/launch-editor-middleware/license +21 -0
  45. package/compiled/launch-editor-middleware/package.json +1 -0
  46. package/compiled/mrmime/index.d.ts +4 -0
  47. package/compiled/mrmime/index.js +452 -0
  48. package/compiled/mrmime/package.json +1 -0
  49. package/compiled/on-finished/index.d.ts +13 -0
  50. package/compiled/on-finished/index.js +197 -0
  51. package/compiled/on-finished/license +23 -0
  52. package/compiled/on-finished/package.json +1 -0
  53. package/compiled/open/index.d.ts +153 -0
  54. package/compiled/open/index.js +409 -0
  55. package/compiled/open/package.json +1 -0
  56. package/compiled/open/xdg-open +1066 -0
  57. package/compiled/picocolors/index.d.ts +55 -0
  58. package/compiled/picocolors/index.js +108 -0
  59. package/compiled/picocolors/license +15 -0
  60. package/compiled/picocolors/package.json +1 -0
  61. package/compiled/postcss/index.d.ts +1 -0
  62. package/compiled/postcss/index.js +5997 -0
  63. package/compiled/postcss/license +20 -0
  64. package/compiled/postcss/package.json +1 -0
  65. package/compiled/postcss-load-config/index.d.ts +1 -0
  66. package/compiled/postcss-load-config/index.js +739 -0
  67. package/compiled/postcss-load-config/license +20 -0
  68. package/compiled/postcss-load-config/package.json +1 -0
  69. package/compiled/postcss-loader/index.d.ts +1 -0
  70. package/compiled/postcss-loader/index.js +741 -0
  71. package/compiled/postcss-loader/license +20 -0
  72. package/compiled/postcss-loader/package.json +1 -0
  73. package/compiled/rsbuild-dev-middleware/index.d.ts +1 -0
  74. package/compiled/rsbuild-dev-middleware/index.js +6158 -0
  75. package/compiled/rsbuild-dev-middleware/license +20 -0
  76. package/compiled/rsbuild-dev-middleware/package.json +1 -0
  77. package/compiled/rslog/index.d.ts +66 -0
  78. package/compiled/rslog/index.js +334 -0
  79. package/compiled/rslog/license +21 -0
  80. package/compiled/rslog/package.json +1 -0
  81. package/compiled/rspack-chain/index.d.ts +611 -0
  82. package/compiled/rspack-chain/index.js +1740 -0
  83. package/compiled/rspack-chain/license +373 -0
  84. package/compiled/rspack-chain/package.json +1 -0
  85. package/compiled/rspack-manifest-plugin/index.d.ts +44 -0
  86. package/compiled/rspack-manifest-plugin/index.js +394 -0
  87. package/compiled/rspack-manifest-plugin/license +21 -0
  88. package/compiled/rspack-manifest-plugin/package.json +1 -0
  89. package/compiled/sirv/index.d.ts +1 -0
  90. package/compiled/sirv/index.js +709 -0
  91. package/compiled/sirv/package.json +1 -0
  92. package/compiled/style-loader/index.d.ts +1 -0
  93. package/compiled/style-loader/index.js +427 -0
  94. package/compiled/style-loader/license +20 -0
  95. package/compiled/style-loader/package.json +1 -0
  96. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  97. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  98. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  99. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  100. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  101. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  102. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  103. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  104. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  105. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  106. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  107. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  108. package/compiled/tinyglobby/index.d.ts +25 -0
  109. package/compiled/tinyglobby/index.js +2749 -0
  110. package/compiled/tinyglobby/index1.js +17 -0
  111. package/compiled/tinyglobby/license +21 -0
  112. package/compiled/tinyglobby/package.json +1 -0
  113. package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
  114. package/compiled/webpack-bundle-analyzer/index.js +13480 -0
  115. package/compiled/webpack-bundle-analyzer/license +20 -0
  116. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  117. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  118. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  119. package/compiled/webpack-merge/index.d.ts +31 -0
  120. package/compiled/webpack-merge/index.js +1200 -0
  121. package/compiled/webpack-merge/license +20 -0
  122. package/compiled/webpack-merge/package.json +1 -0
  123. package/compiled/ws/index.d.ts +401 -0
  124. package/compiled/ws/index.js +3153 -0
  125. package/compiled/ws/license +20 -0
  126. package/compiled/ws/package.json +1 -0
  127. package/dist/client/hmr.js +143 -0
  128. package/dist/client/overlay.js +210 -0
  129. package/dist/ignoreCssLoader.mjs +4 -0
  130. package/dist/index.cjs +7251 -0
  131. package/dist/index.js +7118 -0
  132. package/dist/transformLoader.mjs +22 -0
  133. package/dist/transformRawLoader.mjs +22 -0
  134. package/dist-types/cli/commands.d.ts +23 -0
  135. package/dist-types/cli/index.d.ts +1 -0
  136. package/dist-types/cli/init.d.ts +7 -0
  137. package/dist-types/cli/prepare.d.ts +1 -0
  138. package/dist-types/client/hmr.d.ts +1 -0
  139. package/dist-types/client/overlay.d.ts +1 -0
  140. package/dist-types/config.d.ts +90 -0
  141. package/dist-types/configChain.d.ts +139 -0
  142. package/dist-types/constants.d.ts +37 -0
  143. package/dist-types/createContext.d.ts +11 -0
  144. package/dist-types/createRsbuild.d.ts +2 -0
  145. package/dist-types/helpers/format.d.ts +5 -0
  146. package/dist-types/helpers/fs.d.ts +13 -0
  147. package/dist-types/helpers/index.d.ts +47 -0
  148. package/dist-types/helpers/path.d.ts +11 -0
  149. package/dist-types/helpers/stats.d.ts +9 -0
  150. package/dist-types/hooks.d.ts +48 -0
  151. package/dist-types/index.d.ts +26 -0
  152. package/dist-types/initPlugins.d.ts +6 -0
  153. package/dist-types/internal.d.ts +6 -0
  154. package/dist-types/loadEnv.d.ts +50 -0
  155. package/dist-types/loader/ignoreCssLoader.d.ts +2 -0
  156. package/dist-types/loader/transformLoader.d.ts +7 -0
  157. package/dist-types/loader/transformRawLoader.d.ts +3 -0
  158. package/dist-types/logger.d.ts +4 -0
  159. package/dist-types/mergeConfig.d.ts +2 -0
  160. package/dist-types/package.json +1 -0
  161. package/dist-types/pluginHelper.d.ts +12 -0
  162. package/dist-types/pluginManager.d.ts +9 -0
  163. package/dist-types/plugins/appIcon.d.ts +2 -0
  164. package/dist-types/plugins/asset.d.ts +3 -0
  165. package/dist-types/plugins/basic.d.ts +5 -0
  166. package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
  167. package/dist-types/plugins/cache.d.ts +2 -0
  168. package/dist-types/plugins/cleanOutput.d.ts +3 -0
  169. package/dist-types/plugins/css.d.ts +3 -0
  170. package/dist-types/plugins/define.d.ts +2 -0
  171. package/dist-types/plugins/entry.d.ts +2 -0
  172. package/dist-types/plugins/externals.d.ts +2 -0
  173. package/dist-types/plugins/fileSize.d.ts +4 -0
  174. package/dist-types/plugins/html.d.ts +9 -0
  175. package/dist-types/plugins/inlineChunk.d.ts +2 -0
  176. package/dist-types/plugins/lazyCompilation.d.ts +2 -0
  177. package/dist-types/plugins/manifest.d.ts +2 -0
  178. package/dist-types/plugins/minimize.d.ts +10 -0
  179. package/dist-types/plugins/moduleFederation.d.ts +2 -0
  180. package/dist-types/plugins/moment.d.ts +2 -0
  181. package/dist-types/plugins/nodeAddons.d.ts +2 -0
  182. package/dist-types/plugins/nonce.d.ts +2 -0
  183. package/dist-types/plugins/output.d.ts +2 -0
  184. package/dist-types/plugins/performance.d.ts +5 -0
  185. package/dist-types/plugins/progress.d.ts +2 -0
  186. package/dist-types/plugins/resolve.d.ts +2 -0
  187. package/dist-types/plugins/resourceHints.d.ts +2 -0
  188. package/dist-types/plugins/rsdoctor.d.ts +2 -0
  189. package/dist-types/plugins/rspackProfile.d.ts +2 -0
  190. package/dist-types/plugins/server.d.ts +2 -0
  191. package/dist-types/plugins/splitChunks.d.ts +4 -0
  192. package/dist-types/plugins/sri.d.ts +2 -0
  193. package/dist-types/plugins/swc.d.ts +7 -0
  194. package/dist-types/plugins/target.d.ts +2 -0
  195. package/dist-types/plugins/wasm.d.ts +2 -0
  196. package/dist-types/provider/build.d.ts +3 -0
  197. package/dist-types/provider/createCompiler.d.ts +27 -0
  198. package/dist-types/provider/helpers.d.ts +12 -0
  199. package/dist-types/provider/initConfigs.d.ts +10 -0
  200. package/dist-types/provider/inspectConfig.d.ts +6 -0
  201. package/dist-types/provider/provider.d.ts +2 -0
  202. package/dist-types/provider/rspackConfig.d.ts +8 -0
  203. package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +37 -0
  204. package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +29 -0
  205. package/dist-types/rspack/preload/helpers/determineAsValue.d.ts +22 -0
  206. package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +29 -0
  207. package/dist-types/rspack/preload/helpers/extractChunks.d.ts +28 -0
  208. package/dist-types/rspack/preload/helpers/index.d.ts +4 -0
  209. package/dist-types/rspack/preload/helpers/type.d.ts +13 -0
  210. package/dist-types/server/ansiHTML.d.ts +12 -0
  211. package/dist-types/server/cliShortcuts.d.ts +10 -0
  212. package/dist-types/server/compilerDevMiddleware.d.ts +31 -0
  213. package/dist-types/server/devMiddleware.d.ts +27 -0
  214. package/dist-types/server/devServer.d.ts +60 -0
  215. package/dist-types/server/environment.d.ts +8 -0
  216. package/dist-types/server/getDevMiddlewares.d.ts +25 -0
  217. package/dist-types/server/gzipMiddleware.d.ts +4 -0
  218. package/dist-types/server/helper.d.ts +71 -0
  219. package/dist-types/server/httpServer.d.ts +8 -0
  220. package/dist-types/server/middlewares.d.ts +34 -0
  221. package/dist-types/server/open.d.ts +10 -0
  222. package/dist-types/server/prodServer.d.ts +25 -0
  223. package/dist-types/server/proxy.d.ts +6 -0
  224. package/dist-types/server/restart.d.ts +14 -0
  225. package/dist-types/server/runner/asModule.d.ts +2 -0
  226. package/dist-types/server/runner/basic.d.ts +25 -0
  227. package/dist-types/server/runner/cjs.d.ts +10 -0
  228. package/dist-types/server/runner/esm.d.ts +6 -0
  229. package/dist-types/server/runner/index.d.ts +8 -0
  230. package/dist-types/server/runner/type.d.ts +36 -0
  231. package/dist-types/server/socketServer.d.ts +26 -0
  232. package/dist-types/server/watchFiles.d.ts +14 -0
  233. package/dist-types/types/config.d.ts +1309 -0
  234. package/dist-types/types/context.d.ts +52 -0
  235. package/dist-types/types/hooks.d.ts +146 -0
  236. package/dist-types/types/index.d.ts +8 -0
  237. package/dist-types/types/plugin.d.ts +329 -0
  238. package/dist-types/types/rsbuild.d.ts +156 -0
  239. package/dist-types/types/rspack.d.ts +16 -0
  240. package/dist-types/types/thirdParty.d.ts +176 -0
  241. package/dist-types/types/utils.d.ts +12 -0
  242. package/package.json +61 -0
  243. package/static/openChrome.applescript +95 -0
  244. package/types.d.ts +221 -0
@@ -0,0 +1,156 @@
1
+ import type { Compiler, MultiCompiler } from '@rspack/core';
2
+ import type * as providerHelpers from '../provider/helpers';
3
+ import type { RsbuildDevServer } from '../server/devServer';
4
+ import type { StartServerResult } from '../server/helper';
5
+ import type { RsbuildConfig } from './config';
6
+ import type { NormalizedConfig, NormalizedEnvironmentConfig } from './config';
7
+ import type { InternalContext, RsbuildContext } from './context';
8
+ import type { PluginManager, RsbuildPluginAPI } from './plugin';
9
+ import type { Rspack } from './rspack';
10
+ import type { WebpackConfig } from './thirdParty';
11
+ export type Bundler = 'rspack' | 'webpack';
12
+ export type StartDevServerOptions = {
13
+ /**
14
+ * Using a custom Rspack Compiler object.
15
+ */
16
+ compiler?: Compiler | MultiCompiler;
17
+ /**
18
+ * Whether to get port silently and not print any logs.
19
+ * @default false
20
+ */
21
+ getPortSilently?: boolean;
22
+ };
23
+ export type CreateDevServerOptions = StartDevServerOptions & {
24
+ /**
25
+ * Whether to trigger Rsbuild compilation
26
+ *
27
+ * @default true
28
+ */
29
+ runCompile?: boolean;
30
+ };
31
+ export type PreviewOptions = {
32
+ /**
33
+ * Whether to get port silently and not print any logs.
34
+ * @default false
35
+ */
36
+ getPortSilently?: boolean;
37
+ /**
38
+ * Whether to check if the dist directory exists and is not empty.
39
+ * @default true
40
+ */
41
+ checkDistDir?: boolean;
42
+ };
43
+ export type BuildOptions = {
44
+ /**
45
+ * Whether to watch for file changes and rebuild.
46
+ * @default false
47
+ */
48
+ watch?: boolean;
49
+ /**
50
+ * Using a custom Rspack Compiler object.
51
+ */
52
+ compiler?: Compiler | MultiCompiler;
53
+ };
54
+ export type Build = (options?: BuildOptions) => Promise<{
55
+ /**
56
+ * Stop watching when in watch mode.
57
+ */
58
+ close: () => Promise<void>;
59
+ /**
60
+ * Rspack's [stats](https://rspack.dev/api/javascript-api/stats) object.
61
+ */
62
+ stats?: Rspack.Stats | Rspack.MultiStats;
63
+ }>;
64
+ export type InspectConfigOptions = {
65
+ mode?: RsbuildMode;
66
+ verbose?: boolean;
67
+ outputPath?: string;
68
+ writeToDisk?: boolean;
69
+ };
70
+ export type InspectConfigResult<B extends 'rspack' | 'webpack' = 'rspack'> = {
71
+ rsbuildConfig: string;
72
+ bundlerConfigs: string[];
73
+ environmentConfigs: string[];
74
+ origin: {
75
+ rsbuildConfig: Omit<NormalizedConfig, 'environments'>;
76
+ environmentConfigs: Record<string, NormalizedEnvironmentConfig>;
77
+ bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
78
+ };
79
+ };
80
+ export type CreateCompiler = <C = Compiler | MultiCompiler>() => Promise<C>;
81
+ export type CreateRsbuildOptions = {
82
+ /**
83
+ * The root path of current project.
84
+ * @default process.cwd()
85
+ */
86
+ cwd?: string;
87
+ /**
88
+ * Only build specified environments.
89
+ */
90
+ environment?: string[];
91
+ /**
92
+ * Rsbuild configurations.
93
+ */
94
+ rsbuildConfig?: RsbuildConfig;
95
+ };
96
+ export type ResolvedCreateRsbuildOptions = CreateRsbuildOptions & Required<Omit<CreateRsbuildOptions, 'environment'>>;
97
+ export type CreateDevServer = (options?: CreateDevServerOptions) => Promise<RsbuildDevServer>;
98
+ export type StartDevServer = (options?: StartDevServerOptions) => Promise<StartServerResult>;
99
+ export type ProviderInstance<B extends 'rspack' | 'webpack' = 'rspack'> = {
100
+ readonly bundler: Bundler;
101
+ createCompiler: CreateCompiler;
102
+ /**
103
+ * It is designed for higher-level frameworks that require a custom server
104
+ */
105
+ createDevServer: CreateDevServer;
106
+ startDevServer: StartDevServer;
107
+ build: Build;
108
+ initConfigs: () => Promise<B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[]>;
109
+ inspectConfig: (options?: InspectConfigOptions) => Promise<InspectConfigResult<B>>;
110
+ };
111
+ export type RsbuildProviderHelpers = typeof providerHelpers;
112
+ export type RsbuildProvider<B extends 'rspack' | 'webpack' = 'rspack'> = (options: {
113
+ context: InternalContext;
114
+ pluginManager: PluginManager;
115
+ rsbuildOptions: ResolvedCreateRsbuildOptions;
116
+ helpers: RsbuildProviderHelpers;
117
+ }) => Promise<ProviderInstance<B>>;
118
+ export type RsbuildInstance = {
119
+ context: RsbuildContext;
120
+ addPlugins: PluginManager['addPlugins'];
121
+ getPlugins: PluginManager['getPlugins'];
122
+ removePlugins: PluginManager['removePlugins'];
123
+ isPluginExists: PluginManager['isPluginExists'];
124
+ build: ProviderInstance['build'];
125
+ preview: (options?: PreviewOptions) => Promise<StartServerResult>;
126
+ initConfigs: ProviderInstance['initConfigs'];
127
+ inspectConfig: ProviderInstance['inspectConfig'];
128
+ createCompiler: ProviderInstance['createCompiler'];
129
+ createDevServer: ProviderInstance['createDevServer'];
130
+ startDevServer: ProviderInstance['startDevServer'];
131
+ getRsbuildConfig: RsbuildPluginAPI['getRsbuildConfig'];
132
+ getNormalizedConfig: RsbuildPluginAPI['getNormalizedConfig'];
133
+ onBeforeBuild: RsbuildPluginAPI['onBeforeBuild'];
134
+ onBeforeCreateCompiler: RsbuildPluginAPI['onBeforeCreateCompiler'];
135
+ onBeforeStartDevServer: RsbuildPluginAPI['onBeforeStartDevServer'];
136
+ onBeforeStartProdServer: RsbuildPluginAPI['onBeforeStartProdServer'];
137
+ onAfterBuild: RsbuildPluginAPI['onAfterBuild'];
138
+ onAfterCreateCompiler: RsbuildPluginAPI['onAfterCreateCompiler'];
139
+ onAfterStartDevServer: RsbuildPluginAPI['onAfterStartDevServer'];
140
+ onAfterStartProdServer: RsbuildPluginAPI['onAfterStartProdServer'];
141
+ onCloseDevServer: RsbuildPluginAPI['onCloseDevServer'];
142
+ onDevCompileDone: RsbuildPluginAPI['onDevCompileDone'];
143
+ onExit: RsbuildPluginAPI['onExit'];
144
+ onCloseBuild: RsbuildPluginAPI['onCloseBuild'];
145
+ };
146
+ export type RsbuildTarget = 'web' | 'node' | 'web-worker';
147
+ export type RsbuildEntryDescription = Rspack.EntryDescription & {
148
+ /**
149
+ * Whether to generate an HTML file for the entry.
150
+ *
151
+ * @default true
152
+ */
153
+ html?: boolean;
154
+ };
155
+ export type RsbuildEntry = Record<string, string | string[] | RsbuildEntryDescription>;
156
+ export type RsbuildMode = 'development' | 'production' | 'none';
@@ -0,0 +1,16 @@
1
+ import type * as Rspack from '@rspack/core';
2
+ import type RspackChain from '../../compiled/rspack-chain/index.js';
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<NonNullable<NonNullable<Rspack.Configuration['module']>['rules']>>;
@@ -0,0 +1,176 @@
1
+ import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
2
+ import type { AcceptedPlugin, ProcessOptions } from 'postcss';
3
+ import type { Configuration as WebpackConfig } from 'webpack';
4
+ import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin/index.js';
5
+ import type { Rspack } from './rspack';
6
+ export type { HtmlRspackPlugin };
7
+ export interface CSSExtractOptions {
8
+ pluginOptions?: CssExtractRspackPluginOptions;
9
+ loaderOptions?: CssExtractRspackLoaderOptions;
10
+ }
11
+ export type { WebpackConfig };
12
+ export type PostCSSOptions = ProcessOptions & {
13
+ config?: boolean;
14
+ plugins?: AcceptedPlugin[];
15
+ };
16
+ export type PostCSSLoaderOptions = {
17
+ /**
18
+ * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
19
+ * @default undefined
20
+ */
21
+ execute?: boolean;
22
+ /**
23
+ * Whether to generate source maps.
24
+ * @default `rsbuildConfig.output.sourceMap.css`
25
+ */
26
+ sourceMap?: boolean;
27
+ /**
28
+ * The special implementation option determines which implementation of PostCSS to use.
29
+ * @default `@rsbuild/core/compiled/postcss`
30
+ */
31
+ implementation?: unknown;
32
+ /**
33
+ * Allows to set PostCSS options and plugins.
34
+ * @default undefined
35
+ */
36
+ postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
37
+ };
38
+ export type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
39
+ export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
40
+ export type CSSLoaderExportLocalsConvention = 'asIs' | 'as-is' | 'camelCase' | 'camel-case' | 'camelCaseOnly' | 'camel-case-only' | 'dashes' | 'dashesOnly' | 'dashes-only' | ((name: string) => string);
41
+ export interface CSSLoaderModulesOptions {
42
+ /**
43
+ * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment.
44
+ */
45
+ auto?: boolean | RegExp | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => boolean);
46
+ /**
47
+ * Allow `css-loader` to export names from global class or id, so you can use that as local name.
48
+ */
49
+ exportGlobals?: boolean;
50
+ /**
51
+ * Style of exported class names.
52
+ */
53
+ exportLocalsConvention?: CSSLoaderExportLocalsConvention;
54
+ /**
55
+ * Export only locals.
56
+ */
57
+ exportOnlyLocals?: boolean;
58
+ /**
59
+ * Allows to specify a function to generate the classname.
60
+ */
61
+ getLocalIdent?: (context: Rspack.LoaderContext, localIdentName: string, localName: string) => string;
62
+ /**
63
+ * Allows to configure the generated local ident name.
64
+ */
65
+ localIdentName?: string;
66
+ /**
67
+ * Allows to redefine basic loader context for local ident name.
68
+ */
69
+ localIdentContext?: string;
70
+ /**
71
+ * Allows to add custom hash to generate more unique classes.
72
+ */
73
+ localIdentHashSalt?: string;
74
+ /**
75
+ * Allows to specify hash function to generate classes.
76
+ */
77
+ localIdentHashFunction?: string;
78
+ /**
79
+ * Allows to specify hash digest to generate classes.
80
+ */
81
+ localIdentHashDigest?: string;
82
+ /**
83
+ * Allows to specify custom RegExp for local ident name.
84
+ */
85
+ localIdentRegExp?: string | RegExp;
86
+ /**
87
+ * Controls the level of compilation applied to the input styles.
88
+ */
89
+ mode?: CSSLoaderModulesMode;
90
+ /**
91
+ * Enables/disables ES modules named export for locals.
92
+ */
93
+ namedExport?: boolean;
94
+ /**
95
+ * Enables a callback to output the CSS Modules mapping JSON.
96
+ */
97
+ getJSON?: (context: {
98
+ resourcePath: string;
99
+ imports: object[];
100
+ exports: object[];
101
+ replacements: object[];
102
+ }) => Promise<void> | void;
103
+ }
104
+ export interface CSSLoaderOptions {
105
+ /**
106
+ * Allow to enable/disables handling the CSS functions url and image-set.
107
+ * If set to false, css-loader will not parse any paths specified in url or image-set
108
+ * @default true
109
+ */
110
+ url?: boolean | {
111
+ filter: (url: string, resourcePath: string) => boolean;
112
+ };
113
+ /**
114
+ * Allows to enables/disables @import at-rules handling.
115
+ * @default true
116
+ */
117
+ import?: boolean | {
118
+ filter: (url: string, media: string, resourcePath: string, supports?: string, layer?: string) => boolean;
119
+ };
120
+ /**
121
+ * Allows to enable/disable CSS Modules or ICSS and setup configuration:
122
+ */
123
+ modules?: boolean | string | CSSLoaderModulesOptions;
124
+ /**
125
+ * By default generation of source maps depends on the devtool option.
126
+ */
127
+ sourceMap?: boolean;
128
+ /**
129
+ * Allows to enables/disables or setups number of loaders applied before CSS loader for @import at-rules,
130
+ * CSS Modules and ICSS imports, i.e. @import/composes/@value value from './values.css'/etc.
131
+ * @default 0
132
+ */
133
+ importLoaders?: number;
134
+ /**
135
+ * By default, css-loader generates JS modules that use the ES modules syntax.
136
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
137
+ * @default true
138
+ */
139
+ esModule?: boolean;
140
+ /**
141
+ * Allows exporting styles as array with modules, string or constructable stylesheet (i.e. CSSStyleSheet)
142
+ * @default 'array'
143
+ */
144
+ exportType?: 'array' | 'string' | 'css-style-sheet';
145
+ }
146
+ export type StyleLoaderInjectType = 'styleTag' | 'singletonStyleTag' | 'lazyStyleTag' | 'lazySingletonStyleTag' | 'linkTag';
147
+ export interface StyleLoaderOptions {
148
+ /**
149
+ * By default, style-loader generates JS modules that use the ES modules syntax.
150
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
151
+ * @default true
152
+ */
153
+ esModule?: boolean;
154
+ /**
155
+ * Allows to setup how styles will be injected into the DOM.
156
+ * @default 'styleTag'
157
+ */
158
+ injectType?: StyleLoaderInjectType;
159
+ /**
160
+ * If defined, the style-loader will attach given attributes with their values on <style> / <link> element.
161
+ * @default {}
162
+ */
163
+ attributes?: Record<string, string>;
164
+ /**
165
+ * 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.
166
+ * This will cause CSS created by the loader to take priority over CSS already present in the target.
167
+ * You can use other values if the standard behavior is not suitable for you, but we do not recommend doing this.
168
+ *
169
+ * @default 'head'
170
+ */
171
+ insert?: string | ((element: HTMLElement) => void);
172
+ /**
173
+ * Allows to setup absolute path to custom function that allows to override default behavior styleTagTransform.
174
+ */
175
+ styleTagTransform?: string | ((css: string, styleElement: HTMLStyleElement, options: Record<string, any>) => void);
176
+ }
@@ -0,0 +1,12 @@
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 DeepReadonly<T> = keyof T extends never ? T : {
5
+ readonly [k in keyof T]: DeepReadonly<T[k]>;
6
+ };
7
+ export type ConfigChain<T> = OneOrMany<T | ((config: T) => T | void)>;
8
+ export type ConfigChainWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => T | void)>;
9
+ export type ConfigChainAsyncWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => MaybePromise<T | void>)>;
10
+ export type ConfigChainMergeContext<T, Ctx> = OneOrMany<T | ((merged: {
11
+ value: T;
12
+ } & Ctx) => T | void)>;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@ohos-ports/rsbuild-core",
3
+ "version": "1.1.14-beta.1",
4
+ "description": "The Rspack-based build tool.",
5
+ "homepage": "https://rsbuild.dev",
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.1.14"
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.1.8-beta.1",
50
+ "@rspack/lite-tapable": "~1.0.1",
51
+ "@swc/helpers": "^0.5.15",
52
+ "core-js": "~3.39.0"
53
+ },
54
+ "engines": {
55
+ "node": ">=16.7.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "registry": "https://registry.npmjs.org/"
60
+ }
61
+ }
@@ -0,0 +1,95 @@
1
+ (*
2
+ Copyright (c) 2015-present, Facebook, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file at
6
+ https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
7
+ *)
8
+
9
+ property targetTab: null
10
+ property targetTabIndex: -1
11
+ property targetWindow: null
12
+ property theProgram: "Google Chrome"
13
+
14
+ on run argv
15
+ set theURL to item 1 of argv
16
+
17
+ -- Allow requested program to be optional,
18
+ -- default to Google Chrome
19
+ if (count of argv) > 1 then
20
+ set theProgram to item 2 of argv
21
+ end if
22
+
23
+ using terms from application "Google Chrome"
24
+ tell application theProgram
25
+
26
+ if (count every window) = 0 then
27
+ make new window
28
+ end if
29
+
30
+ -- 1: Looking for tab running debugger
31
+ -- then, Reload debugging tab if found
32
+ -- then return
33
+ set found to my lookupTabWithUrl(theURL)
34
+ if found then
35
+ set targetWindow's active tab index to targetTabIndex
36
+ tell targetTab to reload
37
+ tell targetWindow to activate
38
+ set index of targetWindow to 1
39
+ return
40
+ end if
41
+
42
+ -- 2: Looking for Empty tab
43
+ -- In case debugging tab was not found
44
+ -- We try to find an empty tab instead
45
+ set found to my lookupTabWithUrl("chrome://newtab/")
46
+ if found then
47
+ set targetWindow's active tab index to targetTabIndex
48
+ set URL of targetTab to theURL
49
+ tell targetWindow to activate
50
+ return
51
+ end if
52
+
53
+ -- 3: Create new tab
54
+ -- both debugging and empty tab were not found
55
+ -- make a new tab with url
56
+ tell window 1
57
+ activate
58
+ make new tab with properties {URL:theURL}
59
+ end tell
60
+ end tell
61
+ end using terms from
62
+ end run
63
+
64
+ -- Function:
65
+ -- Lookup tab with given url
66
+ -- if found, store tab, index, and window in properties
67
+ -- (properties were declared on top of file)
68
+ on lookupTabWithUrl(lookupUrl)
69
+ using terms from application "Google Chrome"
70
+ tell application theProgram
71
+ -- Find a tab with the given url
72
+ set found to false
73
+ set theTabIndex to -1
74
+ repeat with theWindow in every window
75
+ set theTabIndex to 0
76
+ repeat with theTab in every tab of theWindow
77
+ set theTabIndex to theTabIndex + 1
78
+ if (theTab's URL as string) contains lookupUrl then
79
+ -- assign tab, tab index, and window to properties
80
+ set targetTab to theTab
81
+ set targetTabIndex to theTabIndex
82
+ set targetWindow to theWindow
83
+ set found to true
84
+ exit repeat
85
+ end if
86
+ end repeat
87
+
88
+ if found then
89
+ exit repeat
90
+ end if
91
+ end repeat
92
+ end tell
93
+ end using terms from
94
+ return found
95
+ end lookupTabWithUrl