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
@@ -0,0 +1,73 @@
1
+ import { getDefaultConfig } from "./defaults.js";
2
+ import { createPluginContext } from "../core/plugins/context.js";
3
+ import { mergeConfig } from "./merge-config.js";
4
+ import path from "node:path";
5
+ import { omit } from "es-toolkit";
6
+ import * as c12 from "c12";
7
+ //#region src/config/load-config.ts
8
+ const CONFIG_FILE_NAME = "rollipop";
9
+ const INTERNAL_PLUGIN_HOOKS = ["transformCacheHit"];
10
+ async function loadConfig(options = {}) {
11
+ const { cwd = process.cwd(), configFile, mode, context = {} } = options;
12
+ const defaultConfig = await getDefaultConfig(cwd, mode);
13
+ const commonOptions = {
14
+ context: {
15
+ ...context,
16
+ defaultConfig
17
+ },
18
+ rcFile: false
19
+ };
20
+ const { config: userConfig } = await c12.loadConfig(configFile ? {
21
+ configFile: path.resolve(cwd, configFile),
22
+ configFileRequired: true
23
+ } : {
24
+ cwd,
25
+ defaultConfig,
26
+ name: CONFIG_FILE_NAME,
27
+ ...commonOptions
28
+ });
29
+ const plugins = await flattenPluginOption(userConfig.plugins);
30
+ const resolvedConfig = {
31
+ ...await resolvePluginConfig(mergeConfig(defaultConfig, {
32
+ ...userConfig,
33
+ plugins
34
+ }), plugins),
35
+ plugins
36
+ };
37
+ if (!path.isAbsolute(resolvedConfig.entry)) resolvedConfig.entry = path.resolve(resolvedConfig.root, resolvedConfig.entry);
38
+ await invokeConfigResolved(resolvedConfig, plugins);
39
+ return resolvedConfig;
40
+ }
41
+ async function flattenPluginOption(pluginOption) {
42
+ const awaitedPluginOption = await pluginOption;
43
+ if (Array.isArray(awaitedPluginOption)) return (await Promise.all(awaitedPluginOption.map(flattenPluginOption))).flat();
44
+ if (awaitedPluginOption == null || awaitedPluginOption === false) return [];
45
+ return [stripInternalPluginHooks(awaitedPluginOption)];
46
+ }
47
+ function stripInternalPluginHooks(plugin) {
48
+ const maybeInternalPlugin = plugin;
49
+ if (!INTERNAL_PLUGIN_HOOKS.some((hook) => hook in maybeInternalPlugin)) return plugin;
50
+ return omit(maybeInternalPlugin, INTERNAL_PLUGIN_HOOKS);
51
+ }
52
+ async function resolvePluginConfig(baseConfig, plugins) {
53
+ let mergedConfig = omit(baseConfig, ["plugins"]);
54
+ for (const plugin of plugins) {
55
+ const context = createPluginContext(plugin.name);
56
+ const overrideBefore = mergedConfig.dangerously_overrideRolldownOptions;
57
+ if (typeof plugin.config === "function") {
58
+ const config = await plugin.config.call(context, mergedConfig);
59
+ if (config != null) mergedConfig = mergeConfig(mergedConfig, config);
60
+ } else if (typeof plugin.config === "object") mergedConfig = mergeConfig(mergedConfig, plugin.config);
61
+ const overrideAfter = mergedConfig.dangerously_overrideRolldownOptions;
62
+ if (overrideAfter != null && overrideAfter !== overrideBefore) context.debug({ message: `set 'dangerously_overrideRolldownOptions'` });
63
+ }
64
+ return mergedConfig;
65
+ }
66
+ async function invokeConfigResolved(config, plugins) {
67
+ await Promise.all(plugins.map((plugin) => {
68
+ const context = createPluginContext(plugin.name);
69
+ return Promise.resolve(plugin.configResolved?.call(context, config));
70
+ }));
71
+ }
72
+ //#endregion
73
+ export { flattenPluginOption, invokeConfigResolved, loadConfig, resolvePluginConfig };
@@ -0,0 +1,12 @@
1
+ import { Plugin } from "../core/plugins/types.js";
2
+ import { Config } from "./types.js";
3
+ import { DefaultConfig, ResolvedConfig } from "./defaults.js";
4
+
5
+ //#region src/config/merge-config.d.ts
6
+ type PluginFlattenConfig = Omit<Config, 'plugins'> & {
7
+ plugins?: Plugin[];
8
+ };
9
+ declare function mergeConfig(baseConfig: PluginFlattenConfig, ...overrideConfigs: PluginFlattenConfig[]): Config;
10
+ declare function mergeConfig(baseConfig: DefaultConfig, ...overrideConfigs: PluginFlattenConfig[]): ResolvedConfig;
11
+ //#endregion
12
+ export { PluginFlattenConfig, mergeConfig };
@@ -0,0 +1,20 @@
1
+ import { composeOverrideRolldownOptions } from "./compose-override.js";
2
+ import { mergeWith } from "es-toolkit";
3
+ //#region src/config/merge-config.ts
4
+ function mergeConfig(baseConfig, ...overrideConfigs) {
5
+ let mergedConfig = baseConfig;
6
+ for (const overrideConfig of overrideConfigs) mergedConfig = mergeWith(mergedConfig, overrideConfig, (target, source, key) => {
7
+ if ([
8
+ "sourceExtensions",
9
+ "assetExtensions",
10
+ "polyfills",
11
+ "prelude",
12
+ "plugins"
13
+ ].includes(key)) return Array.from(new Set([...target ?? [], ...source ?? []]));
14
+ if (key === "reporter") return source ?? target;
15
+ if (key === "dangerously_overrideRolldownOptions") return composeOverrideRolldownOptions(target, source);
16
+ });
17
+ return mergedConfig;
18
+ }
19
+ //#endregion
20
+ export { mergeConfig };
@@ -0,0 +1,452 @@
1
+ import { MaybePromise, NullValue, Reporter } from "../types.js";
2
+ import { Plugin } from "../core/plugins/types.js";
3
+ import { InteractiveCommand } from "../node/commands/start/setup-interactive-mode.js";
4
+ import * as rolldown from "@rollipop/rolldown";
5
+ import { DevWatchOptions, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig } from "@rollipop/rolldown/experimental";
6
+ import { TopLevelFilterExpression } from "@rollipop/rolldown/filter";
7
+ import * as babel from "@babel/core";
8
+ import * as swc from "@swc/core";
9
+ import { TransformOptions } from "@rollipop/rolldown/utils";
10
+
11
+ //#region src/config/types.d.ts
12
+ type RolldownExperimentalOptions = NonNullable<rolldown.InputOptions['experimental']>;
13
+ interface Config {
14
+ /**
15
+ * Defaults to current working directory.
16
+ */
17
+ root?: string;
18
+ /**
19
+ * Specifying this in config will override the default mode for both serve and build.
20
+ *
21
+ * Defaults to: `'development'` for serve, 'production' for build.
22
+ */
23
+ mode?: 'development' | 'production';
24
+ /**
25
+ * Defaults to: `index.js`
26
+ */
27
+ entry?: string;
28
+ /**
29
+ * Resolver configuration.
30
+ */
31
+ resolver?: ResolverConfig;
32
+ /**
33
+ * Transformer configuration.
34
+ */
35
+ transformer?: TransformerConfig;
36
+ /**
37
+ * Serializer configuration.
38
+ */
39
+ serializer?: SerializerConfig;
40
+ /**
41
+ * Watcher configuration.
42
+ */
43
+ watcher?: WatcherConfig;
44
+ /**
45
+ * Optimization configuration.
46
+ */
47
+ optimization?: OptimizationConfig;
48
+ /**
49
+ * React Native specific configuration.
50
+ */
51
+ reactNative?: ReactNativeConfig;
52
+ /**
53
+ * Terminal configuration.
54
+ */
55
+ terminal?: TerminalConfig;
56
+ /**
57
+ * Reporter configuration.
58
+ */
59
+ reporter?: Reporter;
60
+ /**
61
+ * Dev mode specific configuration. (for dev server)
62
+ */
63
+ devMode?: DevModeConfig;
64
+ /**
65
+ * Directory to load environment variables from.
66
+ *
67
+ * Defaults to: `root`
68
+ */
69
+ envDir?: string;
70
+ /**
71
+ * Base name for environment files.
72
+ *
73
+ * Acts as the basename of the standard four-file resolution: the loader looks
74
+ * for `${envFile}`, `${envFile}.local`, `${envFile}.[mode]`, and
75
+ * `${envFile}.[mode].local`. Override this to use a custom name such as
76
+ * `.rollipop-env` instead of the default `.env`.
77
+ *
78
+ * Expects a file name (not a path).
79
+ *
80
+ * Defaults to: `'.env'`
81
+ */
82
+ envFile?: string;
83
+ /**
84
+ * Environment variable prefix.
85
+ *
86
+ * Defaults to: `'ROLLIPOP_'`
87
+ */
88
+ envPrefix?: string;
89
+ /**
90
+ * Configures TypeScript configuration file resolution and usage.
91
+ *
92
+ * Defaults to: `true`
93
+ */
94
+ tsconfig?: rolldown.InputOptions['tsconfig'];
95
+ /**
96
+ * Whether to generate sourcemaps.
97
+ *
98
+ * - `false`: No sourcemap will be generated.
99
+ * - `true`: A separate sourcemap file will be generated.
100
+ * - `'inline'`: The sourcemap will be appended to the output file as a data URL.
101
+ * - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (//# sourceMappingURL comment) will not be included in the output file.
102
+ *
103
+ * Defaults to: `true` when in development mode, `false` otherwise.
104
+ */
105
+ sourcemap?: rolldown.OutputOptions['sourcemap'];
106
+ /**
107
+ * The base URL for the links to the sourcemap file in the output file.
108
+ *
109
+ * By default, relative URLs are generated. If this option is set, an absolute URL with that base URL will be generated.
110
+ * This is useful when deploying source maps to a different location than your code, such as a CDN or separate debugging server.
111
+ */
112
+ sourcemapBaseUrl?: rolldown.OutputOptions['sourcemapBaseUrl'];
113
+ /**
114
+ * Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
115
+ *
116
+ * When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
117
+ *
118
+ * Defaults to: `false`
119
+ */
120
+ sourcemapDebugIds?: rolldown.OutputOptions['sourcemapDebugIds'];
121
+ /**
122
+ * Control which source files are included in the sourcemap ignore list.
123
+ *
124
+ * Files in the ignore list are excluded from debugger stepping and error stack traces.
125
+ *
126
+ * - `false`: Include no source files in the ignore list
127
+ * - `true`: Include all source files in the ignore list
128
+ * - `string`: Files containing this string in their path will be included in the ignore list
129
+ * - `RegExp`: Files matching this regular expression will be included in the ignore list
130
+ * - `function`: Custom function to determine if a source should be ignored
131
+ *
132
+ * :::tip Performance
133
+ * Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
134
+ * Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
135
+ * :::
136
+ *
137
+ * @example
138
+ * ```js
139
+ * // ✅ Preferred: Use RegExp for better performance
140
+ * sourcemapIgnoreList: /node_modules/
141
+ *
142
+ * // ✅ Preferred: Use string pattern for better performance
143
+ * sourcemapIgnoreList: "vendor"
144
+ *
145
+ * // ! Use sparingly: Function calls have high overhead
146
+ * sourcemapIgnoreList: (source, sourcemapPath) => {
147
+ * return source.includes('node_modules') || source.includes('.min.');
148
+ * }
149
+ * ```
150
+ *
151
+ * Defaults to: `/node_modules/`
152
+ */
153
+ sourcemapIgnoreList?: rolldown.OutputOptions['sourcemapIgnoreList'];
154
+ /**
155
+ * A transformation to apply to each path in a sourcemap.
156
+ *
157
+ * @example
158
+ * ```js
159
+ * export default defineConfig({
160
+ * output: {
161
+ * sourcemap: true,
162
+ * sourcemapPathTransform: (source, sourcemapPath) => {
163
+ * // Remove 'src/' prefix from all source paths
164
+ * return source.replace(/^src\//, '');
165
+ * },
166
+ * },
167
+ * });
168
+ * ```
169
+ */
170
+ sourcemapPathTransform?: rolldown.OutputOptions['sourcemapPathTransform'];
171
+ /**
172
+ * Plugins to apply to the build.
173
+ */
174
+ plugins?: PluginOption;
175
+ /**
176
+ * Internal option to specify the runtime target.
177
+ *
178
+ * Defaults to 'hermes-v1'.
179
+ */
180
+ runtimeTarget?: 'hermes' | 'hermes-v1';
181
+ /**
182
+ * Experimental options. Behaviour and shape may change between releases
183
+ * without a major version bump.
184
+ */
185
+ experimental?: ExperimentalConfig;
186
+ /**
187
+ * Rollipop provides default options for Rolldown, but you can override them by this option.
188
+ *
189
+ * **DANGEROUS**: This option is dangerous because it can break the build.
190
+ */
191
+ dangerously_overrideRolldownOptions?: RolldownConfig | ((config: RolldownConfig) => RolldownConfig) | ((config: RolldownConfig) => Promise<RolldownConfig>);
192
+ }
193
+ type PluginOption = MaybePromise<NullValue<Plugin> | {
194
+ name: string;
195
+ } | false | PluginOption[]>;
196
+ type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'extensions'> & {
197
+ /**
198
+ * Defaults to: `['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json']`
199
+ */
200
+ sourceExtensions?: string[];
201
+ /**
202
+ * Defaults to images (`bmp`, `gif`, `jpg`, `jpeg`, `png`, `psd`, `svg`, `webp`, `xml`),
203
+ * video (`m4v`, `mov`, `mp4`, `mpeg`, `mpg`, `webm`), audio (`aac`, `aiff`, `caf`, `m4a`,
204
+ * `mp3`, `wav`), documents (`html`, `pdf`, `yaml`, `yml`), fonts (`otf`, `ttf`), and
205
+ * archives (`zip`).
206
+ */
207
+ assetExtensions?: string[];
208
+ /**
209
+ * If `true`, resolver will resolve `native` suffixed files.
210
+ *
211
+ * e.g.
212
+ * - **true**: `index.android` -> `index.native` -> `index`
213
+ * - **false**: `index.android` -> `index`
214
+ *
215
+ * Defaults to: `true`
216
+ */
217
+ preferNativePlatform?: boolean;
218
+ /**
219
+ * Specifies which modules should be treated as external and not bundled.
220
+ *
221
+ * External modules will be left as import statements in the output.
222
+ */
223
+ external?: rolldown.InputOptions['external'];
224
+ };
225
+ type TransformerConfig = Omit<TransformOptions, 'cwd' | 'lang' | 'sourceType' | 'plugins'> & {
226
+ /**
227
+ * Flow specific configuration.
228
+ *
229
+ * Only applied when `experimental.nativeTransformPipeline` is **disabled** (the
230
+ * default). With the native pipeline enabled, the rust-side plugin
231
+ * handles Flow stripping internally.
232
+ */
233
+ flow?: FlowConfig;
234
+ /**
235
+ * Babel transformation configuration.
236
+ */
237
+ babel?: BabelTransformConfig;
238
+ /**
239
+ * SWC transformation configuration.
240
+ */
241
+ swc?: SwcTransformConfig;
242
+ };
243
+ type BabelTransformConfig = {
244
+ rules?: TransformRule<babel.TransformOptions>[];
245
+ };
246
+ type SwcTransformConfig = {
247
+ rules?: TransformRule<swc.Options>[];
248
+ };
249
+ interface TransformRule<T = unknown> {
250
+ filter?: rolldown.HookFilter | TopLevelFilterExpression[];
251
+ options: T | ((code: string, id: string) => T);
252
+ }
253
+ interface FlowConfig {
254
+ /**
255
+ * Filter for Flow transformation pipeline.
256
+ */
257
+ filter?: rolldown.HookFilter | TopLevelFilterExpression[];
258
+ }
259
+ interface ExperimentalConfig {
260
+ /**
261
+ * Enables the native (rust) transform pipeline, which replaces the
262
+ * legacy JS-side codegen marker, Flow strip, and SWC/babel preset
263
+ * machinery with a single built-in `rollipopReactNativePlugin`.
264
+ *
265
+ * This is a breaking change for projects that customised the legacy
266
+ * pipeline via `transformer.flow.filter`, `reactNative.codegen.filter`,
267
+ * or `runtimeTarget`. Opt in once you have validated builds locally.
268
+ *
269
+ * Defaults to `false`.
270
+ */
271
+ nativeTransformPipeline?: boolean;
272
+ /**
273
+ * Flow handling configuration for the native transform pipeline.
274
+ *
275
+ * Only applied when `experimental.nativeTransformPipeline` is enabled.
276
+ */
277
+ flow?: RollipopReactNativeFlowConfig;
278
+ /**
279
+ * `react-native-worklets` transformation configuration.
280
+ *
281
+ * Only applied when `experimental.nativeTransformPipeline` is enabled.
282
+ */
283
+ worklets?: RollipopReactNativeWorkletsConfig;
284
+ }
285
+ interface SerializerConfig {
286
+ /**
287
+ * Paths to prelude files.
288
+ *
289
+ * Prelude files are imported in the top of the entry module.
290
+ */
291
+ prelude?: string[];
292
+ /**
293
+ * Polyfills to include in the output bundle.
294
+ *
295
+ * Polyfills are injected in the top of the output bundle.
296
+ */
297
+ polyfills?: Polyfill[];
298
+ /**
299
+ * A string to prepend to the bundle before `renderChunk` hook.
300
+ */
301
+ banner?: rolldown.OutputOptions['banner'];
302
+ /**
303
+ * A string to append to the bundle before `renderChunk` hook.
304
+ */
305
+ footer?: rolldown.OutputOptions['footer'];
306
+ /**
307
+ * A string to prepend to the bundle after `renderChunk` hook and minification.
308
+ */
309
+ postBanner?: rolldown.OutputOptions['postBanner'];
310
+ /**
311
+ * A string to append to the bundle after `renderChunk` hook and minification.
312
+ */
313
+ postFooter?: rolldown.OutputOptions['postFooter'];
314
+ /**
315
+ * A string to prepend inside any format-specific wrapper.
316
+ */
317
+ intro?: rolldown.OutputOptions['intro'];
318
+ /**
319
+ * A string to append inside any format-specific wrapper.
320
+ */
321
+ outro?: rolldown.OutputOptions['outro'];
322
+ /**
323
+ * When `true`, creates shim variables for missing exports instead of throwing an error.
324
+ *
325
+ * Defaults to: `false`
326
+ */
327
+ shimMissingExports?: rolldown.InputOptions['shimMissingExports'];
328
+ }
329
+ type Polyfill = string | PolyfillWithCode | PolyfillWithPath;
330
+ type PolyfillWithCode = {
331
+ type: PolyfillType;
332
+ code: string;
333
+ };
334
+ type PolyfillWithPath = {
335
+ type: PolyfillType;
336
+ path: string;
337
+ };
338
+ type PolyfillType = 'plain' | 'iife';
339
+ type OptimizationConfig = rolldown.OptimizationOptions & {
340
+ /**
341
+ * Controls tree-shaking (dead code elimination).
342
+ *
343
+ * When `false`, tree-shaking will be disabled. When `true`, it is equivalent to setting each options to the default value.
344
+ *
345
+ * Defaults to: `true`
346
+ */
347
+ treeshake?: rolldown.InputOptions['treeshake'];
348
+ /**
349
+ * Control code minification.
350
+ *
351
+ * - `true`: Enable full minification including code compression and dead code elimination
352
+ * - `false`: Disable minification (default)
353
+ * - `'dce-only'`: Only perform dead code elimination without code compression
354
+ * - `MinifyOptions`: Fine-grained control over minification settings
355
+ *
356
+ * Defaults to: `false`
357
+ */
358
+ minify?: rolldown.OutputOptions['minify'];
359
+ /**
360
+ * Control whether to enable lazy barrel optimization.
361
+ *
362
+ * Lazy barrel optimization avoids compiling unused re-export modules in side-effect-free barrel modules,
363
+ * significantly improving build performance for large codebases with many barrel modules.
364
+ *
365
+ * Defaults to: `false`
366
+ *
367
+ * @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
368
+ */
369
+ lazyBarrel?: RolldownExperimentalOptions['lazyBarrel'];
370
+ };
371
+ type WatcherConfig = DevWatchOptions;
372
+ interface DevModeConfig {
373
+ /**
374
+ * Hot Module Replacement configurations.
375
+ * This feature is only available in `development` mode.
376
+ *
377
+ * Defaults to `true`.
378
+ */
379
+ hmr?: boolean | HmrConfig;
380
+ }
381
+ interface HmrConfig {
382
+ /**
383
+ * Source code of the HMR runtime implementation.
384
+ *
385
+ * Defaults to: using `rollipop/hmr-runtime` as a default implementation.
386
+ */
387
+ runtimeImplement?: string;
388
+ /**
389
+ * Source code of the HMR client implementation.
390
+ *
391
+ * Defaults to: using `rollipop/hmr-client` as a default implementation.
392
+ */
393
+ clientImplement?: string;
394
+ }
395
+ interface ReactNativeConfig {
396
+ /**
397
+ * Path to React Native package.
398
+ *
399
+ * Defaults to: resolving `react-native` package from `projectRoot`.
400
+ */
401
+ reactNativePath?: string;
402
+ /**
403
+ * Codegen specific configuration.
404
+ *
405
+ * Only applied when `experimental.nativeTransformPipeline` is **disabled** (the
406
+ * default). With the native pipeline enabled, the rust-side plugin
407
+ * handles codegen marking internally.
408
+ */
409
+ codegen?: CodegenConfig;
410
+ /**
411
+ * Path to asset registry file.
412
+ *
413
+ * Defaults to: `react-native/Libraries/Image/AssetRegistry.js`
414
+ */
415
+ assetRegistryPath?: string | ((root: string) => MaybePromise<string>);
416
+ /**
417
+ * Path to HMR client file.
418
+ *
419
+ * Defaults to: `react-native/Libraries/Utilities/HMRClient.js`
420
+ */
421
+ hmrClientPath?: string | ((root: string) => MaybePromise<string>);
422
+ /**
423
+ * Reserved global identifiers of React Native.
424
+ *
425
+ * Defaults to: Global identifier list of React Native 0.83
426
+ */
427
+ globalIdentifiers?: string[];
428
+ }
429
+ interface CodegenConfig {
430
+ /**
431
+ * Filter for codegen transformation pipeline.
432
+ */
433
+ filter?: rolldown.HookFilter | TopLevelFilterExpression[];
434
+ }
435
+ interface TerminalConfig {
436
+ /**
437
+ * Status of the terminal.
438
+ *
439
+ * Defaults to: `process.stderr.isTTY ? 'progress' : 'compat'`
440
+ */
441
+ status?: 'none' | 'compat' | 'progress';
442
+ /**
443
+ * Extra commands to display in the interactive mode.
444
+ */
445
+ extraCommands?: InteractiveCommand[];
446
+ }
447
+ interface RolldownConfig {
448
+ input?: rolldown.InputOptions;
449
+ output?: rolldown.OutputOptions;
450
+ }
451
+ //#endregion
452
+ export { BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig };
@@ -0,0 +1,35 @@
1
+ declare namespace constants_d_exports {
2
+ 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 };
3
+ }
4
+ /**
5
+ * @see `vite.config.ts`
6
+ */
7
+ declare global {
8
+ var __ROLLIPOP_VERSION__: string;
9
+ }
10
+ declare const ROLLIPOP_VERSION: string;
11
+ declare const GLOBAL_IDENTIFIER = "global";
12
+ /**
13
+ * @see {@link https://github.com/facebook/metro/blob/0.81.x/docs/Configuration.md#resolvermainfields}
14
+ */
15
+ declare const DEFAULT_RESOLVER_MAIN_FIELDS: string[];
16
+ declare const DEFAULT_RESOLVER_ALIAS_FIELDS: string[][];
17
+ declare const DEFAULT_RESOLVER_CONDITION_NAMES: string[];
18
+ /**
19
+ * Unlike the Metro bundler configuration, this prioritizes resolving TypeScript and ESM first.
20
+ *
21
+ * @see {@link https://github.com/facebook/metro/blob/0.81.x/packages/metro-config/src/defaults/defaults.js}
22
+ * @see {@link https://github.com/facebook/metro/blob/0.81.x/packages/metro-file-map/src/workerExclusionList.js}
23
+ */
24
+ declare const DEFAULT_SOURCE_EXTENSIONS: string[];
25
+ declare const DEFAULT_IMAGE_EXTENSIONS: string[];
26
+ declare const IMAGE_EXTENSIONS: string[];
27
+ declare const DEFAULT_ASSET_EXTENSIONS: string[];
28
+ declare const DEFAULT_ASSET_REGISTRY_PATH = "react-native/Libraries/Image/AssetRegistry.js";
29
+ declare const DEFAULT_HMR_CLIENT_PATH = "react-native/Libraries/Utilities/HMRClient.js";
30
+ declare const DEFAULT_REACT_NATIVE_GLOBAL_IDENTIFIERS: string[];
31
+ declare const DEFAULT_ENV_PREFIX = "ROLLIPOP_";
32
+ declare const DEFAULT_ENV_FILE = ".env";
33
+ declare const DEFAULT_RUNTIME_TARGET = "hermes-v1";
34
+ //#endregion
35
+ export { constants_d_exports };