@rollipop/rolldown 0.0.0 → 1.0.0-rc.10

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 (50) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +11 -1
  3. package/bin/cli.mjs +2 -0
  4. package/dist/cli.d.mts +1 -0
  5. package/dist/cli.mjs +1191 -0
  6. package/dist/config.d.mts +14 -0
  7. package/dist/config.mjs +4 -0
  8. package/dist/experimental-index.d.mts +316 -0
  9. package/dist/experimental-index.mjs +350 -0
  10. package/dist/experimental-runtime-types.d.ts +98 -0
  11. package/dist/filter-index.d.mts +196 -0
  12. package/dist/filter-index.mjs +386 -0
  13. package/dist/get-log-filter.d.mts +3 -0
  14. package/dist/get-log-filter.mjs +68 -0
  15. package/dist/index.d.mts +4 -0
  16. package/dist/index.mjs +50 -0
  17. package/dist/parallel-plugin-worker.d.mts +1 -0
  18. package/dist/parallel-plugin-worker.mjs +28 -0
  19. package/dist/parallel-plugin.d.mts +13 -0
  20. package/dist/parallel-plugin.mjs +6 -0
  21. package/dist/parse-ast-index.d.mts +32 -0
  22. package/dist/parse-ast-index.mjs +60 -0
  23. package/dist/plugins-index.d.mts +33 -0
  24. package/dist/plugins-index.mjs +40 -0
  25. package/dist/shared/binding-D_jQsHun.mjs +583 -0
  26. package/dist/shared/binding-hSQGgsUz.d.mts +1877 -0
  27. package/dist/shared/bindingify-input-options-DfXGy4QO.mjs +2193 -0
  28. package/dist/shared/constructors-B-HbV10G.mjs +68 -0
  29. package/dist/shared/constructors-DMl58KN5.d.mts +37 -0
  30. package/dist/shared/define-config-BSxBeCq6.d.mts +3810 -0
  31. package/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
  32. package/dist/shared/error-D5tMcn3l.mjs +85 -0
  33. package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
  34. package/dist/shared/load-config-CNjYgiQv.mjs +120 -0
  35. package/dist/shared/logging-C6h4g8dA.d.mts +50 -0
  36. package/dist/shared/logs-D80CXhvg.mjs +180 -0
  37. package/dist/shared/misc-DJYbNKZX.mjs +21 -0
  38. package/dist/shared/normalize-string-or-regex-B8PEhdn1.mjs +66 -0
  39. package/dist/shared/parse-iQx2ihYn.mjs +74 -0
  40. package/dist/shared/prompt-BYQIwEjg.mjs +845 -0
  41. package/dist/shared/resolve-tsconfig-CxoM-bno.mjs +113 -0
  42. package/dist/shared/rolldown-C0o3hS3w.mjs +40 -0
  43. package/dist/shared/rolldown-build-80GULIOI.mjs +3326 -0
  44. package/dist/shared/transform-DY2pi3Qm.d.mts +149 -0
  45. package/dist/shared/watch-C2am0Ahc.mjs +374 -0
  46. package/dist/utils-index.d.mts +376 -0
  47. package/dist/utils-index.mjs +2414 -0
  48. package/package.json +130 -2
  49. package/.editorconfig +0 -10
  50. package/.gitattributes +0 -4
