rollipop 1.0.0-alpha.21 → 1.0.0-alpha.23

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 (161) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{chunk-DEq-mXcV.js → _virtual/_rolldown/runtime.js} +1 -1
  3. package/dist/commands.d.ts +2 -4
  4. package/dist/commands.js +10 -3957
  5. package/dist/common/code.js +21 -0
  6. package/dist/common/constants.js +5 -0
  7. package/dist/common/env.js +33 -0
  8. package/dist/common/logger.d.ts +34 -0
  9. package/dist/common/logger.js +82 -0
  10. package/dist/common/logo.js +54 -0
  11. package/dist/common/progress-bar.js +167 -0
  12. package/dist/common/transformer.js +13 -0
  13. package/dist/common/types.d.ts +10 -0
  14. package/dist/config/compose-override.js +18 -0
  15. package/dist/config/defaults.d.ts +74 -0
  16. package/dist/config/defaults.js +74 -0
  17. package/dist/config/define-config.d.ts +13 -0
  18. package/dist/config/define-config.js +6 -0
  19. package/dist/config/index.d.ts +5 -0
  20. package/dist/config/index.js +5 -0
  21. package/dist/config/load-config.d.ts +19 -0
  22. package/dist/config/load-config.js +73 -0
  23. package/dist/config/merge-config.d.ts +12 -0
  24. package/dist/config/merge-config.js +20 -0
  25. package/dist/config/types.d.ts +452 -0
  26. package/dist/constants.d.ts +35 -0
  27. package/dist/constants.js +146 -0
  28. package/dist/core/assets.d.ts +91 -0
  29. package/dist/core/assets.js +244 -0
  30. package/dist/core/bundler.d.ts +15 -0
  31. package/dist/core/bundler.js +80 -0
  32. package/dist/core/env.d.ts +11 -0
  33. package/dist/core/env.js +36 -0
  34. package/dist/core/fs/data.js +9 -0
  35. package/dist/core/fs/storage.d.ts +15 -0
  36. package/dist/core/fs/storage.js +31 -0
  37. package/dist/core/plugins/babel-plugin.d.ts +22 -0
  38. package/dist/core/plugins/babel-plugin.js +74 -0
  39. package/dist/core/plugins/context.d.ts +10 -0
  40. package/dist/core/plugins/context.js +24 -0
  41. package/dist/core/plugins/dev-server-plugin.d.ts +13 -0
  42. package/dist/core/plugins/dev-server-plugin.js +27 -0
  43. package/dist/core/plugins/index.d.ts +13 -0
  44. package/dist/core/plugins/index.js +18 -0
  45. package/dist/core/plugins/prelude-plugin.d.ts +10 -0
  46. package/dist/core/plugins/prelude-plugin.js +23 -0
  47. package/dist/core/plugins/react-native-plugin.d.ts +36 -0
  48. package/dist/core/plugins/react-native-plugin.js +81 -0
  49. package/dist/core/plugins/reporter-plugin.d.ts +11 -0
  50. package/dist/core/plugins/reporter-plugin.js +87 -0
  51. package/dist/core/plugins/shared/filters.js +5 -0
  52. package/dist/core/plugins/swc-plugin.d.ts +26 -0
  53. package/dist/core/plugins/swc-plugin.js +108 -0
  54. package/dist/core/plugins/types.d.ts +18 -0
  55. package/dist/core/plugins/utils/source.js +10 -0
  56. package/dist/core/plugins/utils/transform-utils.js +56 -0
  57. package/dist/core/rolldown.js +313 -0
  58. package/dist/core/settings.js +19 -0
  59. package/dist/core/types.d.ts +83 -0
  60. package/dist/filter.d.ts +1 -0
  61. package/dist/filter.js +2 -0
  62. package/dist/hmr-runtime.iife.js +5 -5
  63. package/dist/index.d.ts +24 -1221
  64. package/dist/index.js +19 -4029
  65. package/dist/internal/react-native.js +24 -0
  66. package/dist/logger.js +5 -0
  67. package/dist/node/cli-utils.d.ts +10 -0
  68. package/dist/node/cli-utils.js +28 -0
  69. package/dist/node/cli.d.ts +6 -0
  70. package/dist/node/cli.js +23 -0
  71. package/dist/node/commands/agent/action.js +91 -0
  72. package/dist/node/commands/agent/command.js +10 -0
  73. package/dist/node/commands/agent/index.js +2 -0
  74. package/dist/node/commands/bundle/action.js +33 -0
  75. package/dist/node/commands/bundle/command.js +96 -0
  76. package/dist/node/commands/bundle/index.js +2 -0
  77. package/dist/node/commands/start/action.js +37 -0
  78. package/dist/node/commands/start/command.js +93 -0
  79. package/dist/node/commands/start/debugger.js +79 -0
  80. package/dist/node/commands/start/index.js +2 -0
  81. package/dist/node/commands/start/setup-interactive-mode.d.ts +20 -0
  82. package/dist/node/commands/start/setup-interactive-mode.js +107 -0
  83. package/dist/node/constants.js +4 -0
  84. package/dist/node/logger.js +5 -0
  85. package/dist/node/types.d.ts +23 -0
  86. package/dist/node/utils.js +23 -0
  87. package/dist/package.js +4 -0
  88. package/dist/runtime.js +1 -1
  89. package/dist/server/bundle.d.ts +12 -0
  90. package/dist/server/bundle.js +55 -0
  91. package/dist/server/bundler-pool.d.ts +51 -0
  92. package/dist/server/bundler-pool.js +197 -0
  93. package/dist/server/common/schema.js +19 -0
  94. package/dist/server/constants.d.ts +6 -0
  95. package/dist/server/constants.js +6 -0
  96. package/dist/server/create-dev-server.d.ts +6 -0
  97. package/dist/server/create-dev-server.js +185 -0
  98. package/dist/server/error.js +9 -0
  99. package/dist/server/events/event-bus.d.ts +12 -0
  100. package/dist/server/events/event-bus.js +16 -0
  101. package/dist/server/events/types.d.ts +37 -0
  102. package/dist/server/events/types.js +6 -0
  103. package/dist/server/index.d.ts +3 -0
  104. package/dist/server/index.js +3 -0
  105. package/dist/server/logger.js +33 -0
  106. package/dist/server/mcp/context.js +14 -0
  107. package/dist/server/mcp/server.js +86 -0
  108. package/dist/server/mcp/tools/app-log-diagnostics.js +37 -0
  109. package/dist/server/mcp/tools/build-diagnostics.js +97 -0
  110. package/dist/server/mcp/tools/build-info.js +33 -0
  111. package/dist/server/mcp/tools/device-diagnostics.js +52 -0
  112. package/dist/server/mcp/tools/index.js +277 -0
  113. package/dist/server/middlewares/request-logger.js +15 -0
  114. package/dist/server/middlewares/serve-assets.js +49 -0
  115. package/dist/server/middlewares/serve-bundle.js +72 -0
  116. package/dist/server/middlewares/sse.js +34 -0
  117. package/dist/server/middlewares/symbolicate.js +71 -0
  118. package/dist/server/sse/adapter.js +74 -0
  119. package/dist/server/sse/event-bus.js +26 -0
  120. package/dist/server/symbolicate.js +93 -0
  121. package/dist/server/types.d.ts +125 -0
  122. package/dist/server/wss/hmr-server.js +209 -0
  123. package/dist/server/wss/server.d.ts +9 -0
  124. package/dist/server/wss/server.js +70 -0
  125. package/dist/{runtime.d.cts → types/hmr.d.ts} +1 -12
  126. package/dist/types.d.ts +78 -0
  127. package/dist/utils/babel.js +11 -0
  128. package/dist/utils/build-options.js +17 -0
  129. package/dist/utils/bundle.js +6 -0
  130. package/dist/utils/config.d.ts +5 -0
  131. package/dist/utils/config.js +32 -0
  132. package/dist/utils/dev-server.js +51 -0
  133. package/dist/utils/env.js +7 -0
  134. package/dist/utils/errors.js +9 -0
  135. package/dist/utils/hash.js +8 -0
  136. package/dist/utils/id.js +28 -0
  137. package/dist/utils/node-resolve.js +42 -0
  138. package/dist/utils/promise.js +15 -0
  139. package/dist/utils/reporters.js +120 -0
  140. package/dist/utils/reset-cache.d.ts +8 -0
  141. package/dist/utils/reset-cache.js +25 -0
  142. package/dist/utils/response.js +91 -0
  143. package/dist/utils/run-build.d.ts +8 -0
  144. package/dist/utils/run-build.js +7 -0
  145. package/dist/utils/run-server.d.ts +6 -0
  146. package/dist/utils/run-server.js +20 -0
  147. package/dist/utils/runtime-target.js +9 -0
  148. package/dist/utils/serialize.js +10 -0
  149. package/dist/utils/server.js +6 -0
  150. package/dist/utils/storage.js +6 -0
  151. package/dist/utils/string.js +6 -0
  152. package/dist/utils/swc.js +10 -0
  153. package/dist/utils/terminal.js +86 -0
  154. package/dist/utils/url.js +23 -0
  155. package/package.json +56 -68
  156. package/dist/commands.cjs +0 -4008
  157. package/dist/commands.d.cts +0 -5
  158. package/dist/pluginutils.d.ts +0 -1
  159. package/dist/pluginutils.js +0 -2
  160. package/dist/runtime.cjs +0 -34
  161. /package/dist/{chunk-DXpK5_cz.js → chunk-DJV587Yu.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,1223 +1,26 @@
1
- import { ChalkInstance } from "chalk";
1
+ import { BuildDiagnosticLog, DeepRequired, MaybePromise, MetroCompatibleClientLogEvent, NullValue, PackageJson, ReportableEvent, Reporter } from "./types.js";
2
+ import { AsyncResult, BuildOptions, BuildType, BundlerContext, BundlerState, DevEngine, DevEngineOptions } from "./core/types.js";
3
+ import { BundleDetails, DevServer, DevServerContext, DevServerEvents, FastifyInstance, FormattedError, Middlewares, ServerOptions } from "./server/types.js";
4
+ import { createDevServer } from "./server/create-dev-server.js";
5
+ import { DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH } from "./server/constants.js";
6
+ import { Plugin, PluginConfig } from "./core/plugins/types.js";
7
+ import { InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, setupInteractiveMode } from "./node/commands/start/setup-interactive-mode.js";
8
+ import { createCommand, createReactNativeCliCommand } from "./node/cli-utils.js";
9
+ import { BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig } from "./config/types.js";
10
+ import { PluginFlattenConfig, mergeConfig } from "./config/merge-config.js";
11
+ import { DefaultConfig, ResolvedConfig, getDefaultConfig } from "./config/defaults.js";
12
+ import { DefineConfigContext, DynamicUserConfig, UserConfig, defineConfig } from "./config/define-config.js";
13
+ import { LoadConfigOptions, flattenPluginOption, invokeConfigResolved, loadConfig, resolvePluginConfig } from "./config/load-config.js";
14
+ import { resetCache } from "./utils/reset-cache.js";
15
+ import { runBuild } from "./utils/run-build.js";
16
+ import { runServer } from "./utils/run-server.js";
17
+ import { Bundler } from "./core/bundler.js";
18
+ import { index_d_exports } from "./core/plugins/index.js";
19
+ import { assets_d_exports } from "./core/assets.js";
20
+ import { LoadEnvOptions, loadEnv } from "./core/env.js";
21
+ import { constants_d_exports } from "./constants.js";
22
+ import { DevRuntime, DevRuntimeInterface, DevRuntimeMessenger, DevRuntimeModule, HMRClientLogLevel, HMRClientMessage, HMRContext, HMRCustomHandler, HMRCustomMessage, HMRServerError, HMRServerMessage } from "./types/hmr.js";
23
+ import { cli_d_exports } from "./node/cli.js";
2
24
  import * as rolldown from "@rollipop/rolldown";
3
- import { RollupLogWithString } from "@rollipop/rolldown";
4
25
  import * as rolldownExperimental from "@rollipop/rolldown/experimental";
5
- import { DevEngine as DevEngine$1, DevOptions, DevWatchOptions, RollipopReactNativeFlowConfig, RollipopReactNativePluginConfig, RollipopReactNativeWorkletsConfig } from "@rollipop/rolldown/experimental";
6
- import { TopLevelFilterExpression } from "@rollipop/rolldown-pluginutils";
7
- import { FastifyInstance as FastifyInstance$1 } from "fastify";
8
- import { Emitter } from "mitt";
9
- import EventEmitter from "node:events";
10
- import * as ws from "ws";
11
- import * as babel from "@babel/core";
12
- import * as swc from "@swc/core";
13
- import { Command } from "@commander-js/extra-typings";
14
- import * as fastifyMiddie from "@fastify/middie";
15
- import { TransformOptions } from "@rollipop/rolldown/utils";
16
- import { Command as Command$1 } from "@react-native-community/cli-types";
17
-
18
- //#region src/types.d.ts
19
- type MaybePromise<T> = T | Promise<T>;
20
- type NullValue<T = void> = T | undefined | null | void;
21
- type DeepRequired<T> = { [K in keyof T]-?: T[K] extends object ? DeepRequired<T[K]> : T[K] };
22
- interface Reporter {
23
- update(event: ReportableEvent): void;
24
- }
25
- type ReportableEvent = {
26
- type: 'bundle_build_started';
27
- } | {
28
- type: 'bundle_build_done';
29
- totalModules: number;
30
- duration: number;
31
- } | {
32
- type: 'bundle_build_failed';
33
- error: Error;
34
- } | {
35
- type: 'transform';
36
- id: string;
37
- totalModules: number | undefined;
38
- transformedModules: number;
39
- } | {
40
- type: 'watch_change';
41
- id: string;
42
- } | MetroCompatibleClientLogEvent;
43
- type MetroCompatibleClientLogEvent = {
44
- type: 'client_log';
45
- level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug'
46
- /**
47
- * In react-native, ReportableEvent['level'] does not defined `error` type.
48
- * But, Flipper supports the `error` type.
49
- *
50
- * @see https://github.com/facebook/flipper/blob/v0.273.0/desktop/flipper-common/src/server-types.tsx#L74
51
- */
52
- | 'error';
53
- data: any[];
54
- };
55
- interface PackageJson {
56
- name: string;
57
- version?: string;
58
- dependencies?: Record<string, string>;
59
- devDependencies?: Record<string, string>;
60
- }
61
- //#endregion
62
- //#region src/common/types.d.ts
63
- interface FileStorageData {
64
- build: {
65
- [buildHash: string]: {
66
- totalModules: number;
67
- };
68
- };
69
- }
70
- //#endregion
71
- //#region src/core/fs/storage.d.ts
72
- declare class FileStorage {
73
- private readonly basePath;
74
- private static instance;
75
- private dataFilePath;
76
- private data;
77
- static getInstance(basePath: string): FileStorage;
78
- private constructor();
79
- get(): FileStorageData;
80
- set(data: Partial<FileStorageData>): void;
81
- }
82
- //#endregion
83
- //#region src/core/types.d.ts
84
- interface BuildOptions {
85
- /**
86
- * The platform to build for.
87
- */
88
- platform: string;
89
- /**
90
- * Whether to build in development mode.
91
- *
92
- * Defaults to `config.mode === 'development'`.
93
- */
94
- dev?: boolean;
95
- /**
96
- * Whether to minify the bundle.
97
- *
98
- * This option is overridden by the `minify` option in the config.
99
- *
100
- * Defaults to `false`.
101
- */
102
- minify?: rolldown.OutputOptions['minify'];
103
- /**
104
- * Enable or disable the cache.
105
- *
106
- * Defaults to `true`.
107
- */
108
- cache?: boolean;
109
- /**
110
- * The output file.
111
- */
112
- outfile?: string;
113
- /**
114
- * The sourcemap file.
115
- *
116
- * This option is overridden by the `sourcemap` option in the config.
117
- */
118
- sourcemap?: rolldown.OutputOptions['sourcemap'];
119
- /**
120
- * The output file for the sourcemap.
121
- */
122
- sourcemapOutfile?: string;
123
- /**
124
- * The assets directory.
125
- */
126
- assetsDir?: string;
127
- }
128
- type DevEngine = DevEngine$1 & {
129
- getContext: () => BundlerContext;
130
- };
131
- type DevEngineOptions = Omit<DevOptions, 'watch'> & {
132
- /**
133
- * The host to run the dev server on.
134
- */
135
- host: string;
136
- /**
137
- * The port to run the dev server on.
138
- */
139
- port: number;
140
- /**
141
- * Whether to use HTTPS.
142
- *
143
- * Defaults to `false`.
144
- */
145
- https?: boolean;
146
- };
147
- interface BundlerContext {
148
- id: string;
149
- root: string;
150
- storage: FileStorage;
151
- buildType: BuildType;
152
- state: BundlerState;
153
- }
154
- interface BundlerState {
155
- hmrUpdates: Set<string>;
156
- }
157
- type BuildType = 'build' | 'serve';
158
- type AsyncResult<T> = T | Promise<T>;
159
- //#endregion
160
- //#region src/common/logger.d.ts
161
- declare class Logger {
162
- private readonly scope?;
163
- private static blocked;
164
- private static queuedMessages;
165
- static Colors: {
166
- trace: ChalkInstance;
167
- debug: ChalkInstance;
168
- log: ChalkInstance;
169
- info: ChalkInstance;
170
- warn: ChalkInstance;
171
- error: ChalkInstance;
172
- };
173
- private format;
174
- private debugEnabled;
175
- static block(): void;
176
- static unblock(flush?: boolean): void;
177
- constructor(scope?: string | undefined);
178
- getFormat(): string;
179
- setFormat(format: string): void;
180
- private getTimestamp;
181
- private print;
182
- trace(...args: unknown[]): void;
183
- debug(...args: unknown[]): void;
184
- log(...args: unknown[]): void;
185
- info(...args: unknown[]): void;
186
- warn(...args: unknown[]): void;
187
- error(...args: unknown[]): void;
188
- child(scope: string): Logger;
189
- }
190
- //#endregion
191
- //#region src/server/wss/server.d.ts
192
- type WebSocketClient = ws.WebSocket & {
193
- id: number;
194
- };
195
- //#endregion
196
- //#region src/server/types.d.ts
197
- type FastifyInstance = FastifyInstance$1 & {
198
- use(fn: fastifyMiddie.Handler): FastifyInstance;
199
- use(route: string, fn: fastifyMiddie.Handler): FastifyInstance;
200
- use(routes: string[], fn: fastifyMiddie.Handler): FastifyInstance;
201
- };
202
- interface ServerOptions {
203
- port?: number;
204
- host?: string;
205
- https?: boolean;
206
- key?: string;
207
- cert?: string;
208
- buildOptions?: Pick<BuildOptions, 'cache'>;
209
- }
210
- type DevServerEvents = {
211
- 'device.connected': {
212
- client: WebSocketClient;
213
- };
214
- 'device.message': {
215
- client: WebSocketClient;
216
- data: ws.RawData;
217
- };
218
- 'device.error': {
219
- client: WebSocketClient;
220
- error: Error;
221
- };
222
- 'device.disconnected': {
223
- client: WebSocketClient;
224
- };
225
- };
226
- interface Middlewares {
227
- /**
228
- * Register a middleware to the Fastify instance.
229
- *
230
- * **NOTE**: This is a wrapper of `instance.use`.
231
- */
232
- use: FastifyInstance['use'];
233
- }
234
- interface DevServer extends Emitter<DevServerEvents> {
235
- /**
236
- * Resolved Rollipop config.
237
- */
238
- config: ResolvedConfig;
239
- /**
240
- * The Fastify instance.
241
- */
242
- instance: FastifyInstance;
243
- /**
244
- * `express` and `connect` style middleware registration API.
245
- */
246
- middlewares: Middlewares;
247
- /**
248
- * The message websocket server API.
249
- */
250
- message: ws.Server & {
251
- /**
252
- * Broadcast a message to all connected devices.
253
- */
254
- broadcast: (method: string, params?: Record<string, any>) => void;
255
- };
256
- /**
257
- * The events websocket server API.
258
- */
259
- events: ws.Server & {
260
- /**
261
- * Report an event to the reporter.
262
- */
263
- reportEvent: (event: {
264
- type: string;
265
- [key: string]: unknown;
266
- }) => void;
267
- };
268
- /**
269
- * HMR websocket server API
270
- */
271
- hot: ws.Server & {
272
- send: (client: ws.WebSocket, eventName: string, payload?: unknown) => void;
273
- sendAll: (eventName: string, payload?: unknown) => void;
274
- };
275
- }
276
- interface BundleDetails {
277
- bundleType: string;
278
- dev: boolean;
279
- entryFile: string;
280
- minify: boolean;
281
- platform?: string;
282
- }
283
- interface FormattedError {
284
- type: string;
285
- message: string;
286
- errors: {
287
- description: string;
288
- }[];
289
- }
290
- //#endregion
291
- //#region src/server/create-dev-server.d.ts
292
- declare function createDevServer(config: ResolvedConfig, options?: ServerOptions): Promise<DevServer>;
293
- //#endregion
294
- //#region src/server/constants.d.ts
295
- declare const DEFAULT_PORT = 8081;
296
- declare const DEFAULT_HOST = "localhost";
297
- declare const DEV_SERVER_ASSET_PATH = "assets";
298
- //#endregion
299
- //#region src/core/plugins/context.d.ts
300
- interface PluginContext {
301
- debug: (log: RollupLogWithString) => void;
302
- info: (log: RollupLogWithString) => void;
303
- warn: (log: RollupLogWithString) => void;
304
- }
305
- //#endregion
306
- //#region src/core/plugins/types.d.ts
307
- type PluginConfig = Omit<Config, 'plugins'>;
308
- type ResolvedPluginConfig = Omit<ResolvedConfig, 'plugins'>;
309
- type Plugin = rolldown.Plugin & {
310
- config?: PluginConfig | ((this: PluginContext, config: PluginConfig) => AsyncResult<PluginConfig | null | void>);
311
- configResolved?: (this: PluginContext, config: ResolvedConfig) => AsyncResult<void>;
312
- configureServer?: (this: PluginContext, server: DevServer) => AsyncResult<void | (() => AsyncResult<void>)>;
313
- };
314
- //#endregion
315
- //#region src/node/types.d.ts
316
- interface CommandDefinition<Options> {
317
- name: string;
318
- description: string;
319
- helpText?: string;
320
- options?: CommandOptionDefinition[];
321
- action: CommandAction<Options>;
322
- }
323
- interface CommandAction<Options> {
324
- (this: CommandContext, options: Options): Promise<void>;
325
- }
326
- interface CommandOptionDefinition<T = any> {
327
- name: string;
328
- description: string;
329
- required?: boolean;
330
- default?: T;
331
- parse?: (value: string) => T;
332
- }
333
- interface CommandContext {
334
- platforms: string[];
335
- }
336
- //#endregion
337
- //#region src/node/commands/start/setup-interactive-mode.d.ts
338
- interface InteractiveCommand {
339
- key: string;
340
- shift?: boolean;
341
- description: string | (() => string);
342
- handler: (this: InteractiveCommandContext) => void;
343
- }
344
- interface InteractiveCommandContext {
345
- server: DevServer;
346
- logger: Logger;
347
- }
348
- interface InteractiveModeOptions {
349
- devServer: DevServer;
350
- extraCommands?: InteractiveCommand[];
351
- }
352
- declare function setupInteractiveMode(options: InteractiveModeOptions): void;
353
- //#endregion
354
- //#region src/node/cli-utils.d.ts
355
- declare function createCommand<T>(commandDefinition: CommandDefinition<T>): Command;
356
- declare function createReactNativeCliCommand<T>(commandDefinition: CommandDefinition<T>): Command$1;
357
- //#endregion
358
- //#region src/config/types.d.ts
359
- type RolldownExperimentalOptions = NonNullable<rolldown.InputOptions['experimental']>;
360
- interface Config {
361
- /**
362
- * Defaults to current working directory.
363
- */
364
- root?: string;
365
- /**
366
- * Specifying this in config will override the default mode for both serve and build.
367
- *
368
- * Defaults to: `'development'` for serve, 'production' for build.
369
- */
370
- mode?: 'development' | 'production';
371
- /**
372
- * Defaults to: `index.js`
373
- */
374
- entry?: string;
375
- /**
376
- * Resolver configuration.
377
- */
378
- resolver?: ResolverConfig;
379
- /**
380
- * Transformer configuration.
381
- */
382
- transformer?: TransformerConfig;
383
- /**
384
- * Serializer configuration.
385
- */
386
- serializer?: SerializerConfig;
387
- /**
388
- * Watcher configuration.
389
- */
390
- watcher?: WatcherConfig;
391
- /**
392
- * Optimization configuration.
393
- */
394
- optimization?: OptimizationConfig;
395
- /**
396
- * React Native specific configuration.
397
- */
398
- reactNative?: ReactNativeConfig;
399
- /**
400
- * Terminal configuration.
401
- */
402
- terminal?: TerminalConfig;
403
- /**
404
- * Reporter configuration.
405
- */
406
- reporter?: Reporter;
407
- /**
408
- * Dev mode specific configuration. (for dev server)
409
- */
410
- devMode?: DevModeConfig;
411
- /**
412
- * Directory to load environment variables from.
413
- *
414
- * Defaults to: `root`
415
- */
416
- envDir?: string;
417
- /**
418
- * Base name for environment files.
419
- *
420
- * Acts as the basename of the standard four-file resolution: the loader looks
421
- * for `${envFile}`, `${envFile}.local`, `${envFile}.[mode]`, and
422
- * `${envFile}.[mode].local`. Override this to use a custom name such as
423
- * `.rollipop-env` instead of the default `.env`.
424
- *
425
- * Expects a file name (not a path).
426
- *
427
- * Defaults to: `'.env'`
428
- */
429
- envFile?: string;
430
- /**
431
- * Environment variable prefix.
432
- *
433
- * Defaults to: `'ROLLIPOP_'`
434
- */
435
- envPrefix?: string;
436
- /**
437
- * Configures TypeScript configuration file resolution and usage.
438
- *
439
- * Defaults to: `true`
440
- */
441
- tsconfig?: rolldown.InputOptions['tsconfig'];
442
- /**
443
- * Whether to generate sourcemaps.
444
- *
445
- * - `false`: No sourcemap will be generated.
446
- * - `true`: A separate sourcemap file will be generated.
447
- * - `'inline'`: The sourcemap will be appended to the output file as a data URL.
448
- * - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (//# sourceMappingURL comment) will not be included in the output file.
449
- *
450
- * Defaults to: `true` when in development mode, `false` otherwise.
451
- */
452
- sourcemap?: rolldown.OutputOptions['sourcemap'];
453
- /**
454
- * The base URL for the links to the sourcemap file in the output file.
455
- *
456
- * By default, relative URLs are generated. If this option is set, an absolute URL with that base URL will be generated.
457
- * This is useful when deploying source maps to a different location than your code, such as a CDN or separate debugging server.
458
- */
459
- sourcemapBaseUrl?: rolldown.OutputOptions['sourcemapBaseUrl'];
460
- /**
461
- * Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
462
- *
463
- * When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
464
- *
465
- * Defaults to: `false`
466
- */
467
- sourcemapDebugIds?: rolldown.OutputOptions['sourcemapDebugIds'];
468
- /**
469
- * Control which source files are included in the sourcemap ignore list.
470
- *
471
- * Files in the ignore list are excluded from debugger stepping and error stack traces.
472
- *
473
- * - `false`: Include no source files in the ignore list
474
- * - `true`: Include all source files in the ignore list
475
- * - `string`: Files containing this string in their path will be included in the ignore list
476
- * - `RegExp`: Files matching this regular expression will be included in the ignore list
477
- * - `function`: Custom function to determine if a source should be ignored
478
- *
479
- * :::tip Performance
480
- * Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
481
- * Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
482
- * :::
483
- *
484
- * @example
485
- * ```js
486
- * // ✅ Preferred: Use RegExp for better performance
487
- * sourcemapIgnoreList: /node_modules/
488
- *
489
- * // ✅ Preferred: Use string pattern for better performance
490
- * sourcemapIgnoreList: "vendor"
491
- *
492
- * // ! Use sparingly: Function calls have high overhead
493
- * sourcemapIgnoreList: (source, sourcemapPath) => {
494
- * return source.includes('node_modules') || source.includes('.min.');
495
- * }
496
- * ```
497
- *
498
- * Defaults to: `/node_modules/`
499
- */
500
- sourcemapIgnoreList?: rolldown.OutputOptions['sourcemapIgnoreList'];
501
- /**
502
- * A transformation to apply to each path in a sourcemap.
503
- *
504
- * @example
505
- * ```js
506
- * export default defineConfig({
507
- * output: {
508
- * sourcemap: true,
509
- * sourcemapPathTransform: (source, sourcemapPath) => {
510
- * // Remove 'src/' prefix from all source paths
511
- * return source.replace(/^src\//, '');
512
- * },
513
- * },
514
- * });
515
- * ```
516
- */
517
- sourcemapPathTransform?: rolldown.OutputOptions['sourcemapPathTransform'];
518
- /**
519
- * Plugins to apply to the build.
520
- */
521
- plugins?: PluginOption;
522
- /**
523
- * Internal option to specify the runtime target.
524
- *
525
- * Defaults to 'hermes-v1'.
526
- */
527
- runtimeTarget?: 'hermes' | 'hermes-v1';
528
- /**
529
- * Experimental options. Behaviour and shape may change between releases
530
- * without a major version bump.
531
- */
532
- experimental?: ExperimentalConfig;
533
- /**
534
- * Rollipop provides default options for Rolldown, but you can override them by this option.
535
- *
536
- * **DANGEROUS**: This option is dangerous because it can break the build.
537
- */
538
- dangerously_overrideRolldownOptions?: RolldownConfig | ((config: RolldownConfig) => RolldownConfig) | ((config: RolldownConfig) => Promise<RolldownConfig>);
539
- }
540
- type PluginOption = MaybePromise<NullValue<Plugin> | {
541
- name: string;
542
- } | false | PluginOption[]>;
543
- type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'extensions'> & {
544
- /**
545
- * Defaults to: `['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json']`
546
- */
547
- sourceExtensions?: string[];
548
- /**
549
- * Defaults to images (`bmp`, `gif`, `jpg`, `jpeg`, `png`, `psd`, `svg`, `webp`, `xml`),
550
- * video (`m4v`, `mov`, `mp4`, `mpeg`, `mpg`, `webm`), audio (`aac`, `aiff`, `caf`, `m4a`,
551
- * `mp3`, `wav`), documents (`html`, `pdf`, `yaml`, `yml`), fonts (`otf`, `ttf`), and
552
- * archives (`zip`).
553
- */
554
- assetExtensions?: string[];
555
- /**
556
- * If `true`, resolver will resolve `native` suffixed files.
557
- *
558
- * e.g.
559
- * - **true**: `index.android` -> `index.native` -> `index`
560
- * - **false**: `index.android` -> `index`
561
- *
562
- * Defaults to: `true`
563
- */
564
- preferNativePlatform?: boolean;
565
- /**
566
- * Specifies which modules should be treated as external and not bundled.
567
- *
568
- * External modules will be left as import statements in the output.
569
- */
570
- external?: rolldown.InputOptions['external'];
571
- };
572
- type TransformerConfig = Omit<TransformOptions, 'cwd' | 'lang' | 'sourceType' | 'plugins'> & {
573
- /**
574
- * Flow specific configuration.
575
- *
576
- * Only applied when `experimental.nativeTransformPipeline` is **disabled** (the
577
- * default). With the native pipeline enabled, the rust-side plugin
578
- * handles Flow stripping internally.
579
- */
580
- flow?: FlowConfig;
581
- /**
582
- * Babel transformation configuration.
583
- */
584
- babel?: BabelTransformConfig;
585
- /**
586
- * SWC transformation configuration.
587
- */
588
- swc?: SwcTransformConfig;
589
- };
590
- type BabelTransformConfig = {
591
- rules?: TransformRule<babel.TransformOptions>[];
592
- };
593
- type SwcTransformConfig = {
594
- rules?: TransformRule<swc.Options>[];
595
- };
596
- interface TransformRule<T = unknown> {
597
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
598
- options: T | ((code: string, id: string) => T);
599
- }
600
- interface FlowConfig {
601
- /**
602
- * Filter for Flow transformation pipeline.
603
- */
604
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
605
- }
606
- interface ExperimentalConfig {
607
- /**
608
- * Enables the native (rust) transform pipeline, which replaces the
609
- * legacy JS-side codegen marker, Flow strip, and SWC/babel preset
610
- * machinery with a single built-in `rollipopReactNativePlugin`.
611
- *
612
- * This is a breaking change for projects that customised the legacy
613
- * pipeline via `transformer.flow.filter`, `reactNative.codegen.filter`,
614
- * or `runtimeTarget`. Opt in once you have validated builds locally.
615
- *
616
- * Defaults to `false`.
617
- */
618
- nativeTransformPipeline?: boolean;
619
- /**
620
- * Flow handling configuration for the native transform pipeline.
621
- *
622
- * Only applied when `experimental.nativeTransformPipeline` is enabled.
623
- */
624
- flow?: RollipopReactNativeFlowConfig;
625
- /**
626
- * `react-native-worklets` transformation configuration.
627
- *
628
- * Only applied when `experimental.nativeTransformPipeline` is enabled.
629
- */
630
- worklets?: RollipopReactNativeWorkletsConfig;
631
- }
632
- interface SerializerConfig {
633
- /**
634
- * Paths to prelude files.
635
- *
636
- * Prelude files are imported in the top of the entry module.
637
- */
638
- prelude?: string[];
639
- /**
640
- * Polyfills to include in the output bundle.
641
- *
642
- * Polyfills are injected in the top of the output bundle.
643
- */
644
- polyfills?: Polyfill[];
645
- /**
646
- * A string to prepend to the bundle before `renderChunk` hook.
647
- */
648
- banner?: rolldown.OutputOptions['banner'];
649
- /**
650
- * A string to append to the bundle before `renderChunk` hook.
651
- */
652
- footer?: rolldown.OutputOptions['footer'];
653
- /**
654
- * A string to prepend to the bundle after `renderChunk` hook and minification.
655
- */
656
- postBanner?: rolldown.OutputOptions['postBanner'];
657
- /**
658
- * A string to append to the bundle after `renderChunk` hook and minification.
659
- */
660
- postFooter?: rolldown.OutputOptions['postFooter'];
661
- /**
662
- * A string to prepend inside any format-specific wrapper.
663
- */
664
- intro?: rolldown.OutputOptions['intro'];
665
- /**
666
- * A string to append inside any format-specific wrapper.
667
- */
668
- outro?: rolldown.OutputOptions['outro'];
669
- /**
670
- * When `true`, creates shim variables for missing exports instead of throwing an error.
671
- *
672
- * Defaults to: `false`
673
- */
674
- shimMissingExports?: rolldown.InputOptions['shimMissingExports'];
675
- }
676
- type Polyfill = string | PolyfillWithCode | PolyfillWithPath;
677
- type PolyfillWithCode = {
678
- type: PolyfillType;
679
- code: string;
680
- };
681
- type PolyfillWithPath = {
682
- type: PolyfillType;
683
- path: string;
684
- };
685
- type PolyfillType = 'plain' | 'iife';
686
- type OptimizationConfig = rolldown.OptimizationOptions & {
687
- /**
688
- * Controls tree-shaking (dead code elimination).
689
- *
690
- * When `false`, tree-shaking will be disabled. When `true`, it is equivalent to setting each options to the default value.
691
- *
692
- * Defaults to: `true`
693
- */
694
- treeshake?: rolldown.InputOptions['treeshake'];
695
- /**
696
- * Control code minification.
697
- *
698
- * - `true`: Enable full minification including code compression and dead code elimination
699
- * - `false`: Disable minification (default)
700
- * - `'dce-only'`: Only perform dead code elimination without code compression
701
- * - `MinifyOptions`: Fine-grained control over minification settings
702
- *
703
- * Defaults to: `false`
704
- */
705
- minify?: rolldown.OutputOptions['minify'];
706
- /**
707
- * Control whether to enable lazy barrel optimization.
708
- *
709
- * Lazy barrel optimization avoids compiling unused re-export modules in side-effect-free barrel modules,
710
- * significantly improving build performance for large codebases with many barrel modules.
711
- *
712
- * Defaults to: `false`
713
- *
714
- * @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
715
- */
716
- lazyBarrel?: RolldownExperimentalOptions['lazyBarrel'];
717
- };
718
- type WatcherConfig = DevWatchOptions;
719
- interface DevModeConfig {
720
- /**
721
- * Hot Module Replacement configurations.
722
- * This feature is only available in `development` mode.
723
- *
724
- * Defaults to `true`.
725
- */
726
- hmr?: boolean | HmrConfig;
727
- }
728
- interface HmrConfig {
729
- /**
730
- * Source code of the HMR runtime implementation.
731
- *
732
- * Defaults to: using `rollipop/hmr-runtime` as a default implementation.
733
- */
734
- runtimeImplement?: string;
735
- /**
736
- * Source code of the HMR client implementation.
737
- *
738
- * Defaults to: using `rollipop/hmr-client` as a default implementation.
739
- */
740
- clientImplement?: string;
741
- }
742
- interface ReactNativeConfig {
743
- /**
744
- * Path to React Native package.
745
- *
746
- * Defaults to: resolving `react-native` package from `projectRoot`.
747
- */
748
- reactNativePath?: string;
749
- /**
750
- * Codegen specific configuration.
751
- *
752
- * Only applied when `experimental.nativeTransformPipeline` is **disabled** (the
753
- * default). With the native pipeline enabled, the rust-side plugin
754
- * handles codegen marking internally.
755
- */
756
- codegen?: CodegenConfig;
757
- /**
758
- * Path to asset registry file.
759
- *
760
- * Defaults to: `react-native/Libraries/Image/AssetRegistry.js`
761
- */
762
- assetRegistryPath?: string | ((root: string) => MaybePromise<string>);
763
- /**
764
- * Path to HMR client file.
765
- *
766
- * Defaults to: `react-native/Libraries/Utilities/HMRClient.js`
767
- */
768
- hmrClientPath?: string | ((root: string) => MaybePromise<string>);
769
- /**
770
- * Reserved global identifiers of React Native.
771
- *
772
- * Defaults to: Global identifier list of React Native 0.83
773
- */
774
- globalIdentifiers?: string[];
775
- }
776
- interface CodegenConfig {
777
- /**
778
- * Filter for codegen transformation pipeline.
779
- */
780
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
781
- }
782
- interface TerminalConfig {
783
- /**
784
- * Status of the terminal.
785
- *
786
- * Defaults to: `process.stderr.isTTY ? 'progress' : 'compat'`
787
- */
788
- status?: 'none' | 'compat' | 'progress';
789
- /**
790
- * Extra commands to display in the interactive mode.
791
- */
792
- extraCommands?: InteractiveCommand[];
793
- }
794
- interface RolldownConfig {
795
- input?: rolldown.InputOptions;
796
- output?: rolldown.OutputOptions;
797
- }
798
- //#endregion
799
- //#region src/config/merge-config.d.ts
800
- type PluginFlattenConfig = Omit<Config, 'plugins'> & {
801
- plugins?: Plugin[];
802
- };
803
- declare function mergeConfig(baseConfig: PluginFlattenConfig, ...overrideConfigs: PluginFlattenConfig[]): Config;
804
- declare function mergeConfig(baseConfig: DefaultConfig, ...overrideConfigs: PluginFlattenConfig[]): ResolvedConfig;
805
- //#endregion
806
- //#region src/config/defaults.d.ts
807
- declare function getDefaultConfig(projectRoot: string, mode?: Config['mode']): Promise<{
808
- root: string;
809
- mode: "development" | "production";
810
- entry: string;
811
- resolver: {
812
- sourceExtensions: string[];
813
- assetExtensions: string[];
814
- mainFields: string[];
815
- aliasFields: string[][];
816
- conditionNames: string[];
817
- preferNativePlatform: true;
818
- symlinks: true;
819
- };
820
- transformer: {
821
- flow: {
822
- filter: {
823
- id: RegExp;
824
- code: RegExp;
825
- };
826
- };
827
- };
828
- serializer: {
829
- prelude: string[];
830
- polyfills: {
831
- type: "iife";
832
- code: string;
833
- }[];
834
- };
835
- watcher: {
836
- skipWrite: true;
837
- useDebounce: true;
838
- debounceDuration: number;
839
- };
840
- optimization: {
841
- treeshake: NonNullable<OptimizationConfig["treeshake"]>;
842
- };
843
- reactNative: {
844
- reactNativePath: string;
845
- codegen: {
846
- /**
847
- * @see {@link https://github.com/facebook/react-native/blob/v0.83.1/packages/react-native-babel-preset/src/configs/main.js#L78}
848
- */
849
- filter: {
850
- code: RegExp;
851
- };
852
- };
853
- assetRegistryPath: NonNullable<NonNullable<ReactNativeConfig>["assetRegistryPath"]>;
854
- hmrClientPath: NonNullable<NonNullable<ReactNativeConfig>["hmrClientPath"]>;
855
- globalIdentifiers: string[];
856
- };
857
- devMode: {
858
- hmr: NonNullable<DevModeConfig["hmr"]>;
859
- };
860
- reporter: Reporter;
861
- terminal: {
862
- status: "none" | "compat" | "progress" | undefined;
863
- };
864
- envDir: string;
865
- envFile: string;
866
- envPrefix: string;
867
- runtimeTarget: "hermes-v1";
868
- experimental: {
869
- nativeTransformPipeline: boolean;
870
- };
871
- }>;
872
- type DefaultConfig = Awaited<ReturnType<typeof getDefaultConfig>>;
873
- type ResolvedConfig = DefaultConfig & PluginFlattenConfig;
874
- //#endregion
875
- //#region src/config/define-config.d.ts
876
- interface DefineConfigContext {
877
- command?: string;
878
- defaultConfig: DefaultConfig;
879
- }
880
- type UserConfig = Config | DynamicUserConfig;
881
- type DynamicUserConfig = ((context: DefineConfigContext) => Config) | ((context: DefineConfigContext) => Promise<Config>);
882
- declare function defineConfig(userConfig: UserConfig): UserConfig;
883
- //#endregion
884
- //#region src/config/load-config.d.ts
885
- interface LoadConfigOptions {
886
- cwd?: string;
887
- configFile?: string;
888
- mode?: Config['mode'];
889
- context?: Omit<DefineConfigContext, 'defaultConfig'>;
890
- }
891
- declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
892
- declare function flattenPluginOption(pluginOption: PluginOption): Promise<Plugin[]>;
893
- declare function resolvePluginConfig(baseConfig: ResolvedConfig, plugins: Plugin[]): Promise<ResolvedPluginConfig>;
894
- declare function resolvePluginConfig(baseConfig: Config, plugins: Plugin[]): Promise<PluginConfig>;
895
- declare function invokeConfigResolved(config: ResolvedConfig, plugins: Plugin[]): Promise<void>;
896
- //#endregion
897
- //#region src/utils/reset-cache.d.ts
898
- /**
899
- * Remove the entire build cache directory for the given project root.
900
- * Backs the `/reset-cache` control endpoint, the `reset_cache` MCP tool,
901
- * and the `--reset-cache` CLI flag.
902
- */
903
- declare function resetCache(projectRoot: string): void;
904
- //#endregion
905
- //#region src/utils/run-build.d.ts
906
- declare function runBuild(config: ResolvedConfig, options: BuildOptions): Promise<rolldown.OutputChunk>;
907
- //#endregion
908
- //#region src/utils/run-server.d.ts
909
- declare function runServer(config: ResolvedConfig, options: ServerOptions): Promise<DevServer>;
910
- //#endregion
911
- //#region src/core/bundler.d.ts
912
- declare class Bundler {
913
- private readonly config;
914
- static devEngine(config: ResolvedConfig, buildOptions: Omit<BuildOptions, 'dev' | 'outfile'>, devEngineOptions: DevEngineOptions): Promise<DevEngine>;
915
- static createId(config: ResolvedConfig, buildOptions: BuildOptions): string;
916
- private static createContext;
917
- constructor(config: ResolvedConfig);
918
- build(buildOptions: BuildOptions): Promise<rolldown.OutputChunk>;
919
- }
920
- //#endregion
921
- //#region src/core/plugins/react-native-plugin.d.ts
922
- interface ReactNativePluginOptions {
923
- projectRoot: string;
924
- platform: string;
925
- preferNativePlatform: boolean;
926
- buildType: BuildType;
927
- assetsDir?: string;
928
- assetExtensions: string[];
929
- assetRegistryPath: string;
930
- /**
931
- * Native pipeline configuration. When `null`, the legacy JS plugins
932
- * (codegen marker + Flow strip) are installed instead.
933
- *
934
- * @internal builtin plugin config
935
- */
936
- builtinPluginConfig: RollipopReactNativePluginConfig | null;
937
- /**
938
- * Filter for the legacy Flow-strip transform pipeline. Used when the
939
- * native pipeline is disabled.
940
- */
941
- flowFilter: rolldown.HookFilter | TopLevelFilterExpression[];
942
- /**
943
- * Filter for the legacy codegen marker pipeline. Used when the native
944
- * pipeline is disabled.
945
- */
946
- codegenFilter: rolldown.HookFilter | TopLevelFilterExpression[];
947
- }
948
- declare function reactNativePlugin(options: ReactNativePluginOptions): rolldown.Plugin[];
949
- //#endregion
950
- //#region src/core/plugins/prelude-plugin.d.ts
951
- interface PreludePluginOptions {
952
- modulePaths: string[];
953
- }
954
- declare function preludePlugin(options: PreludePluginOptions): rolldown.Plugin | null;
955
- //#endregion
956
- //#region src/core/plugins/json-plugin.d.ts
957
- declare function jsonPlugin(): rolldown.Plugin;
958
- //#endregion
959
- //#region src/core/plugins/babel-plugin.d.ts
960
- interface BabelPluginOptions {
961
- /**
962
- * When `false`, the legacy JS preset (TS strip / Flow strip / RN
963
- * codegen) is applied. When `true`, the preset is skipped and only
964
- * user-provided rules run — the rust-side pipeline handles the rest.
965
- */
966
- useNativeTransformPipeline: boolean;
967
- transformConfig?: TransformerConfig['babel'];
968
- }
969
- declare function babelPlugin({
970
- useNativeTransformPipeline,
971
- transformConfig
972
- }: BabelPluginOptions): rolldown.Plugin[];
973
- //#endregion
974
- //#region src/core/plugins/swc-plugin.d.ts
975
- interface SwcPluginOptions {
976
- /**
977
- * When `false`, the legacy JS preset for the resolved `runtimeTarget`
978
- * is applied to every module (TS/JSX strip, hermes target). When
979
- * `true`, the preset is skipped and only user-provided rules run — the
980
- * rust-side pipeline handles the rest.
981
- */
982
- useNativeTransformPipeline: boolean;
983
- runtimeTarget: ResolvedConfig['runtimeTarget'];
984
- transformConfig?: TransformerConfig['swc'];
985
- }
986
- declare function swcPlugin({
987
- useNativeTransformPipeline,
988
- runtimeTarget,
989
- transformConfig
990
- }: SwcPluginOptions): rolldown.Plugin[];
991
- //#endregion
992
- //#region src/core/plugins/reporter-plugin.d.ts
993
- interface ReporterPluginOptions {
994
- initialTotalModules?: number;
995
- reporter?: Reporter;
996
- }
997
- declare function reporterPlugin(options?: ReporterPluginOptions): rolldown.Plugin | null;
998
- //#endregion
999
- //#region src/utils/config.d.ts
1000
- type ResolvedHmrConfig = Required<HmrConfig>;
1001
- //#endregion
1002
- //#region src/core/plugins/dev-server-plugin.d.ts
1003
- interface DevServerPluginOptions {
1004
- cwd: string;
1005
- hmrClientPath: ResolvedConfig['reactNative']['hmrClientPath'];
1006
- hmrConfig: ResolvedHmrConfig | null;
1007
- }
1008
- declare function devServerPlugin(options: DevServerPluginOptions): Promise<rolldown.Plugin[] | null>;
1009
- declare namespace index_d_exports {
1010
- export { BabelPluginOptions, DevServerPluginOptions, PreludePluginOptions, ReactNativePluginOptions, ReporterPluginOptions, SwcPluginOptions, babelPlugin as babel, devServerPlugin as devServer, jsonPlugin as json, preludePlugin as prelude, reactNativePlugin as reactNative, reporterPlugin as reporter, swcPlugin as swc };
1011
- }
1012
- declare namespace assets_d_exports {
1013
- export { AssetContext, AssetData, AssetDataFiltered, AssetDataWithoutFiles, AssetInfo, AssetScale, copyAssetsToDestination, generateAssetRegistryCode, getAssetPriority, getSuffixedPath, platformSuffixPattern, resolveAssetPath, resolveScaledAssets, stripSuffix };
1014
- }
1015
- /**
1016
- * **NOTE**: Type definitions are ported from `metro` implementation.
1017
- *
1018
- * @see https://github.com/facebook/metro/blob/0.81.x/packages/metro/src/Assets.js
1019
- */
1020
- interface AssetContext {
1021
- platform: string;
1022
- preferNativePlatform: boolean;
1023
- }
1024
- interface AssetInfo {
1025
- files: string[];
1026
- hash: string;
1027
- name: string;
1028
- scales: number[];
1029
- type: string;
1030
- }
1031
- interface AssetDataWithoutFiles {
1032
- __packager_asset: boolean;
1033
- fileSystemLocation: string;
1034
- hash: string;
1035
- httpServerLocation: string;
1036
- name: string;
1037
- scales: AssetScale[];
1038
- type: string;
1039
- width?: number;
1040
- height?: number;
1041
- }
1042
- interface AssetDataFiltered {
1043
- __packager_asset: boolean;
1044
- hash: string;
1045
- httpServerLocation: string;
1046
- name: string;
1047
- scales: AssetScale[];
1048
- type: string;
1049
- width?: number;
1050
- height?: number;
1051
- }
1052
- interface AssetData extends AssetDataWithoutFiles {
1053
- id: string;
1054
- files: string[];
1055
- }
1056
- type AssetScale = 0.75 | 1 | 1.5 | 2 | 3;
1057
- interface ResolveScaledAssetsOptions {
1058
- projectRoot: string;
1059
- assetPath: string;
1060
- platform: string;
1061
- preferNativePlatform: boolean;
1062
- }
1063
- declare function resolveScaledAssets(options: ResolveScaledAssetsOptions): Promise<AssetData>;
1064
- declare function platformSuffixPattern(context: AssetContext): string;
1065
- declare function stripSuffix(assetPath: string, context: AssetContext): string;
1066
- declare function getAssetPriority(assetPath: string, context: AssetContext): 0 | 3 | 2 | 1;
1067
- interface GetSuffixedPathOptions {
1068
- scale?: AssetScale;
1069
- platform?: string;
1070
- }
1071
- /**
1072
- * add suffix to asset path
1073
- *
1074
- * ```js
1075
- * // assetPath input
1076
- * '/path/to/assets/image.png'
1077
- *
1078
- * // `platform` suffixed
1079
- * '/path/to/assets/image.android.png'
1080
- *
1081
- * // `scale` suffixed
1082
- * '/path/to/assets/image@1x.png'
1083
- *
1084
- * // both `platform` and `scale` suffixed
1085
- * '/path/to/assets/image@1x.android.png'
1086
- * ```
1087
- */
1088
- declare function getSuffixedPath(assetPath: string, context: AssetContext, options: GetSuffixedPathOptions): string;
1089
- declare function resolveAssetPath(assetPath: string, context: AssetContext, scale: AssetScale): string;
1090
- interface CopyAssetsToDestinationOptions {
1091
- assets: AssetData[];
1092
- assetsDir: string;
1093
- platform: string;
1094
- preferNativePlatform: boolean;
1095
- }
1096
- /**
1097
- * @see https://github.com/facebook/react-native/blob/0.83-stable/packages/community-cli-plugin/src/commands/bundle/assetPathUtils.js
1098
- */
1099
- declare function copyAssetsToDestination(options: CopyAssetsToDestinationOptions): Promise<undefined>;
1100
- declare function generateAssetRegistryCode(assetRegistryPath: string, asset: AssetData): string;
1101
- //#endregion
1102
- //#region src/core/env.d.ts
1103
- interface LoadEnvOptions {
1104
- envDir: string;
1105
- envPrefix: string;
1106
- envFile: string;
1107
- mode?: Config['mode'];
1108
- }
1109
- declare function loadEnv(options: LoadEnvOptions): Record<string, string>;
1110
- declare namespace constants_d_exports {
1111
- export { DEFAULT_ASSET_EXTENSIONS, DEFAULT_ASSET_REGISTRY_PATH, DEFAULT_ENV_FILE, DEFAULT_ENV_PREFIX, DEFAULT_HMR_CLIENT_PATH, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_REACT_NATIVE_GLOBAL_IDENTIFIERS, DEFAULT_RESOLVER_ALIAS_FIELDS, DEFAULT_RESOLVER_CONDITION_NAMES, DEFAULT_RESOLVER_MAIN_FIELDS, DEFAULT_RUNTIME_TARGET, DEFAULT_SOURCE_EXTENSIONS, GLOBAL_IDENTIFIER, IMAGE_EXTENSIONS, ROLLIPOP_VERSION };
1112
- }
1113
- /**
1114
- * @see `tsdown.config.ts`
1115
- */
1116
- declare global {
1117
- var __ROLLIPOP_VERSION__: string;
1118
- }
1119
- declare const ROLLIPOP_VERSION: string;
1120
- declare const GLOBAL_IDENTIFIER = "global";
1121
- /**
1122
- * @see {@link https://github.com/facebook/metro/blob/0.81.x/docs/Configuration.md#resolvermainfields}
1123
- */
1124
- declare const DEFAULT_RESOLVER_MAIN_FIELDS: string[];
1125
- declare const DEFAULT_RESOLVER_ALIAS_FIELDS: string[][];
1126
- declare const DEFAULT_RESOLVER_CONDITION_NAMES: string[];
1127
- /**
1128
- * Unlike the Metro bundler configuration, this prioritizes resolving TypeScript and ESM first.
1129
- *
1130
- * @see {@link https://github.com/facebook/metro/blob/0.81.x/packages/metro-config/src/defaults/defaults.js}
1131
- * @see {@link https://github.com/facebook/metro/blob/0.81.x/packages/metro-file-map/src/workerExclusionList.js}
1132
- */
1133
- declare const DEFAULT_SOURCE_EXTENSIONS: string[];
1134
- declare const DEFAULT_IMAGE_EXTENSIONS: string[];
1135
- declare const IMAGE_EXTENSIONS: string[];
1136
- declare const DEFAULT_ASSET_EXTENSIONS: string[];
1137
- declare const DEFAULT_ASSET_REGISTRY_PATH = "react-native/Libraries/Image/AssetRegistry.js";
1138
- declare const DEFAULT_HMR_CLIENT_PATH = "react-native/Libraries/Utilities/HMRClient.js";
1139
- declare const DEFAULT_REACT_NATIVE_GLOBAL_IDENTIFIERS: string[];
1140
- declare const DEFAULT_ENV_PREFIX = "ROLLIPOP_";
1141
- declare const DEFAULT_ENV_FILE = ".env";
1142
- declare const DEFAULT_RUNTIME_TARGET = "hermes-v1";
1143
- //#endregion
1144
- //#region src/types/hmr.d.ts
1145
- interface HMRContext {
1146
- accept(...args: any[]): void;
1147
- invalidate(): void;
1148
- on(event: string, listener: (...args: any[]) => void): void;
1149
- off(event: string, listener: (...args: any[]) => void): void;
1150
- send(type: string, payload?: unknown): void;
1151
- }
1152
- type HMRClientLogLevel = 'trace' | 'info' | 'warn' | 'error' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';
1153
- type HMRClientMessage = {
1154
- type: 'hmr:connected';
1155
- bundleEntry: string;
1156
- platform: string;
1157
- } | {
1158
- type: 'hmr:module-registered';
1159
- modules: string[];
1160
- } | {
1161
- type: 'hmr:log';
1162
- level: HMRClientLogLevel;
1163
- data: any[];
1164
- } | {
1165
- type: 'hmr:invalidate';
1166
- moduleId: string;
1167
- };
1168
- type HMRServerMessage = {
1169
- type: 'hmr:update-start';
1170
- } | {
1171
- type: 'hmr:update-done';
1172
- } | {
1173
- type: 'hmr:update';
1174
- code: string;
1175
- } | {
1176
- type: 'hmr:reload';
1177
- } | {
1178
- type: 'hmr:error';
1179
- payload: HMRServerError;
1180
- };
1181
- type HMRCustomMessage = {
1182
- type: string;
1183
- payload: unknown;
1184
- };
1185
- type HMRCustomHandler = (socket: WebSocket, message: HMRCustomMessage) => void;
1186
- interface HMRServerError {
1187
- type: string;
1188
- message: string;
1189
- errors: {
1190
- description: string;
1191
- }[];
1192
- }
1193
- interface DevRuntimeModule {
1194
- exportsHolder: {
1195
- exports: any;
1196
- };
1197
- id: string;
1198
- exports: any;
1199
- }
1200
- interface DevRuntimeInterface {
1201
- modules: Record<string, DevRuntimeModule>;
1202
- createModuleHotContext(moduleId: string): void;
1203
- applyUpdates(boundaries: [string, string][]): void;
1204
- registerModule(id: string, exportsHolder: DevRuntimeModule['exportsHolder']): void;
1205
- loadExports(id: string): void;
1206
- }
1207
- declare class DevRuntime implements DevRuntimeInterface {
1208
- constructor(messenger: DevRuntimeMessenger);
1209
- modules: Record<string, DevRuntimeModule>;
1210
- createModuleHotContext(moduleId: string): void;
1211
- applyUpdates(boundaries: [string, string][]): void;
1212
- registerModule(id: string, exportsHolder: DevRuntimeModule['exportsHolder']): void;
1213
- loadExports(id: string): void;
1214
- }
1215
- interface DevRuntimeMessenger {
1216
- send(message: HMRClientMessage): void;
1217
- }
1218
- declare namespace cli_d_exports {
1219
- export { run };
1220
- }
1221
- declare function run(argv: string[]): void;
1222
- //#endregion
1223
- export { assets_d_exports as AssetUtils, AsyncResult, BabelTransformConfig, BuildOptions, BuildType, BundleDetails, Bundler, BundlerContext, BundlerState, CodegenConfig, Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, DeepRequired, DefaultConfig, DefineConfigContext, DevEngine, DevEngineOptions, DevModeConfig, type DevRuntime, DevRuntimeInterface, DevRuntimeMessenger, DevRuntimeModule, DevServer, DevServerEvents, DynamicUserConfig, ExperimentalConfig, FastifyInstance, FlowConfig, FormattedError, HMRClientLogLevel, HMRClientMessage, HMRContext, HMRCustomHandler, HMRCustomMessage, HMRServerError, HMRServerMessage, HmrConfig, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, LoadConfigOptions, LoadEnvOptions, MaybePromise, Middlewares, NullValue, OptimizationConfig, PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, PluginOption, Polyfill, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ReportableEvent, Reporter, ResolvedConfig, ResolverConfig, RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, SerializerConfig, ServerOptions, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, UserConfig, WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, runBuild, runServer, setupInteractiveMode };
26
+ export { assets_d_exports as AssetUtils, type AsyncResult, type BabelTransformConfig, type BuildDiagnosticLog, type BuildOptions, type BuildType, type BundleDetails, Bundler, type BundlerContext, type BundlerState, type CodegenConfig, type Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, type DeepRequired, DefaultConfig, DefineConfigContext, type DevEngine, type DevEngineOptions, type DevModeConfig, type DevRuntime, type DevRuntimeInterface, type DevRuntimeMessenger, type DevRuntimeModule, type DevServer, type DevServerContext, type DevServerEvents, DynamicUserConfig, type ExperimentalConfig, type FastifyInstance, type FlowConfig, type FormattedError, type HMRClientLogLevel, type HMRClientMessage, type HMRContext, type HMRCustomHandler, type HMRCustomMessage, type HMRServerError, type HMRServerMessage, type HmrConfig, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, LoadConfigOptions, LoadEnvOptions, type MaybePromise, type MetroCompatibleClientLogEvent, type Middlewares, type NullValue, type OptimizationConfig, type PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, type PluginOption, type Polyfill, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ReportableEvent, type Reporter, ResolvedConfig, type ResolverConfig, type RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, type SerializerConfig, type ServerOptions, type SwcTransformConfig, type TerminalConfig, type TransformRule, type TransformerConfig, UserConfig, type WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, runBuild, runServer, setupInteractiveMode };