@@ -0,0 +1,14 @@
1
+ import { F as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-BSxBeCq6.mjs";
2
+
3
+ //#region src/utils/load-config.d.ts
4
+ /**
5
+ * Load config from a file in a way that Rolldown does.
6
+ *
7
+ * @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
8
+ * @returns The loaded config export
9
+ *
10
+ * @category Config
11
+ */
12
+ declare function loadConfig(configPath: string): Promise<ConfigExport>;
13
+ //#endregion
14
+ export { VERSION, defineConfig, loadConfig };
@@ -0,0 +1,4 @@
1
+ import { x as VERSION } from "./shared/bindingify-input-options-DfXGy4QO.mjs";
2
+ import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
3
+ import { t as loadConfig } from "./shared/load-config-CNjYgiQv.mjs";
4
+ export { VERSION, defineConfig, loadConfig };
@@ -0,0 +1,316 @@
1
+ import { A as BindingViteTransformPluginConfig, H as ResolveResult, J as isolatedDeclarationSync, N as IsolatedDeclarationsOptions, P as IsolatedDeclarationsResult, R as NapiResolveOptions, T as BindingViteManifestPluginConfig, U as ResolverFactory, Y as moduleRunnerTransform, f as BindingRebuildStrategy, g as BindingRollipopWorkletsPluginConfig, h as BindingRollipopReactRefreshWrapperPluginConfig, i as BindingClientHmrUpdate, n as BindingBundleAnalyzerPluginConfig, q as isolatedDeclaration, r as BindingBundleState, v as BindingTsconfigCompilerOptions, y as BindingTsconfigRawOptions } from "./shared/binding-hSQGgsUz.mjs";
2
+ import { Jt as freeExternalMemory, Kt as RolldownOutput, Lt as OutputOptions, N as BuiltinPlugin, X as defineParallelPlugin, c as InputOptions, st as NormalizedOutputOptions } from "./shared/define-config-BSxBeCq6.mjs";
3
+ import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-DY2pi3Qm.mjs";
4
+ import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWasmFallbackPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-DMl58KN5.mjs";
5
+
6
+ //#region src/api/dev/dev-options.d.ts
7
+ type DevOnHmrUpdates = (result: Error | {
8
+ updates: BindingClientHmrUpdate[];
9
+ changedFiles: string[];
10
+ }) => void | Promise<void>;
11
+ type DevOnOutput = (result: Error | RolldownOutput) => void | Promise<void>;
12
+ interface DevWatchOptions {
13
+ /**
14
+ * If `true`, files are not written to disk.
15
+ * @default false
16
+ */
17
+ skipWrite?: boolean;
18
+ /**
19
+ * If `true`, use polling instead of native file system events for watching.
20
+ * @default false
21
+ */
22
+ usePolling?: boolean;
23
+ /**
24
+ * Poll interval in milliseconds (only used when usePolling is true).
25
+ * @default 100
26
+ */
27
+ pollInterval?: number;
28
+ /**
29
+ * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
30
+ * @default true
31
+ */
32
+ useDebounce?: boolean;
33
+ /**
34
+ * Debounce duration in milliseconds (only used when useDebounce is true).
35
+ * @default 10
36
+ */
37
+ debounceDuration?: number;
38
+ /**
39
+ * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
40
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
41
+ * @default false
42
+ */
43
+ compareContentsForPolling?: boolean;
44
+ /**
45
+ * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
46
+ * Controls how frequently the debouncer checks for events to process.
47
+ * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
48
+ * @default undefined (auto-select)
49
+ */
50
+ debounceTickRate?: number;
51
+ }
52
+ interface DevOptions {
53
+ onHmrUpdates?: DevOnHmrUpdates;
54
+ onOutput?: DevOnOutput;
55
+ /**
56
+ * Strategy for triggering rebuilds after HMR updates.
57
+ * - `'always'`: Always trigger a rebuild after HMR updates
58
+ * - `'auto'`: Trigger rebuild only if HMR updates contain full reload updates
59
+ * - `'never'`: Never trigger rebuild after HMR updates (default)
60
+ * @default 'auto'
61
+ */
62
+ rebuildStrategy?: "always" | "auto" | "never";
63
+ watch?: DevWatchOptions;
64
+ }
65
+ //#endregion
66
+ //#region src/api/dev/dev-engine.d.ts
67
+ declare class DevEngine {
68
+ #private;
69
+ static create(inputOptions: InputOptions, outputOptions?: OutputOptions, devOptions?: DevOptions): Promise<DevEngine>;
70
+ private constructor();
71
+ run(): Promise<void>;
72
+ ensureCurrentBuildFinish(): Promise<void>;
73
+ getBundleState(): Promise<BindingBundleState>;
74
+ ensureLatestBuildOutput(): Promise<void>;
75
+ invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingClientHmrUpdate[]>;
76
+ registerModules(clientId: string, modules: string[]): Promise<void>;
77
+ removeClient(clientId: string): Promise<void>;
78
+ close(): Promise<void>;
79
+ /**
80
+ * Compile a lazy entry module and return HMR-style patch code.
81
+ *
82
+ * This is called when a dynamically imported module is first requested at runtime.
83
+ * The module was previously stubbed with a proxy, and now we need to compile the
84
+ * actual module and its dependencies.
85
+ *
86
+ * @param moduleId - The absolute file path of the module to compile
87
+ * @param clientId - The client ID requesting this compilation
88
+ * @returns The compiled JavaScript code as a string (HMR patch format)
89
+ */
90
+ compileEntry(moduleId: string, clientId: string): Promise<string>;
91
+ }
92
+ //#endregion
93
+ //#region src/api/dev/index.d.ts
94
+ declare const dev: typeof DevEngine.create;
95
+ //#endregion
96
+ //#region src/api/experimental.d.ts
97
+ /**
98
+ * This is an experimental API. Its behavior may change in the future.
99
+ *
100
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
101
+ * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
102
+ *
103
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
104
+ * ```ts
105
+ * import { scan } from '@rollipop/rolldown/api/experimental';
106
+ *
107
+ * const cleanupPromise = await scan(...);
108
+ * await cleanupPromise;
109
+ * // Now all resources have been cleaned up.
110
+ * ```
111
+ */
112
+ declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;
113
+ //#endregion
114
+ //#region src/builtin-plugin/alias-plugin.d.ts
115
+ type ViteAliasPluginConfig = {
116
+ entries: {
117
+ find: string | RegExp;
118
+ replacement: string;
119
+ }[];
120
+ };
121
+ declare function viteAliasPlugin(config: ViteAliasPluginConfig): BuiltinPlugin;
122
+ //#endregion
123
+ //#region src/builtin-plugin/bundle-analyzer-plugin.d.ts
124
+ /**
125
+ * A plugin that analyzes bundle composition and generates detailed reports.
126
+ *
127
+ * The plugin outputs a file containing detailed information about:
128
+ * - All chunks and their relationships
129
+ * - Modules bundled in each chunk
130
+ * - Import dependencies between chunks
131
+ * - Reachable modules from each entry point
132
+ *
133
+ * @example
134
+ * ```js
135
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
136
+ *
137
+ * export default {
138
+ * plugins: [
139
+ * bundleAnalyzerPlugin()
140
+ * ]
141
+ * }
142
+ * ```
143
+ *
144
+ * @example
145
+ * **Custom filename**
146
+ * ```js
147
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
148
+ *
149
+ * export default {
150
+ * plugins: [
151
+ * bundleAnalyzerPlugin({
152
+ * fileName: 'bundle-analysis.json'
153
+ * })
154
+ * ]
155
+ * }
156
+ * ```
157
+ *
158
+ * @example
159
+ * **LLM-friendly markdown output**
160
+ * ```js
161
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
162
+ *
163
+ * export default {
164
+ * plugins: [
165
+ * bundleAnalyzerPlugin({
166
+ * format: 'md'
167
+ * })
168
+ * ]
169
+ * }
170
+ * ```
171
+ */
172
+ declare function bundleAnalyzerPlugin(config?: BindingBundleAnalyzerPluginConfig): BuiltinPlugin;
173
+ //#endregion
174
+ //#region src/builtin-plugin/transform-plugin.d.ts
175
+ type TransformPattern = string | RegExp | readonly (RegExp | string)[];
176
+ type TransformPluginConfig = Omit<BindingViteTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude" | "yarnPnp"> & {
177
+ include?: TransformPattern;
178
+ exclude?: TransformPattern;
179
+ jsxRefreshInclude?: TransformPattern;
180
+ jsxRefreshExclude?: TransformPattern;
181
+ };
182
+ declare function viteTransformPlugin(config: TransformPluginConfig): BuiltinPlugin;
183
+ //#endregion
184
+ //#region src/builtin-plugin/vite-manifest-plugin.d.ts
185
+ type ViteManifestPluginConfig = Omit<BindingViteManifestPluginConfig, "isLegacy"> & {
186
+ isOutputOptionsForLegacyChunks?: (outputOptions: NormalizedOutputOptions) => boolean;
187
+ };
188
+ declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPlugin;
189
+ //#endregion
190
+ //#region src/builtin-plugin/rollipop-react-refresh-wrapper-plugin.d.ts
191
+ declare function rollipopReactRefreshWrapperPlugin(config: BindingRollipopReactRefreshWrapperPluginConfig): BuiltinPlugin;
192
+ //#endregion
193
+ //#region src/builtin-plugin/rollipop-worklets-plugin.d.ts
194
+ declare function rollipopWorkletsPlugin(config: BindingRollipopWorkletsPluginConfig): BuiltinPlugin;
195
+ //#endregion
196
+ //#region src/builtin-plugin/rollipop-react-native-plugin.d.ts
197
+ type RollipopReactNativeRuntimeTarget = "Hermes" | "HermesV1";
198
+ /**
199
+ * `react-native-worklets` transform configuration. Field semantics mirror
200
+ * the upstream Babel plugin's `WorkletsOptions`, minus the rolldown-managed
201
+ * fields (`filename`, `cwd`). Pass `worklets: {}` to opt in with defaults;
202
+ * omit the field entirely to skip the visitor.
203
+ */
204
+ interface RollipopReactNativeWorkletsConfig {
205
+ /** Identifiers treated as globals — never captured into worklet closures. */
206
+ globals?: string[];
207
+ /** When `true`, only the names listed in `globals` are considered safe. */
208
+ strictGlobal?: boolean;
209
+ /** Omit native-only data (`init_data`) from the output. Useful for web builds. */
210
+ omitNativeOnlyData?: boolean;
211
+ /** Disable source map generation for worklets. */
212
+ disableSourceMaps?: boolean;
213
+ /** Use paths relative to `cwd` for source locations. */
214
+ relativeSourceLocation?: boolean;
215
+ /** Disable Worklet Classes support. */
216
+ disableWorkletClasses?: boolean;
217
+ /** Suppress the inline-shared-values warning. */
218
+ disableInlineStylesWarning?: boolean;
219
+ /** Enable Bundle Mode. */
220
+ bundleMode?: boolean;
221
+ /** Release builds skip debug info such as stack details, version, and location. */
222
+ isRelease?: boolean;
223
+ /** Version string emitted as `__pluginVersion` (the installed `react-native-worklets` version). */
224
+ pluginVersion?: string;
225
+ }
226
+ /**
227
+ * Flow handling configuration. Mirrors Babel's
228
+ * `@babel/plugin-transform-flow-strip-types` semantics.
229
+ */
230
+ interface RollipopReactNativeFlowConfig {
231
+ /**
232
+ * When `true`, only files containing `@flow` or `@noflow` directive comments are parsed as Flow (Babel `requireDirective: true`).
233
+ * When `false` (default), every JS module is parsed as Flow regardless of directive — matches Metro / Babel default behavior.
234
+ */
235
+ requireDirective?: boolean;
236
+ }
237
+ interface RollipopReactNativePluginConfig {
238
+ runtimeTarget?: RollipopReactNativeRuntimeTarget;
239
+ /**
240
+ * The name of the `env` to use when loading configs and plugins. Defaults
241
+ * to the value of `SWC_ENV`, or else `NODE_ENV`, or else `"development"`.
242
+ */
243
+ envName?: string;
244
+ /** `react-native-worklets` transform. Visitor is skipped when omitted. */
245
+ worklets?: RollipopReactNativeWorkletsConfig;
246
+ /** SWC plugins to load. */
247
+ plugins?: [string, Record<string, unknown>][];
248
+ /** Flow handling configuration. Defaults match Metro / Babel behavior. */
249
+ flow?: RollipopReactNativeFlowConfig;
250
+ }
251
+ declare function rollipopReactNativePlugin(config?: RollipopReactNativePluginConfig): BuiltinPlugin;
252
+ //#endregion
253
+ //#region src/experimental-index.d.ts
254
+ /**
255
+ * In-memory file system for browser builds.
256
+ *
257
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
258
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
259
+ *
260
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
261
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
262
+ *
263
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * import { memfs } from '@rollipop/rolldown/experimental';
268
+ *
269
+ * // Write files to virtual filesystem before bundling
270
+ * memfs?.volume.fromJSON({
271
+ * '/src/index.js': 'export const foo = 42;',
272
+ * '/package.json': '{"name": "my-app"}'
273
+ * });
274
+ *
275
+ * // Read files from the virtual filesystem
276
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
277
+ * ```
278
+ *
279
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
280
+ */
281
+ declare const memfs: {
282
+ fs: any;
283
+ volume: any;
284
+ } | undefined;
285
+ /** @deprecated Use from `rolldown/utils` instead. */
286
+ declare const parse: typeof parse$1;
287
+ /** @deprecated Use from `rolldown/utils` instead. */
288
+ declare const parseSync: typeof parseSync$1;
289
+ /** @deprecated Use from `rolldown/utils` instead. */
290
+ type ParseResult = ParseResult$1;
291
+ /** @deprecated Use from `rolldown/utils` instead. */
292
+ type ParserOptions = ParserOptions$1;
293
+ /** @deprecated Use from `rolldown/utils` instead. */
294
+ declare const minify: typeof minify$1;
295
+ /** @deprecated Use from `rolldown/utils` instead. */
296
+ declare const minifySync: typeof minifySync$1;
297
+ /** @deprecated Use from `rolldown/utils` instead. */
298
+ type MinifyOptions = MinifyOptions$1;
299
+ /** @deprecated Use from `rolldown/utils` instead. */
300
+ type MinifyResult = MinifyResult$1;
301
+ /** @deprecated Use from `rolldown/utils` instead. */
302
+ declare const transform: typeof transform$1;
303
+ /** @deprecated Use from `rolldown/utils` instead. */
304
+ declare const transformSync: typeof transformSync$1;
305
+ /** @deprecated Use from `rolldown/utils` instead. */
306
+ type TransformOptions = TransformOptions$1;
307
+ /** @deprecated Use from `rolldown/utils` instead. */
308
+ type TransformResult = TransformResult$1;
309
+ /** @deprecated Use from `rolldown/utils` instead. */
310
+ declare const TsconfigCache: typeof TsconfigCache$1;
311
+ /** @deprecated Use from `rolldown/utils` instead. */
312
+ type TsconfigRawOptions = BindingTsconfigRawOptions;
313
+ /** @deprecated Use from `rolldown/utils` instead. */
314
+ type TsconfigCompilerOptions = BindingTsconfigCompilerOptions;
315
+ //#endregion
316
+ export { type BindingClientHmrUpdate, BindingRebuildStrategy, DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, MinifyOptions, MinifyResult, ParseResult, ParserOptions, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type RollipopReactNativeFlowConfig, type RollipopReactNativePluginConfig, type RollipopReactNativeRuntimeTarget, type RollipopReactNativeWorkletsConfig, type BindingRollipopReactRefreshWrapperPluginConfig as RollipopReactRefreshWrapperPluginConfig, type BindingRollipopWorkletsPluginConfig as RollipopWorkletsPluginConfig, TransformOptions, TransformResult, TsconfigCache, TsconfigCompilerOptions, TsconfigRawOptions, bundleAnalyzerPlugin, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, oxcRuntimePlugin, parse, parseSync, resolveTsconfig, rollipopReactNativePlugin, rollipopReactRefreshWrapperPlugin, rollipopWorkletsPlugin, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWebWorkerPostPlugin };
@@ -0,0 +1,350 @@
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-D_jQsHun.mjs";
2
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-B8PEhdn1.mjs";
3
+ import { o as transformToRollupOutput } from "./shared/bindingify-input-options-DfXGy4QO.mjs";
4
+ import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-80GULIOI.mjs";
5
+ import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-D5tMcn3l.mjs";
6
+ import { n as parseSync$1, t as parse$1 } from "./shared/parse-iQx2ihYn.mjs";
7
+ import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWasmFallbackPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-B-HbV10G.mjs";
8
+ import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-CxoM-bno.mjs";
9
+ import { pathToFileURL } from "node:url";
10
+ //#region src/api/dev/dev-engine.ts
11
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
12
+ var DevEngine = class DevEngine {
13
+ #inner;
14
+ #cachedBuildFinishPromise = null;
15
+ static async create(inputOptions, outputOptions = {}, devOptions = {}) {
16
+ inputOptions = await PluginDriver.callOptionsHook(inputOptions);
17
+ const options = await createBundlerOptions(inputOptions, outputOptions, false);
18
+ const userOnHmrUpdates = devOptions.onHmrUpdates;
19
+ const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {
20
+ const result = normalizeBindingResult(rawResult);
21
+ if (result instanceof Error) {
22
+ userOnHmrUpdates(result);
23
+ return;
24
+ }
25
+ const [updates, changedFiles] = result;
26
+ userOnHmrUpdates({
27
+ updates,
28
+ changedFiles
29
+ });
30
+ } : void 0;
31
+ const userOnOutput = devOptions.onOutput;
32
+ const bindingDevOptions = {
33
+ onHmrUpdates: bindingOnHmrUpdates,
34
+ onOutput: userOnOutput ? function(rawResult) {
35
+ const result = normalizeBindingResult(rawResult);
36
+ if (result instanceof Error) {
37
+ userOnOutput(result);
38
+ return;
39
+ }
40
+ userOnOutput(transformToRollupOutput(result));
41
+ } : void 0,
42
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding.BindingRebuildStrategy.Auto : import_binding.BindingRebuildStrategy.Never : void 0,
43
+ watch: devOptions.watch && {
44
+ skipWrite: devOptions.watch.skipWrite,
45
+ usePolling: devOptions.watch.usePolling,
46
+ pollInterval: devOptions.watch.pollInterval,
47
+ useDebounce: devOptions.watch.useDebounce,
48
+ debounceDuration: devOptions.watch.debounceDuration,
49
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
50
+ debounceTickRate: devOptions.watch.debounceTickRate
51
+ }
52
+ };
53
+ return new DevEngine(new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
54
+ }
55
+ constructor(inner) {
56
+ this.#inner = inner;
57
+ }
58
+ async run() {
59
+ await this.#inner.run();
60
+ }
61
+ async ensureCurrentBuildFinish() {
62
+ if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
63
+ const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
64
+ this.#cachedBuildFinishPromise = null;
65
+ });
66
+ this.#cachedBuildFinishPromise = promise;
67
+ return promise;
68
+ }
69
+ async getBundleState() {
70
+ return this.#inner.getBundleState();
71
+ }
72
+ async ensureLatestBuildOutput() {
73
+ await this.#inner.ensureLatestBuildOutput();
74
+ }
75
+ async invalidate(file, firstInvalidatedBy) {
76
+ return this.#inner.invalidate(file, firstInvalidatedBy);
77
+ }
78
+ async registerModules(clientId, modules) {
79
+ await this.#inner.registerModules(clientId, modules);
80
+ }
81
+ async removeClient(clientId) {
82
+ await this.#inner.removeClient(clientId);
83
+ }
84
+ async close() {
85
+ await this.#inner.close();
86
+ }
87
+ /**
88
+ * Compile a lazy entry module and return HMR-style patch code.
89
+ *
90
+ * This is called when a dynamically imported module is first requested at runtime.
91
+ * The module was previously stubbed with a proxy, and now we need to compile the
92
+ * actual module and its dependencies.
93
+ *
94
+ * @param moduleId - The absolute file path of the module to compile
95
+ * @param clientId - The client ID requesting this compilation
96
+ * @returns The compiled JavaScript code as a string (HMR patch format)
97
+ */
98
+ async compileEntry(moduleId, clientId) {
99
+ return this.#inner.compileEntry(moduleId, clientId);
100
+ }
101
+ };
102
+ //#endregion
103
+ //#region src/api/dev/index.ts
104
+ const dev = (...args) => DevEngine.create(...args);
105
+ //#endregion
106
+ //#region src/types/external-memory-handle.ts
107
+ const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
108
+ /**
109
+ * Frees the external memory held by the given handle.
110
+ *
111
+ * This is useful when you want to manually release memory held by Rust objects
112
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
113
+ *
114
+ * @param handle - The object with external memory to free
115
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
116
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
117
+ * when accessing properties after the memory is freed.
118
+ * @returns Status object with `freed` boolean and optional `reason` string.
119
+ * - `{ freed: true }` if memory was successfully freed
120
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { freeExternalMemory } from '@rollipop/rolldown/experimental';
125
+ *
126
+ * const output = await bundle.generate();
127
+ * const chunk = output.output[0];
128
+ *
129
+ * // Use the chunk...
130
+ *
131
+ * // Manually free the memory (fast, but accessing properties after will throw)
132
+ * const status = freeExternalMemory(chunk); // { freed: true }
133
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
134
+ *
135
+ * // Keep data alive before freeing (slower, but data remains accessible)
136
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
137
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
138
+ *
139
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
140
+ * ```
141
+ */
142
+ function freeExternalMemory(handle, keepDataAlive = false) {
143
+ return handle[symbolForExternalMemoryHandle](keepDataAlive);
144
+ }
145
+ //#endregion
146
+ //#region src/api/experimental.ts
147
+ /**
148
+ * This is an experimental API. Its behavior may change in the future.
149
+ *
150
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
151
+ * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
152
+ *
153
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
154
+ * ```ts
155
+ * import { scan } from '@rollipop/rolldown/api/experimental';
156
+ *
157
+ * const cleanupPromise = await scan(...);
158
+ * await cleanupPromise;
159
+ * // Now all resources have been cleaned up.
160
+ * ```
161
+ */
162
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
163
+ validateOption("input", rawInputOptions);
164
+ validateOption("output", rawOutputOptions);
165
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
166
+ const bundler = new import_binding.BindingBundler();
167
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();
168
+ async function cleanup() {
169
+ await bundler.close();
170
+ await ret.stopWorkers?.();
171
+ (0, import_binding.shutdownAsyncRuntime)();
172
+ RolldownBuild.asyncRuntimeShutdown = true;
173
+ }
174
+ let cleanupPromise = Promise.resolve();
175
+ try {
176
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
177
+ } catch (err) {
178
+ await cleanup();
179
+ throw err;
180
+ } finally {
181
+ cleanupPromise = cleanup();
182
+ }
183
+ return cleanupPromise;
184
+ };
185
+ //#endregion
186
+ //#region src/plugin/parallel-plugin.ts
187
+ function defineParallelPlugin(pluginPath) {
188
+ return (options) => {
189
+ return { _parallel: {
190
+ fileUrl: pathToFileURL(pluginPath).href,
191
+ options
192
+ } };
193
+ };
194
+ }
195
+ //#endregion
196
+ //#region src/builtin-plugin/alias-plugin.ts
197
+ function viteAliasPlugin(config) {
198
+ return new BuiltinPlugin("builtin:vite-alias", config);
199
+ }
200
+ //#endregion
201
+ //#region src/builtin-plugin/bundle-analyzer-plugin.ts
202
+ /**
203
+ * A plugin that analyzes bundle composition and generates detailed reports.
204
+ *
205
+ * The plugin outputs a file containing detailed information about:
206
+ * - All chunks and their relationships
207
+ * - Modules bundled in each chunk
208
+ * - Import dependencies between chunks
209
+ * - Reachable modules from each entry point
210
+ *
211
+ * @example
212
+ * ```js
213
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
214
+ *
215
+ * export default {
216
+ * plugins: [
217
+ * bundleAnalyzerPlugin()
218
+ * ]
219
+ * }
220
+ * ```
221
+ *
222
+ * @example
223
+ * **Custom filename**
224
+ * ```js
225
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
226
+ *
227
+ * export default {
228
+ * plugins: [
229
+ * bundleAnalyzerPlugin({
230
+ * fileName: 'bundle-analysis.json'
231
+ * })
232
+ * ]
233
+ * }
234
+ * ```
235
+ *
236
+ * @example
237
+ * **LLM-friendly markdown output**
238
+ * ```js
239
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
240
+ *
241
+ * export default {
242
+ * plugins: [
243
+ * bundleAnalyzerPlugin({
244
+ * format: 'md'
245
+ * })
246
+ * ]
247
+ * }
248
+ * ```
249
+ */
250
+ function bundleAnalyzerPlugin(config) {
251
+ return new BuiltinPlugin("builtin:bundle-analyzer", config);
252
+ }
253
+ //#endregion
254
+ //#region src/builtin-plugin/transform-plugin.ts
255
+ function viteTransformPlugin(config) {
256
+ return new BuiltinPlugin("builtin:vite-transform", {
257
+ ...config,
258
+ include: normalizedStringOrRegex(config.include),
259
+ exclude: normalizedStringOrRegex(config.exclude),
260
+ jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
261
+ jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),
262
+ yarnPnp: typeof process === "object" && !!process.versions?.pnp
263
+ });
264
+ }
265
+ //#endregion
266
+ //#region src/builtin-plugin/vite-manifest-plugin.ts
267
+ function viteManifestPlugin(config) {
268
+ return new BuiltinPlugin("builtin:vite-manifest", config);
269
+ }
270
+ //#endregion
271
+ //#region src/builtin-plugin/rollipop-react-refresh-wrapper-plugin.ts
272
+ function rollipopReactRefreshWrapperPlugin(config) {
273
+ return new BuiltinPlugin("builtin:rollipop-react-refresh-wrapper", {
274
+ cwd: config.cwd,
275
+ include: normalizedStringOrRegex(config.include),
276
+ exclude: normalizedStringOrRegex(config.exclude),
277
+ jsxImportSource: config.jsxImportSource
278
+ });
279
+ }
280
+ //#endregion
281
+ //#region src/builtin-plugin/rollipop-worklets-plugin.ts
282
+ function rollipopWorkletsPlugin(config) {
283
+ return new BuiltinPlugin("builtin:rollipop-worklets", config);
284
+ }
285
+ //#endregion
286
+ //#region src/builtin-plugin/rollipop-react-native-plugin.ts
287
+ function rollipopReactNativePlugin(config) {
288
+ const plugins = config?.plugins?.map(([path, pluginConfig]) => ({
289
+ path,
290
+ config: JSON.stringify(pluginConfig ?? {})
291
+ }));
292
+ return new BuiltinPlugin("builtin:rollipop-react-native", {
293
+ runtimeTarget: config?.runtimeTarget,
294
+ envName: config?.envName,
295
+ flow: config?.flow,
296
+ worklets: config?.worklets,
297
+ plugins
298
+ });
299
+ }
300
+ //#endregion
301
+ //#region src/experimental-index.ts
302
+ /**
303
+ * In-memory file system for browser builds.
304
+ *
305
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
306
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
307
+ *
308
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
309
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
310
+ *
311
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * import { memfs } from '@rollipop/rolldown/experimental';
316
+ *
317
+ * // Write files to virtual filesystem before bundling
318
+ * memfs?.volume.fromJSON({
319
+ * '/src/index.js': 'export const foo = 42;',
320
+ * '/package.json': '{"name": "my-app"}'
321
+ * });
322
+ *
323
+ * // Read files from the virtual filesystem
324
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
325
+ * ```
326
+ *
327
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
328
+ */
329
+ const memfs = void 0;
330
+ /** @deprecated Use from `rolldown/utils` instead. */
331
+ const parse = parse$1;
332
+ /** @deprecated Use from `rolldown/utils` instead. */
333
+ const parseSync = parseSync$1;
334
+ /** @deprecated Use from `rolldown/utils` instead. */
335
+ const minify = minify$1;
336
+ /** @deprecated Use from `rolldown/utils` instead. */
337
+ const minifySync = minifySync$1;
338
+ /** @deprecated Use from `rolldown/utils` instead. */
339
+ const transform = transform$1;
340
+ /** @deprecated Use from `rolldown/utils` instead. */
341
+ const transformSync = transformSync$1;
342
+ /** @deprecated Use from `rolldown/utils` instead. */
343
+ const TsconfigCache = TsconfigCache$1;
344
+ //#endregion
345
+ var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;
346
+ var ResolverFactory = import_binding.ResolverFactory;
347
+ var isolatedDeclaration = import_binding.isolatedDeclaration;
348
+ var isolatedDeclarationSync = import_binding.isolatedDeclarationSync;
349
+ var moduleRunnerTransform = import_binding.moduleRunnerTransform;
350
+ export { BindingRebuildStrategy, DevEngine, ResolverFactory, TsconfigCache, bundleAnalyzerPlugin, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, oxcRuntimePlugin, parse, parseSync, resolveTsconfig, rollipopReactNativePlugin, rollipopReactRefreshWrapperPlugin, rollipopWorkletsPlugin, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWebWorkerPostPlugin };