rolldown 1.1.4 → 1.2.0

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 (42) hide show
  1. package/dist/cli.mjs +11 -8
  2. package/dist/config.d.mts +22 -10
  3. package/dist/config.mjs +2 -2
  4. package/dist/experimental-index.d.mts +164 -155
  5. package/dist/experimental-index.mjs +23 -14
  6. package/dist/experimental-runtime-types.d.ts +111 -41
  7. package/dist/filter-index.d.mts +6 -5
  8. package/dist/get-log-filter.d.mts +2 -2
  9. package/dist/index.d.mts +4 -4
  10. package/dist/index.mjs +10 -4
  11. package/dist/parallel-plugin-worker.mjs +2 -2
  12. package/dist/parallel-plugin.d.mts +3 -4
  13. package/dist/parse-ast-index.d.mts +19 -20
  14. package/dist/parse-ast-index.mjs +2 -2
  15. package/dist/plugins-index.d.mts +27 -28
  16. package/dist/plugins-index.mjs +2 -2
  17. package/dist/shared/{binding-B1q9aYT-.d.mts → binding-Dbbi0RbO.d.mts} +49 -25
  18. package/dist/shared/{binding-BmkJW3Wy.mjs → binding-Dby9rwGk.mjs} +26 -26
  19. package/dist/shared/{bindingify-input-options-BsDhfYrS.mjs → bindingify-input-options-_ppP73I9.mjs} +11 -13
  20. package/dist/shared/{constructors-2i1T9YcF.d.mts → constructors-CSWbNgBZ.d.mts} +9 -10
  21. package/dist/shared/{constructors-CE6zZSUt.mjs → constructors-CuGa75s-.mjs} +1 -1
  22. package/dist/shared/define-config-B-IDOhDz.d.mts +4003 -0
  23. package/dist/shared/dist-DKbukT1H.mjs +154 -0
  24. package/dist/shared/{error-BlQ0-ek7.mjs → error-DFGNOCle.mjs} +1 -1
  25. package/dist/shared/get-log-filter-AjBknEEO.d.mts +34 -0
  26. package/dist/shared/{load-config-FRmAU9xl.mjs → load-config-C6UyiS41.mjs} +19 -2
  27. package/dist/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
  28. package/dist/shared/{logs-aMKUxRpj.mjs → logs-ZGEh6uhb.mjs} +6 -1
  29. package/dist/shared/{normalize-string-or-regex-BYkbbGqQ.mjs → normalize-string-or-regex-SiXbePVH.mjs} +2 -2
  30. package/dist/shared/{parse-DVMnkavl.mjs → parse-BFj5G_7i.mjs} +2 -2
  31. package/dist/shared/{prompt-B1Yc1NPt.mjs → prompt--dNycKSZ.mjs} +59 -17
  32. package/dist/shared/{resolve-tsconfig-CdIAR1Eb.mjs → resolve-tsconfig-2TXRF_zr.mjs} +2 -2
  33. package/dist/shared/{rolldown-tbHvKzVl.mjs → rolldown-951h_1lf.mjs} +1 -1
  34. package/dist/shared/{rolldown-build-aV0QeeTW.mjs → rolldown-build-CdF8HAHX.mjs} +33 -13
  35. package/dist/shared/transform-Cs2bUDRH.d.mts +148 -0
  36. package/dist/shared/{watch-DIhJ-T1s.mjs → watch-WnrlHRS0.mjs} +5 -5
  37. package/dist/utils-index.d.mts +29 -30
  38. package/dist/utils-index.mjs +8 -6
  39. package/package.json +23 -22
  40. package/dist/shared/define-config-BBz954-q.d.mts +0 -3901
  41. package/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  42. package/dist/shared/transform-CEmFsvJW.d.mts +0 -149
@@ -0,0 +1,4003 @@
1
+ import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-xuHO4mAy.mjs";
2
+ import { A as BindingWatcherBundler, B as PreRenderedChunk, F as MinifyOptions$1, P as JsxOptions, W as TransformOptions$1, c as BindingHookResolveIdExtraArgs, d as BindingMagicString, f as BindingPluginContextResolveOptions, g as BindingTransformHookExtraArgs, j as ExternalMemoryStatus, m as BindingRenderedChunk, t as BindingBuiltinPluginName, z as ParserOptions } from "./binding-Dbbi0RbO.mjs";
3
+ import { TopLevelFilterExpression } from "@rolldown/pluginutils";
4
+ import { Program } from "@oxc-project/types";
5
+ //#region src/types/misc.d.ts
6
+ /** @inline */
7
+ type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
8
+ /** @inline */
9
+ type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
10
+ //#endregion
11
+ //#region src/types/module-info.d.ts
12
+ /** @category Plugin APIs */
13
+ interface ModuleInfo extends ModuleOptions {
14
+ /**
15
+ * @hidden Not supported by Rolldown
16
+ */
17
+ ast: any;
18
+ /**
19
+ * The source code of the module.
20
+ *
21
+ * `null` if external or not yet available.
22
+ */
23
+ code: string | null;
24
+ /**
25
+ * The id of the module for convenience
26
+ */
27
+ id: string;
28
+ /**
29
+ * The ids of all modules that statically import this module.
30
+ */
31
+ importers: string[];
32
+ /**
33
+ * The ids of all modules that dynamically import this module.
34
+ */
35
+ dynamicImporters: string[];
36
+ /**
37
+ * The module ids statically imported by this module.
38
+ */
39
+ importedIds: string[];
40
+ /**
41
+ * The module ids dynamically imported by this module.
42
+ */
43
+ dynamicallyImportedIds: string[];
44
+ /**
45
+ * All exported variables
46
+ */
47
+ exports: string[];
48
+ /**
49
+ * Whether this module is a user- or plugin-defined entry point.
50
+ */
51
+ isEntry: boolean;
52
+ /**
53
+ * The detected format of the module, based on both its syntax and module definition
54
+ * metadata (such as `package.json` `type` and file extensions like `.mjs`/`.cjs`/`.mts`/`.cts`).
55
+ * - "esm" for ES modules (has `import`/`export` statements or is defined as ESM by module metadata)
56
+ * - "cjs" for CommonJS modules (uses `module.exports`, `exports`, top-level `return`, or is defined as CommonJS by module metadata)
57
+ * - "unknown" when the format could not be determined from either syntax or module definition metadata
58
+ *
59
+ * @experimental
60
+ */
61
+ inputFormat: "es" | "cjs" | "unknown";
62
+ }
63
+ //#endregion
64
+ //#region src/utils/asset-source.d.ts
65
+ /** @inline */
66
+ type AssetSource = string | Uint8Array;
67
+ //#endregion
68
+ //#region src/types/external-memory-handle.d.ts
69
+ declare const symbolForExternalMemoryHandle: "__rolldown_external_memory_handle__";
70
+ /**
71
+ * Interface for objects that hold external memory that can be explicitly freed.
72
+ */
73
+ interface ExternalMemoryHandle {
74
+ /**
75
+ * Frees the external memory held by this object.
76
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory.
77
+ * This will take time but prevents errors when accessing properties after freeing.
78
+ * @returns Status object with `freed` boolean and optional `reason` string.
79
+ * @internal
80
+ */
81
+ [symbolForExternalMemoryHandle]: (keepDataAlive?: boolean) => ExternalMemoryStatus;
82
+ }
83
+ /**
84
+ * Frees the external memory held by the given handle.
85
+ *
86
+ * This is useful when you want to manually release memory held by Rust objects
87
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
88
+ *
89
+ * @param handle - The object with external memory to free
90
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
91
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
92
+ * when accessing properties after the memory is freed.
93
+ * @returns Status object with `freed` boolean and optional `reason` string.
94
+ * - `{ freed: true }` if memory was successfully freed
95
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import { freeExternalMemory } from 'rolldown/experimental';
100
+ *
101
+ * const output = await bundle.generate();
102
+ * const chunk = output.output[0];
103
+ *
104
+ * // Use the chunk...
105
+ *
106
+ * // Manually free the memory (fast, but accessing properties after will throw)
107
+ * const status = freeExternalMemory(chunk); // { freed: true }
108
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
109
+ *
110
+ * // Keep data alive before freeing (slower, but data remains accessible)
111
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
112
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
113
+ *
114
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
115
+ * ```
116
+ */
117
+ declare function freeExternalMemory(handle: ExternalMemoryHandle, keepDataAlive?: boolean): ExternalMemoryStatus;
118
+ //#endregion
119
+ //#region src/types/rolldown-output.d.ts
120
+ /**
121
+ * The information about an asset in the generated bundle.
122
+ *
123
+ * @category Plugin APIs
124
+ */
125
+ interface OutputAsset extends ExternalMemoryHandle {
126
+ type: "asset";
127
+ /** The file name of this asset. */
128
+ fileName: string;
129
+ /** @deprecated Use {@linkcode originalFileNames} instead. */
130
+ originalFileName: string | null;
131
+ /** The list of the absolute paths to the original file of this asset. */
132
+ originalFileNames: string[];
133
+ /** The content of this asset. */
134
+ source: AssetSource;
135
+ /** @deprecated Use {@linkcode names} instead. */
136
+ name: string | undefined;
137
+ names: string[];
138
+ }
139
+ /** @category Plugin APIs */
140
+ interface SourceMap {
141
+ file: string;
142
+ mappings: string;
143
+ names: string[];
144
+ sources: string[];
145
+ sourcesContent: string[];
146
+ version: number;
147
+ debugId?: string;
148
+ x_google_ignoreList?: number[];
149
+ toString(): string;
150
+ toUrl(): string;
151
+ }
152
+ /** @category Plugin APIs */
153
+ interface RenderedModule {
154
+ /**
155
+ * The rendered code of this module.
156
+ *
157
+ * The unused variables and functions are removed.
158
+ */
159
+ readonly code: string | null;
160
+ /**
161
+ * The length of the rendered code of this module.
162
+ */
163
+ renderedLength: number;
164
+ /**
165
+ * The list of exported names from this module.
166
+ *
167
+ * The names that are not used are not included.
168
+ */
169
+ renderedExports: string[];
170
+ }
171
+ /**
172
+ * The information about the chunk being rendered.
173
+ *
174
+ * Unlike {@link OutputChunk}, `code` and `map` are not set as the chunk has not been rendered yet.
175
+ * All referenced chunk file names in each property that would contain hashes will contain hash placeholders instead.
176
+ *
177
+ * @category Plugin APIs
178
+ */
179
+ interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
180
+ type: "chunk";
181
+ /** Information about the modules included in this chunk. */
182
+ modules: {
183
+ [id: string]: RenderedModule;
184
+ };
185
+ /** The name of this chunk, which is used in naming patterns. */
186
+ name: string;
187
+ /** Whether this chunk is a static entry point. */
188
+ isEntry: boolean;
189
+ /** Whether this chunk is a dynamic entry point. */
190
+ isDynamicEntry: boolean;
191
+ /** The id of a module that this chunk corresponds to. */
192
+ facadeModuleId: string | null;
193
+ /** The list of ids of modules included in this chunk. */
194
+ moduleIds: Array<string>;
195
+ /** Exported variable names from this chunk. */
196
+ exports: Array<string>;
197
+ /** The preliminary file name of this chunk with hash placeholders. */
198
+ fileName: string;
199
+ /** External modules imported statically by this chunk. */
200
+ imports: Array<string>;
201
+ /** External modules imported dynamically by this chunk. */
202
+ dynamicImports: Array<string>;
203
+ }
204
+ /**
205
+ * The information about a chunk in the generated bundle.
206
+ *
207
+ * @category Plugin APIs
208
+ */
209
+ interface OutputChunk extends ExternalMemoryHandle {
210
+ type: "chunk";
211
+ /** The generated code of this chunk. */
212
+ code: string;
213
+ /** The name of this chunk, which is used in naming patterns. */
214
+ name: string;
215
+ /** Whether this chunk is a static entry point. */
216
+ isEntry: boolean;
217
+ /** Exported variable names from this chunk. */
218
+ exports: string[];
219
+ /** The file name of this chunk. */
220
+ fileName: string;
221
+ /** Information about the modules included in this chunk. */
222
+ modules: {
223
+ [id: string]: RenderedModule;
224
+ };
225
+ /** External modules imported statically by this chunk. */
226
+ imports: string[];
227
+ /** External modules imported dynamically by this chunk. */
228
+ dynamicImports: string[];
229
+ /** The id of a module that this chunk corresponds to. */
230
+ facadeModuleId: string | null;
231
+ /** Whether this chunk is a dynamic entry point. */
232
+ isDynamicEntry: boolean;
233
+ moduleIds: string[];
234
+ /** The source map of this chunk if present. */
235
+ map: SourceMap | null;
236
+ sourcemapFileName: string | null;
237
+ /** The preliminary file name of this chunk with hash placeholders. */
238
+ preliminaryFileName: string;
239
+ }
240
+ /**
241
+ * The generated bundle output.
242
+ *
243
+ * @category Programmatic APIs
244
+ */
245
+ interface RolldownOutput extends ExternalMemoryHandle {
246
+ /**
247
+ * The list of chunks and assets in the generated bundle.
248
+ *
249
+ * This includes at least one {@linkcode OutputChunk}. It may also include more
250
+ * {@linkcode OutputChunk} and/or {@linkcode OutputAsset}s.
251
+ */
252
+ output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
253
+ }
254
+ //#endregion
255
+ //#region src/types/utils.d.ts
256
+ type MaybePromise<T> = T | Promise<T>;
257
+ /** @inline */
258
+ type NullValue<T = void> = T | undefined | null | void;
259
+ type PartialNull<T> = { [P in keyof T]: T[P] | null; };
260
+ type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
261
+ type MaybeArray<T> = T | T[];
262
+ /** @inline */
263
+ type StringOrRegExp = string | RegExp;
264
+ //#endregion
265
+ //#region src/options/output-options.d.ts
266
+ type GeneratedCodePreset = "es5" | "es2015";
267
+ interface GeneratedCodeOptions {
268
+ /**
269
+ * Whether to use Symbol.toStringTag for namespace objects.
270
+ * @default false
271
+ */
272
+ symbols?: boolean;
273
+ /**
274
+ * Allows choosing one of the presets listed above while overriding some options.
275
+ *
276
+ * ```js
277
+ * export default {
278
+ * output: {
279
+ * generatedCode: {
280
+ * preset: 'es2015',
281
+ * symbols: false
282
+ * }
283
+ * }
284
+ * };
285
+ * ```
286
+ *
287
+ * @default 'es2015'
288
+ */
289
+ preset?: GeneratedCodePreset;
290
+ /**
291
+ * Whether to add readable names to internal variables for profiling purposes.
292
+ *
293
+ * When enabled, generated code will use descriptive variable names that correspond
294
+ * to the original module names, making it easier to profile and debug the bundled code.
295
+ *
296
+ * @default false
297
+ *
298
+ *
299
+ */
300
+ profilerNames?: boolean;
301
+ }
302
+ /** @inline */
303
+ type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
304
+ /** @inline */
305
+ type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
306
+ /** @inline */
307
+ type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
308
+ /** @inline */
309
+ type SanitizeFileNameFunction = (name: string) => string;
310
+ /** @category Plugin APIs */
311
+ interface PreRenderedAsset {
312
+ type: "asset";
313
+ /** @deprecated Use {@linkcode names} instead. */
314
+ name?: string;
315
+ names: string[];
316
+ /** @deprecated Use {@linkcode originalFileNames} instead. */
317
+ originalFileName?: string;
318
+ /** The list of the absolute paths to the original file of this asset. */
319
+ originalFileNames: string[];
320
+ /** The content of this asset. */
321
+ source: AssetSource;
322
+ }
323
+ /** @inline */
324
+ type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
325
+ /** @inline */
326
+ type PathsFunction$1 = (id: string) => string;
327
+ /** @inline */
328
+ type ManualChunksFunction = (moduleId: string, meta: {
329
+ getModuleInfo: (moduleId: string) => ModuleInfo | null;
330
+ }) => string | NullValue;
331
+ /** @inline */
332
+ type GlobalsFunction = (name: string) => string;
333
+ /** @category Plugin APIs */
334
+ type CodeSplittingNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
335
+ /** @inline */
336
+ type CodeSplittingTestFunction = (id: string) => boolean | undefined | void;
337
+ type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
338
+ interface CommentsOptions {
339
+ /**
340
+ * Comments that contain `@license`, `@preserve` or start with `//!` or `/*!`
341
+ */
342
+ legal?: boolean;
343
+ /**
344
+ * Comments that contain `@__PURE__`, `@__NO_SIDE_EFFECTS__` or `@vite-ignore`
345
+ */
346
+ annotation?: boolean;
347
+ /**
348
+ * JSDoc comments
349
+ */
350
+ jsdoc?: boolean;
351
+ }
352
+ /** @inline */
353
+ interface ChunkingContext {
354
+ getModuleInfo(moduleId: string): ModuleInfo | null;
355
+ }
356
+ interface OutputOptions {
357
+ /**
358
+ * The directory in which all generated chunks are placed.
359
+ *
360
+ * The {@linkcode file | output.file} option can be used instead if only a single chunk is generated.
361
+ *
362
+ *
363
+ *
364
+ * @default 'dist'
365
+ */
366
+ dir?: string;
367
+ /**
368
+ * The file path for the single generated chunk.
369
+ *
370
+ * The {@linkcode dir | output.dir} option should be used instead if multiple chunks are generated.
371
+ */
372
+ file?: string;
373
+ /**
374
+ * Which exports mode to use.
375
+ *
376
+ *
377
+ *
378
+ * @default 'auto'
379
+ */
380
+ exports?: "auto" | "named" | "default" | "none";
381
+ /**
382
+ * Specify the character set that Rolldown is allowed to use in file hashes.
383
+ *
384
+ * - `'base64'`: Uses url-safe base64 characters (0-9, a-z, A-Z, -, _). This will produce the shortest hashes.
385
+ * - `'base36'`: Uses alphanumeric characters (0-9, a-z)
386
+ * - `'hex'`: Uses hexadecimal characters (0-9, a-f)
387
+ *
388
+ * @default 'base64'
389
+ */
390
+ hashCharacters?: "base64" | "base36" | "hex";
391
+ /**
392
+ * Expected format of generated code.
393
+ *
394
+ * - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
395
+ * - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
396
+ * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
397
+ * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
398
+ *
399
+ * @default 'es'
400
+ *
401
+ *
402
+ */
403
+ format?: ModuleFormat;
404
+ /**
405
+ * Whether to generate sourcemaps.
406
+ *
407
+ * - `false`: No sourcemap will be generated.
408
+ * - `true`: A separate sourcemap file will be generated.
409
+ * - `'inline'`: The sourcemap will be appended to the output file as a data URL.
410
+ * - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (`//# sourceMappingURL` comment) will not be included in the output file.
411
+ *
412
+ * @default false
413
+ */
414
+ sourcemap?: boolean | "inline" | "hidden";
415
+ /**
416
+ * The base URL for the links to the sourcemap file in the output file.
417
+ *
418
+ * By default, relative URLs are generated. If this option is set, an absolute URL with that base URL will be generated. This is useful when deploying source maps to a different location than your code, such as a CDN or separate debugging server.
419
+ */
420
+ sourcemapBaseUrl?: string;
421
+ /**
422
+ * The pattern to use for sourcemaps created from entry points, or a function that is called per entry chunk with {@linkcode PreRenderedChunk} to return such a pattern.
423
+ *
424
+ * Patterns support the following placeholders:
425
+ * - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
426
+ * - `[hash]`: A hash based only on the content of the final generated sourcemap. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
427
+ * - `[chunkhash]`: The same hash as the one used for the corresponding generated chunk (if any).
428
+ * - `[name]`: The name of the corresponding chunk.
429
+ *
430
+ * Forward slashes (`/`) can be used to place files in sub-directories. This pattern will also be used for every file when setting the {@linkcode preserveModules | output.preserveModules} option.
431
+ *
432
+ * See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
433
+ *
434
+ * @default the corresponding chunk filename with `.map` appended
435
+ */
436
+ sourcemapFileNames?: string | ChunkFileNamesFunction;
437
+ /**
438
+ * Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
439
+ *
440
+ * When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
441
+ *
442
+ * @default false
443
+ */
444
+ sourcemapDebugIds?: boolean;
445
+ /**
446
+ * Control which source files are included in the sourcemap ignore list.
447
+ *
448
+ * Files in the ignore list are excluded from debugger stepping and error stack traces.
449
+ *
450
+ * - `false`: Include no source files in the ignore list
451
+ * - `true`: Include all source files in the ignore list
452
+ * - `string`: Files containing this string in their path will be included in the ignore list
453
+ * - `RegExp`: Files matching this regular expression will be included in the ignore list
454
+ * - `function`: Custom function to determine if a source should be ignored
455
+ *
456
+ * :::tip Performance
457
+ * Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
458
+ * Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
459
+ * :::
460
+ *
461
+ * @example
462
+ * ```js
463
+ * // ✅ Preferred: Use RegExp for better performance
464
+ * sourcemapIgnoreList: /node_modules/
465
+ *
466
+ * // ✅ Preferred: Use string pattern for better performance
467
+ * sourcemapIgnoreList: "vendor"
468
+ *
469
+ * // ! Use sparingly: Function calls have high overhead
470
+ * sourcemapIgnoreList: (source, sourcemapPath) => {
471
+ * return source.includes('node_modules') || source.includes('.min.');
472
+ * }
473
+ * ```
474
+ *
475
+ * @default /node_modules/
476
+ */
477
+ sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | StringOrRegExp;
478
+ /**
479
+ * A transformation to apply to each path in a sourcemap.
480
+ *
481
+ * @example
482
+ * ```js
483
+ * export default defineConfig({
484
+ * output: {
485
+ * sourcemap: true,
486
+ * sourcemapPathTransform: (source, sourcemapPath) => {
487
+ * // Remove 'src/' prefix from all source paths
488
+ * return source.replace(/^src\//, '');
489
+ * },
490
+ * },
491
+ * });
492
+ * ```
493
+ */
494
+ sourcemapPathTransform?: SourcemapPathTransformOption;
495
+ /**
496
+ * Whether to exclude the original source code from sourcemaps.
497
+ *
498
+ * When `true`, the `sourcesContent` field is omitted from the generated sourcemap,
499
+ * reducing the sourcemap file size. The sourcemap will still contain source file paths
500
+ * and mappings, so debugging works if the original files are available.
501
+ *
502
+ * @default false
503
+ */
504
+ sourcemapExcludeSources?: boolean;
505
+ /**
506
+ * A string to prepend to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
507
+ *
508
+ * See {@linkcode intro | output.intro}, {@linkcode postBanner | output.postBanner} as well.
509
+ *
510
+ *
511
+ */
512
+ banner?: string | AddonFunction;
513
+ /**
514
+ * A string to append to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
515
+ *
516
+ * See {@linkcode outro | output.outro}, {@linkcode postFooter | output.postFooter} as well.
517
+ *
518
+ *
519
+ */
520
+ footer?: string | AddonFunction;
521
+ /**
522
+ * A string to prepend to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
523
+ *
524
+ * See {@linkcode banner | output.banner}, {@linkcode intro | output.intro} as well.
525
+ *
526
+ *
527
+ */
528
+ postBanner?: string | AddonFunction;
529
+ /**
530
+ * A string to append to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
531
+ *
532
+ * See {@linkcode footer | output.footer}, {@linkcode outro | output.outro} as well.
533
+ *
534
+ *
535
+ */
536
+ postFooter?: string | AddonFunction;
537
+ /**
538
+ * A string to prepend inside any {@link OutputOptions.format | format}-specific wrapper.
539
+ *
540
+ * See {@linkcode banner | output.banner}, {@linkcode postBanner | output.postBanner} as well.
541
+ *
542
+ *
543
+ */
544
+ intro?: string | AddonFunction;
545
+ /**
546
+ * A string to append inside any {@link OutputOptions.format | format}-specific wrapper.
547
+ *
548
+ * See {@linkcode footer | output.footer}, {@linkcode postFooter | output.postFooter} as well.
549
+ *
550
+ *
551
+ */
552
+ outro?: string | AddonFunction;
553
+ /**
554
+ * Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` {@link OutputOptions.format | formats}.
555
+ *
556
+ * When `true`, the global variable will be defined as `global.name = global.name || {}`.
557
+ * When `false`, the global defined by name will be overwritten like `global.name = {}`.
558
+ *
559
+ * @default false
560
+ */
561
+ extend?: boolean;
562
+ /**
563
+ * Whether to add a `__esModule: true` property when generating exports for non-ES {@link OutputOptions.format | formats}.
564
+ *
565
+ * This property signifies that the exported value is the namespace of an ES module and that the default export of this module corresponds to the `.default` property of the exported object.
566
+ *
567
+ * - `true`: Always add the property when using {@link OutputOptions.exports | named exports mode}, which is similar to what other tools do.
568
+ * - `"if-default-prop"`: Only add the property when using {@link OutputOptions.exports | named exports mode} and there also is a default export. The subtle difference is that if there is no default export, consumers of the CommonJS version of your library will get all named exports as default export instead of an error or `undefined`.
569
+ * - `false`: Never add the property even if the default export would become a property `.default`.
570
+ *
571
+ * @default 'if-default-prop'
572
+ *
573
+ *
574
+ */
575
+ esModule?: boolean | "if-default-prop";
576
+ /**
577
+ * The pattern to use for naming custom emitted assets to include in the build output, or a function that is called per asset with {@linkcode PreRenderedAsset} to return such a pattern.
578
+ *
579
+ * Patterns support the following placeholders:
580
+ * - `[extname]`: The file extension of the asset including a leading dot, e.g. `.css`.
581
+ * - `[ext]`: The file extension without a leading dot, e.g. css.
582
+ * - `[hash]`: A hash based on the content of the asset. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
583
+ * - `[name]`: The file name of the asset excluding any extension.
584
+ *
585
+ * Forward slashes (`/`) can be used to place files in sub-directories.
586
+ *
587
+ * See also {@linkcode chunkFileNames | output.chunkFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
588
+ *
589
+ * @default 'assets/[name]-[hash][extname]'
590
+ */
591
+ assetFileNames?: string | AssetFileNamesFunction;
592
+ /**
593
+ * The pattern to use for chunks created from entry points, or a function that is called per entry chunk with {@linkcode PreRenderedChunk} to return such a pattern.
594
+ *
595
+ * Patterns support the following placeholders:
596
+ * - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
597
+ * - `[hash]`: A hash based only on the content of the final generated chunk, including transformations in `renderChunk` and any referenced file hashes. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
598
+ * - `[name]`: The file name (without extension) of the entry point, unless the object form of input was used to define a different name.
599
+ *
600
+ * Forward slashes (`/`) can be used to place files in sub-directories. This pattern will also be used for every file when setting the {@linkcode preserveModules | output.preserveModules} option.
601
+ *
602
+ * See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
603
+ *
604
+ * @default '[name].js'
605
+ */
606
+ entryFileNames?: string | ChunkFileNamesFunction;
607
+ /**
608
+ * The pattern to use for naming shared chunks created when code-splitting, or a function that is called per chunk with {@linkcode PreRenderedChunk} to return such a pattern.
609
+ *
610
+ * Patterns support the following placeholders:
611
+ * - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
612
+ * - `[hash]`: A hash based only on the content of the final generated chunk, including transformations in `renderChunk` and any referenced file hashes. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
613
+ * - `[name]`: The name of the chunk. This can be explicitly set via the {@linkcode codeSplitting | output.codeSplitting} option or when the chunk is created by a plugin via `this.emitFile`. Otherwise, it will be derived from the chunk contents.
614
+ *
615
+ * Forward slashes (`/`) can be used to place files in sub-directories.
616
+ *
617
+ * See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
618
+ *
619
+ * @default '[name]-[hash].js'
620
+ */
621
+ chunkFileNames?: string | ChunkFileNamesFunction;
622
+ /**
623
+ * Whether to enable chunk name sanitization (removal of non-URL-safe characters like `\0`, `?` and `*`).
624
+ *
625
+ * Set `false` to disable the sanitization. You can also provide a custom sanitization function.
626
+ *
627
+ * @default true
628
+ */
629
+ sanitizeFileName?: boolean | SanitizeFileNameFunction;
630
+ /**
631
+ * Control code minification
632
+ *
633
+ * Rolldown uses Oxc Minifier under the hood. See Oxc's [minification documentation](https://oxc.rs/docs/guide/usage/minifier#features) for more details.
634
+ *
635
+ * - `true`: Enable full minification including code compression and dead code elimination
636
+ * - `false`: Disable minification
637
+ * - `'dce-only'`: Only perform dead code elimination without code compression (default)
638
+ * - `MinifyOptions`: Fine-grained control over minification settings
639
+ *
640
+ * @default 'dce-only'
641
+ */
642
+ minify?: boolean | "dce-only" | MinifyOptions;
643
+ /**
644
+ * Specifies the global variable name that contains the exports of `umd` / `iife` {@link OutputOptions.format | formats}.
645
+ *
646
+ * @example
647
+ * ```js
648
+ * export default defineConfig({
649
+ * output: {
650
+ * format: 'iife',
651
+ * name: 'MyBundle',
652
+ * }
653
+ * });
654
+ * ```
655
+ * ```js
656
+ * // output
657
+ * var MyBundle = (function () {
658
+ * // ...
659
+ * })();
660
+ * ```
661
+ *
662
+ *
663
+ */
664
+ name?: string;
665
+ /**
666
+ * Specifies `id: variableName` pairs necessary for {@link InputOptions.external | external} imports in `umd` / `iife` {@link OutputOptions.format | formats}.
667
+ *
668
+ * @example
669
+ * ```js
670
+ * export default defineConfig({
671
+ * external: ['jquery'],
672
+ * output: {
673
+ * format: 'iife',
674
+ * name: 'MyBundle',
675
+ * globals: {
676
+ * jquery: '$',
677
+ * }
678
+ * }
679
+ * });
680
+ * ```
681
+ * ```js
682
+ * // input
683
+ * import $ from 'jquery';
684
+ * ```
685
+ * ```js
686
+ * // output
687
+ * var MyBundle = (function ($) {
688
+ * // ...
689
+ * })($);
690
+ * ```
691
+ */
692
+ globals?: Record<string, string> | GlobalsFunction;
693
+ /**
694
+ * Maps {@link InputOptions.external | external} module IDs to paths.
695
+ *
696
+ * Allows customizing the path used when importing external dependencies.
697
+ * This is particularly useful for loading dependencies from CDNs or custom locations.
698
+ *
699
+ * - Object form: Maps module IDs to their replacement paths
700
+ * - Function form: Takes a module ID and returns its replacement path
701
+ *
702
+ * @example
703
+ * ```js
704
+ * {
705
+ * paths: {
706
+ * 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
707
+ * }
708
+ * }
709
+ * ```
710
+ *
711
+ * @example
712
+ * ```js
713
+ * {
714
+ * paths: (id) => {
715
+ * if (id.startsWith('lodash')) {
716
+ * return `https://cdn.jsdelivr.net/npm/${id}`
717
+ * }
718
+ * return id
719
+ * }
720
+ * }
721
+ * ```
722
+ */
723
+ paths?: Record<string, string> | PathsFunction$1;
724
+ /**
725
+ * Which language features Rolldown can safely use in generated code.
726
+ *
727
+ * This will not transpile any user code but only change the code Rolldown uses in wrappers and helpers.
728
+ */
729
+ generatedCode?: Partial<GeneratedCodeOptions>;
730
+ /**
731
+ * Whether to generate code to support live bindings for {@link InputOptions.external | external} imports.
732
+ *
733
+ * With the default value of `true`, Rolldown will generate code to support live bindings for external imports.
734
+ *
735
+ * When set to `false`, Rolldown will assume that exports from external modules do not change. This will allow Rolldown to generate smaller code. Note that this can cause issues when there are circular dependencies involving an external dependency.
736
+ *
737
+ * @default true
738
+ *
739
+ *
740
+ */
741
+ externalLiveBindings?: boolean;
742
+ /**
743
+ * @deprecated Please use `codeSplitting: false` instead.
744
+ *
745
+ * Whether to inline dynamic imports instead of creating new chunks to create a single bundle.
746
+ *
747
+ * This option can be used only when a single input is provided.
748
+ *
749
+ * @default false
750
+ */
751
+ inlineDynamicImports?: boolean;
752
+ /**
753
+ * Whether to keep external dynamic imports as `import(...)` expressions in CommonJS output.
754
+ *
755
+ * If set to `false`, external dynamic imports will be rewritten to use `require(...)` calls.
756
+ * This may be necessary to support environments that do not support dynamic `import()` in CommonJS modules like old Node.js versions.
757
+ *
758
+ * @default true
759
+ */
760
+ dynamicImportInCjs?: boolean;
761
+ /**
762
+ * Allows you to do manual chunking. Provided for Rollup compatibility.
763
+ *
764
+ * You could use this option for migration purpose. Under the hood,
765
+ *
766
+ * ```js
767
+ * {
768
+ * manualChunks: (moduleId, meta) => {
769
+ * if (moduleId.includes('node_modules')) {
770
+ * return 'vendor';
771
+ * }
772
+ * return null;
773
+ * }
774
+ * }
775
+ * ```
776
+ *
777
+ * will be transformed to
778
+ *
779
+ * ```js
780
+ * {
781
+ * codeSplitting: {
782
+ * groups: [
783
+ * {
784
+ * name(moduleId) {
785
+ * if (moduleId.includes('node_modules')) {
786
+ * return 'vendor';
787
+ * }
788
+ * return null;
789
+ * },
790
+ * },
791
+ * ],
792
+ * }
793
+ * }
794
+ *
795
+ * ```
796
+ *
797
+ * Note that unlike Rollup, object form is not supported.
798
+ *
799
+ * @deprecated
800
+ * Please use {@linkcode codeSplitting | output.codeSplitting} instead.
801
+ *
802
+ * :::warning
803
+ * If `manualChunks` and `codeSplitting` are both specified, `manualChunks` option will be ignored.
804
+ * :::
805
+ */
806
+ manualChunks?: ManualChunksFunction;
807
+ /**
808
+ * Controls how code splitting is performed.
809
+ *
810
+ * - `true`: Default behavior, automatic code splitting. **(default)**
811
+ * - `false`: Inline all dynamic imports into a single bundle (equivalent to deprecated `inlineDynamicImports: true`).
812
+ * - `object`: Advanced manual code splitting configuration.
813
+ *
814
+ * For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/manual-code-splitting).
815
+ *
816
+ *
817
+ *
818
+ * @example
819
+ * **Basic vendor chunk**
820
+ * ```js
821
+ * export default defineConfig({
822
+ * output: {
823
+ * codeSplitting: {
824
+ * minSize: 20000,
825
+ * groups: [
826
+ * {
827
+ * name: 'vendor',
828
+ * test: /node_modules/,
829
+ * },
830
+ * ],
831
+ * },
832
+ * },
833
+ * });
834
+ * ```
835
+ *
836
+ *
837
+ * @default true
838
+ */
839
+ codeSplitting?: boolean | CodeSplittingOptions;
840
+ /**
841
+ * @deprecated Please use {@linkcode codeSplitting | output.codeSplitting} instead.
842
+ *
843
+ * Allows you to do manual chunking.
844
+ *
845
+ * :::warning
846
+ * If `advancedChunks` and `codeSplitting` are both specified, `advancedChunks` option will be ignored.
847
+ * :::
848
+ */
849
+ advancedChunks?: {
850
+ includeDependenciesRecursively?: boolean;
851
+ minSize?: number;
852
+ maxSize?: number;
853
+ maxModuleSize?: number;
854
+ minModuleSize?: number;
855
+ minShareCount?: number;
856
+ groups?: CodeSplittingGroup[];
857
+ };
858
+ /**
859
+ * Controls how legal comments are preserved in the output.
860
+ *
861
+ * - `none`: no legal comments
862
+ * - `inline`: preserve legal comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
863
+ *
864
+ * @deprecated Use `comments.legal` instead. When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
865
+ */
866
+ legalComments?: "none" | "inline";
867
+ /**
868
+ * Control which comments are preserved in the output.
869
+ *
870
+ * - `true`: Preserve legal, annotation, and JSDoc comments (default)
871
+ * - `false`: Strip all comments
872
+ * - Object: Granular control over comment categories
873
+ *
874
+ * Note: Regular line and block comments without these markers
875
+ * are always removed regardless of this option.
876
+ *
877
+ * When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
878
+ *
879
+ * @default true
880
+ */
881
+ comments?: boolean | CommentsOptions;
882
+ /**
883
+ * The list of plugins to use only for this output.
884
+ *
885
+ * @see {@linkcode InputOptions.plugins | plugins}
886
+ */
887
+ plugins?: RolldownOutputPluginOption;
888
+ /**
889
+ * Whether to add a polyfill for `require()` function in non-CommonJS formats.
890
+ *
891
+ * This option is useful when you want to inject your own `require` implementation.
892
+ *
893
+ * @default true
894
+ */
895
+ polyfillRequire?: boolean;
896
+ /**
897
+ * This option is not implemented yet.
898
+ * @hidden
899
+ */
900
+ hoistTransitiveImports?: false;
901
+ /**
902
+ * Whether to use preserve modules mode.
903
+ *
904
+ *
905
+ *
906
+ * @default false
907
+ */
908
+ preserveModules?: boolean;
909
+ /**
910
+ * Specifies the directory name for "virtual" files that might be emitted by plugins when using {@link OutputOptions.preserveModules | preserve modules mode}.
911
+ *
912
+ * @default '_virtual'
913
+ */
914
+ virtualDirname?: string;
915
+ /**
916
+ * A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using {@link OutputOptions.preserveModules | preserve modules mode}.
917
+ *
918
+ *
919
+ */
920
+ preserveModulesRoot?: string;
921
+ /**
922
+ * Whether to convert top-level `let` and `const` declarations into `var` declarations.
923
+ *
924
+ * Enabling this option can improve runtime performance of the generated code in
925
+ * certain environments by avoiding Temporal Dead Zone (TDZ) checks. Only declarations
926
+ * in the module's top-level scope are rewritten — declarations inside nested scopes
927
+ * (functions, blocks, etc.) are left as-is.
928
+ *
929
+ * Note:
930
+ * - Top-level `class X {}` declarations are always emitted as `var X = class {}` so
931
+ * rolldown can hoist them alongside other top-level bindings; this transform is
932
+ * independent of `topLevelVar`.
933
+ * - Top-level `function` declarations are never rewritten.
934
+ *
935
+ * @default false
936
+ *
937
+ *
938
+ */
939
+ topLevelVar?: boolean;
940
+ /**
941
+ * Whether to minify internal exports as single letter variables to allow for better minification.
942
+ *
943
+ * @default
944
+ * `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
945
+ *
946
+ *
947
+ */
948
+ minifyInternalExports?: boolean;
949
+ /**
950
+ * Clean output directory ({@linkcode dir | output.dir}) before emitting output.
951
+ *
952
+ * @default false
953
+ *
954
+ *
955
+ */
956
+ cleanDir?: boolean;
957
+ /**
958
+ * Keep `name` property of functions and classes after bundling.
959
+ *
960
+ * When enabled, the bundler will preserve the original `name` property value of functions and
961
+ * classes in the output. This is useful for debugging and some frameworks that rely on it for
962
+ * registration and binding purposes.
963
+ *
964
+ *
965
+ *
966
+ * @default false
967
+ */
968
+ keepNames?: boolean;
969
+ /**
970
+ * Lets modules be executed in the order they are declared.
971
+ *
972
+ * This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
973
+ *
974
+ * > [!WARNING]
975
+ * > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
976
+ * @default false
977
+ */
978
+ strictExecutionOrder?: boolean;
979
+ /**
980
+ * Whether to always output `"use strict"` directive in non-ES module outputs.
981
+ *
982
+ * - `true` - Always emit `"use strict"` at the top of the output (not applicable for ESM format since ESM is always strict).
983
+ * - `false` - Never emit `"use strict"` in the output.
984
+ * - `'auto'` - Respect the `"use strict"` directives from the source code.
985
+ *
986
+ * See [In-depth directive guide](https://rolldown.rs/in-depth/directives) for more details.
987
+ *
988
+ * @default 'auto'
989
+ */
990
+ strict?: boolean | "auto";
991
+ }
992
+ /**
993
+ * Built-in module tag names computed by rolldown.
994
+ *
995
+ * - `'$initial'` — the module is statically imported by at least one user-defined entry point, or is part of its static dependency chain.
996
+ */
997
+ type BuiltinModuleTag = "$initial";
998
+ type CodeSplittingGroup = {
999
+ /**
1000
+ * Name of the group. It will be also used as the name of the chunk and replace the `[name]` placeholder in the {@linkcode OutputOptions.chunkFileNames | output.chunkFileNames} option.
1001
+ *
1002
+ * For example,
1003
+ *
1004
+ * ```js
1005
+ * import { defineConfig } from 'rolldown';
1006
+ *
1007
+ * export default defineConfig({
1008
+ * output: {
1009
+ * codeSplitting: {
1010
+ * groups: [
1011
+ * {
1012
+ * name: 'libs',
1013
+ * test: /node_modules/,
1014
+ * },
1015
+ * ],
1016
+ * },
1017
+ * },
1018
+ * });
1019
+ * ```
1020
+ * will create a chunk named `libs-[hash].js` in the end.
1021
+ *
1022
+ * It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
1023
+ *
1024
+ * #### Dynamic `name()`
1025
+ *
1026
+ * If `name` is a function, it will be called with the module id as the argument. The function should return a string or `null`. If it returns `null`, the module will be ignored by this group.
1027
+ *
1028
+ * Notice, each returned new name will be treated as a separate group.
1029
+ *
1030
+ * For example,
1031
+ *
1032
+ * ```js
1033
+ * import { defineConfig } from 'rolldown';
1034
+ *
1035
+ * export default defineConfig({
1036
+ * output: {
1037
+ * codeSplitting: {
1038
+ * groups: [
1039
+ * {
1040
+ * name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
1041
+ * minSize: 100 * 1024,
1042
+ * },
1043
+ * ],
1044
+ * },
1045
+ * },
1046
+ * });
1047
+ * ```
1048
+ *
1049
+ * :::warning
1050
+ * Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
1051
+ * :::
1052
+ */
1053
+ name: string | CodeSplittingNameFunction;
1054
+ /**
1055
+ * Controls which modules are captured in this group.
1056
+ *
1057
+ * - If `test` is a string, the module whose id contains the string will be captured.
1058
+ * - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
1059
+ * - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
1060
+ * - If `test` is empty, any module will be considered as matched.
1061
+ *
1062
+ * :::warning
1063
+ * When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
1064
+ * - ✅ Recommended: `/node_modules[\\/]react/`
1065
+ * - ❌ Not recommended: `/node_modules/react/`
1066
+ * :::
1067
+ */
1068
+ test?: StringOrRegExp | CodeSplittingTestFunction;
1069
+ /**
1070
+ * Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
1071
+ *
1072
+ * If two groups have the same priority, the group whose index is smaller will be chosen.
1073
+ *
1074
+ * @example
1075
+ * ```js
1076
+ * import { defineConfig } from 'rolldown';
1077
+ *
1078
+ * export default defineConfig({
1079
+ * output: {
1080
+ * codeSplitting: {
1081
+ * groups: [
1082
+ * {
1083
+ * name: 'react',
1084
+ * test: /node_modules[\\/]react/,
1085
+ * priority: 2,
1086
+ * },
1087
+ * {
1088
+ * name: 'other-libs',
1089
+ * test: /node_modules/,
1090
+ * priority: 1,
1091
+ * },
1092
+ * ],
1093
+ * },
1094
+ * },
1095
+ * });
1096
+ * ```
1097
+ *
1098
+ * @default 0
1099
+ */
1100
+ priority?: number;
1101
+ /**
1102
+ * Minimum size in bytes of the desired chunk. If the accumulated size of the captured modules by this group is smaller than this value, it will be ignored. Modules in this group will fall back to the `automatic chunking` if they are not captured by any other group.
1103
+ *
1104
+ * @default 0
1105
+ */
1106
+ minSize?: number;
1107
+ /**
1108
+ * Controls if a module should be captured based on how many entry chunks reference it.
1109
+ *
1110
+ * @default 1
1111
+ */
1112
+ minShareCount?: number;
1113
+ /**
1114
+ * If the accumulated size in bytes of the captured modules by this group is larger than this value, this group will be split into multiple groups that each has size close to this value.
1115
+ *
1116
+ * @default Infinity
1117
+ */
1118
+ maxSize?: number;
1119
+ /**
1120
+ * Controls whether a module can only be captured if its size in bytes is smaller than or equal to this value.
1121
+ *
1122
+ * @default Infinity
1123
+ */
1124
+ maxModuleSize?: number;
1125
+ /**
1126
+ * Controls whether a module can only be captured if its size in bytes is larger than or equal to this value.
1127
+ *
1128
+ * @default 0
1129
+ */
1130
+ minModuleSize?: number;
1131
+ /**
1132
+ * When `false` (default), all matching modules are merged into a single chunk.
1133
+ * Every entry that uses any of these modules must load the entire chunk — even
1134
+ * modules it doesn't need.
1135
+ *
1136
+ * When `true`, matching modules are grouped by which entries actually import them.
1137
+ * Modules shared by the same set of entries go into the same chunk, while modules
1138
+ * shared by a different set go into a separate chunk. This way, each entry only
1139
+ * loads the code it actually uses.
1140
+ *
1141
+ * Example: entries A, B, C all match a `"vendor"` group.
1142
+ * - `moduleX` is used by A, B, C
1143
+ * - `moduleY` is used by A, B only
1144
+ *
1145
+ * With `entriesAware: false` → one `vendor.js` chunk with both modules; C loads `moduleY` unnecessarily.
1146
+ * With `entriesAware: true` → `vendor.js` (moduleX, loaded by all) + `vendor2.js` (moduleY, loaded by A and B only).
1147
+ *
1148
+ * @default false
1149
+ */
1150
+ entriesAware?: boolean;
1151
+ /**
1152
+ * Size threshold in bytes for merging small `entriesAware` subgroups into the
1153
+ * closest neighboring subgroup.
1154
+ *
1155
+ * This option only works when {@linkcode CodeSplittingGroup.entriesAware | entriesAware}
1156
+ * is `true`. Set to `0` to disable subgroup merging.
1157
+ *
1158
+ * @default 0
1159
+ */
1160
+ entriesAwareMergeThreshold?: number;
1161
+ /**
1162
+ * Whether to include captured modules' dependencies.
1163
+ *
1164
+ * Enabling this option reduces the chance of generating circular chunks.
1165
+ *
1166
+ * If you want to disable this behavior, it's recommended to both set
1167
+ * - {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures}: `false | 'allow-extension'`
1168
+ * - {@linkcode OutputOptions.strictExecutionOrder | strictExecutionOrder}: `true`
1169
+ *
1170
+ * to avoid generating invalid chunks.
1171
+ *
1172
+ * @default true
1173
+ */
1174
+ includeDependenciesRecursively?: boolean;
1175
+ /**
1176
+ * Filter modules by tags. Only modules that have **all** specified tags
1177
+ * are captured by this group. Combines with `test` and other filters —
1178
+ * a module must match all criteria.
1179
+ *
1180
+ * Built-in tags: `'$initial'` (module is statically imported by a user-defined entry or part of its dependency chain).
1181
+ *
1182
+ * @see {@link https://rolldown.rs/in-depth/manual-code-splitting | Manual Code Splitting}
1183
+ *
1184
+ * @example
1185
+ * ```js
1186
+ * { name: 'initial-deps', tags: ['$initial'], maxSize: 1048576 }
1187
+ * ```
1188
+ */
1189
+ tags?: BuiltinModuleTag[];
1190
+ };
1191
+ /**
1192
+ * Alias for {@linkcode CodeSplittingGroup}. Use this type for the `codeSplitting.groups` option.
1193
+ *
1194
+ * @deprecated Please use {@linkcode CodeSplittingGroup} instead.
1195
+ */
1196
+ type AdvancedChunksGroup = CodeSplittingGroup;
1197
+ /**
1198
+ * Configuration options for advanced code splitting.
1199
+ */
1200
+ type CodeSplittingOptions = {
1201
+ /**
1202
+ * Global fallback of {@linkcode CodeSplittingGroup.includeDependenciesRecursively | group.includeDependenciesRecursively}, if it's not specified in the group.
1203
+ */
1204
+ includeDependenciesRecursively?: boolean;
1205
+ /**
1206
+ * Global fallback of {@linkcode CodeSplittingGroup.minSize | group.minSize}, if it's not specified in the group.
1207
+ */
1208
+ minSize?: number;
1209
+ /**
1210
+ * Global fallback of {@linkcode CodeSplittingGroup.maxSize | group.maxSize}, if it's not specified in the group.
1211
+ */
1212
+ maxSize?: number;
1213
+ /**
1214
+ * Global fallback of {@linkcode CodeSplittingGroup.maxModuleSize | group.maxModuleSize}, if it's not specified in the group.
1215
+ */
1216
+ maxModuleSize?: number;
1217
+ /**
1218
+ * Global fallback of {@linkcode CodeSplittingGroup.minModuleSize | group.minModuleSize}, if it's not specified in the group.
1219
+ */
1220
+ minModuleSize?: number;
1221
+ /**
1222
+ * Global fallback of {@linkcode CodeSplittingGroup.minShareCount | group.minShareCount}, if it's not specified in the group.
1223
+ */
1224
+ minShareCount?: number;
1225
+ /**
1226
+ * Groups to be used for code splitting.
1227
+ */
1228
+ groups?: CodeSplittingGroup[];
1229
+ };
1230
+ /**
1231
+ * Alias for {@linkcode CodeSplittingOptions}. Use this type for the `codeSplitting` option.
1232
+ *
1233
+ * @deprecated Please use {@linkcode CodeSplittingOptions} instead.
1234
+ */
1235
+ type AdvancedChunksOptions = CodeSplittingOptions;
1236
+ //#endregion
1237
+ //#region src/api/build.d.ts
1238
+ /**
1239
+ * The options for {@linkcode build} function.
1240
+ *
1241
+ * @experimental
1242
+ * @category Programmatic APIs
1243
+ */
1244
+ type BuildOptions = InputOptions & {
1245
+ /**
1246
+ * Write the output to the file system
1247
+ *
1248
+ * @default true
1249
+ */
1250
+ write?: boolean;
1251
+ output?: OutputOptions;
1252
+ };
1253
+ /**
1254
+ * Build a single output.
1255
+ *
1256
+ * @param options The build options.
1257
+ * @returns A Promise that resolves to the build output.
1258
+ */
1259
+ declare function build(options: BuildOptions): Promise<RolldownOutput>;
1260
+ /**
1261
+ * Build multiple outputs __sequentially__.
1262
+ *
1263
+ * @param options The build options.
1264
+ * @returns A Promise that resolves to the build outputs for each option.
1265
+ */
1266
+ declare function build(options: BuildOptions[]): Promise<RolldownOutput[]>;
1267
+ //#endregion
1268
+ //#region src/api/rolldown/rolldown-build.d.ts
1269
+ /**
1270
+ * The bundle object returned by {@linkcode rolldown} function.
1271
+ *
1272
+ * @category Programmatic APIs
1273
+ */
1274
+ declare class RolldownBuild {
1275
+ #private;
1276
+ /** @internal */
1277
+ static asyncRuntimeShutdown: boolean;
1278
+ /** @hidden should not be used directly */
1279
+ constructor(inputOptions: InputOptions);
1280
+ /**
1281
+ * Whether the bundle has been closed.
1282
+ *
1283
+ * If the bundle is closed, calling other methods will throw an error.
1284
+ */
1285
+ get closed(): boolean;
1286
+ /**
1287
+ * Generate bundles in-memory.
1288
+ *
1289
+ * If you directly want to write bundles to disk, use the {@linkcode write} method instead.
1290
+ *
1291
+ * @param outputOptions The output options.
1292
+ * @returns The generated bundle.
1293
+ * @throws {@linkcode BundleError} When an error occurs during the build.
1294
+ */
1295
+ generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
1296
+ /**
1297
+ * Generate and write bundles to disk.
1298
+ *
1299
+ * If you want to generate bundles in-memory, use the {@linkcode generate} method instead.
1300
+ *
1301
+ * @param outputOptions The output options.
1302
+ * @returns The generated bundle.
1303
+ * @throws {@linkcode BundleError} When an error occurs during the build.
1304
+ */
1305
+ write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
1306
+ /**
1307
+ * Close the bundle and free resources.
1308
+ *
1309
+ * This method should be called even if the {@linkcode generate} method
1310
+ * or the {@linkcode write} method threw an error. It should be called
1311
+ * even if neither of the methods are called.
1312
+ *
1313
+ * This method is called automatically when using `using` syntax.
1314
+ *
1315
+ * @example
1316
+ * ```js
1317
+ * import { rolldown } from 'rolldown';
1318
+ *
1319
+ * {
1320
+ * using bundle = await rolldown({ input: 'src/main.js' });
1321
+ * const output = await bundle.generate({ format: 'esm' });
1322
+ * console.log(output);
1323
+ * // bundle.close() is called automatically here
1324
+ * }
1325
+ * ```
1326
+ */
1327
+ close(): Promise<void>;
1328
+ /** @hidden documented in close method */
1329
+ [Symbol.asyncDispose](): Promise<void>;
1330
+ /**
1331
+ * @experimental
1332
+ * @hidden not ready for public usage yet
1333
+ */
1334
+ get watchFiles(): Promise<string[]>;
1335
+ }
1336
+ //#endregion
1337
+ //#region src/api/rolldown/index.d.ts
1338
+ /**
1339
+ * The API compatible with Rollup's `rollup` function.
1340
+ *
1341
+ * Unlike Rollup, the module graph is not built until the methods of the bundle object are called.
1342
+ *
1343
+ * @param input The input options object.
1344
+ * @returns A Promise that resolves to a bundle object.
1345
+ *
1346
+ * @example
1347
+ * ```js
1348
+ * import { rolldown } from 'rolldown';
1349
+ *
1350
+ * let bundle, failed = false;
1351
+ * try {
1352
+ * bundle = await rolldown({
1353
+ * input: 'src/main.js',
1354
+ * });
1355
+ * await bundle.write({
1356
+ * format: 'esm',
1357
+ * });
1358
+ * } catch (e) {
1359
+ * console.error(e);
1360
+ * failed = true;
1361
+ * }
1362
+ * if (bundle) {
1363
+ * await bundle.close();
1364
+ * }
1365
+ * process.exitCode = failed ? 1 : 0;
1366
+ * ```
1367
+ *
1368
+ * @category Programmatic APIs
1369
+ */
1370
+ declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
1371
+ //#endregion
1372
+ //#region src/options/watch-options.d.ts
1373
+ /** @category Programmatic APIs */
1374
+ interface WatchOptions extends InputOptions {
1375
+ output?: OutputOptions | OutputOptions[];
1376
+ }
1377
+ //#endregion
1378
+ //#region src/api/watch/watch-emitter.d.ts
1379
+ type ChangeEvent$1 = "create" | "update" | "delete";
1380
+ type RolldownWatchBuild = BindingWatcherBundler;
1381
+ /**
1382
+ * - `START`: the watcher is (re)starting
1383
+ * - `BUNDLE_START`: building an individual bundle
1384
+ * - `BUNDLE_END`: finished building a bundle
1385
+ * - `duration`: the build duration in milliseconds
1386
+ * - `output`: an array of the {@linkcode OutputOptions.file | file} or {@linkcode OutputOptions.dir | dir} option values of the generated outputs
1387
+ * - `result`: the bundle object that can be used to generate additional outputs. This is especially important when the watch.skipWrite option is used. You should call `event.result.close()` once you are done generating outputs, or if you do not generate outputs. This will allow plugins to clean up resources via the `closeBundle` hook.
1388
+ * - `END`: finished building all bundles
1389
+ * - `ERROR`: encountered an error while bundling
1390
+ * - `error`: the error that was thrown
1391
+ * - `result`: the bundle object
1392
+ *
1393
+ * @category Programmatic APIs
1394
+ */
1395
+ type RolldownWatcherEvent = {
1396
+ code: "START";
1397
+ } | {
1398
+ code: "BUNDLE_START";
1399
+ } | {
1400
+ code: "BUNDLE_END";
1401
+ duration: number;
1402
+ output: readonly string[];
1403
+ result: RolldownWatchBuild;
1404
+ } | {
1405
+ code: "END";
1406
+ } | {
1407
+ code: "ERROR";
1408
+ error: Error;
1409
+ result: RolldownWatchBuild;
1410
+ };
1411
+ /**
1412
+ *
1413
+ * @category Programmatic APIs
1414
+ */
1415
+ type RolldownWatcherWatcherEventMap = {
1416
+ event: [data: RolldownWatcherEvent];
1417
+ /** a file was modified */
1418
+ change: [id: string, change: {
1419
+ event: ChangeEvent$1;
1420
+ }];
1421
+ /** a new run was triggered */
1422
+ restart: [];
1423
+ /** the watcher was closed */
1424
+ close: [];
1425
+ };
1426
+ /**
1427
+ * @category Programmatic APIs
1428
+ */
1429
+ interface RolldownWatcher {
1430
+ /**
1431
+ * Register a listener for events defined in {@linkcode RolldownWatcherWatcherEventMap}.
1432
+ */
1433
+ on<E extends keyof RolldownWatcherWatcherEventMap>(event: E, listener: (...args: RolldownWatcherWatcherEventMap[E]) => MaybePromise<void>): this;
1434
+ /**
1435
+ * Unregister a listener for events defined in {@linkcode RolldownWatcherWatcherEventMap}.
1436
+ */
1437
+ off<E extends keyof RolldownWatcherWatcherEventMap>(event: E, listener: (...args: RolldownWatcherWatcherEventMap[E]) => MaybePromise<void>): this;
1438
+ /**
1439
+ * Unregister all listeners for a specific event defined in {@linkcode RolldownWatcherWatcherEventMap}.
1440
+ */
1441
+ clear<E extends keyof RolldownWatcherWatcherEventMap>(event: E): void;
1442
+ /**
1443
+ * Close the watcher and stop listening for file changes.
1444
+ */
1445
+ close(): Promise<void>;
1446
+ }
1447
+ //#endregion
1448
+ //#region src/api/watch/index.d.ts
1449
+ /**
1450
+ * The API compatible with Rollup's `watch` function.
1451
+ *
1452
+ * This function will rebuild the bundle when it detects that the individual modules have changed on disk.
1453
+ *
1454
+ * Note that when using this function, it is your responsibility to call `event.result.close()` in response to the `BUNDLE_END` event to avoid resource leaks.
1455
+ *
1456
+ * @param input The watch options object or the list of them.
1457
+ * @returns A watcher object.
1458
+ *
1459
+ * @example
1460
+ * ```js
1461
+ * import { watch } from 'rolldown';
1462
+ *
1463
+ * const watcher = watch({ /* ... *\/ });
1464
+ * watcher.on('event', (event) => {
1465
+ * if (event.code === 'BUNDLE_END') {
1466
+ * console.log(event.duration);
1467
+ * event.result.close();
1468
+ * }
1469
+ * });
1470
+ *
1471
+ * // Stop watching
1472
+ * watcher.close();
1473
+ * ```
1474
+ *
1475
+ * @experimental
1476
+ * @category Programmatic APIs
1477
+ */
1478
+ declare function watch(input: WatchOptions | WatchOptions[]): RolldownWatcher;
1479
+ //#endregion
1480
+ //#region src/binding-magic-string.d.ts
1481
+ interface RolldownMagicString extends BindingMagicString {
1482
+ readonly isRolldownMagicString: true;
1483
+ /** Accepts a string or RegExp pattern. RegExp supports `$&`, `$$`, and `$N` substitutions. */
1484
+ replace(from: string | RegExp, to: string): this;
1485
+ /** Accepts a string or RegExp pattern. RegExp must have the global (`g`) flag. */
1486
+ replaceAll(from: string | RegExp, to: string): this;
1487
+ }
1488
+ type RolldownMagicStringConstructor = Omit<typeof BindingMagicString, "prototype"> & {
1489
+ new (...args: ConstructorParameters<typeof BindingMagicString>): RolldownMagicString;
1490
+ prototype: RolldownMagicString;
1491
+ };
1492
+ /**
1493
+ * A native MagicString implementation powered by Rust.
1494
+ *
1495
+ * @experimental
1496
+ */
1497
+ declare const RolldownMagicString: RolldownMagicStringConstructor;
1498
+ //#endregion
1499
+ //#region src/log/log-handler.d.ts
1500
+ type LoggingFunction = (log: RolldownLog | string | (() => RolldownLog | string)) => void;
1501
+ type LoggingFunctionWithPosition = (log: RolldownLog | string | (() => RolldownLog | string), pos?: number | {
1502
+ column: number;
1503
+ line: number;
1504
+ }) => void;
1505
+ type WarningHandlerWithDefault = (warning: RolldownLog, defaultHandler: LoggingFunction) => void;
1506
+ //#endregion
1507
+ //#region src/options/generated/checks-options.d.ts
1508
+ interface ChecksOptions {
1509
+ /**
1510
+ * Whether to emit warnings when detecting circular dependency.
1511
+ *
1512
+ * Circular dependencies lead to a bigger bundle size and sometimes cause execution order issues and are better to avoid.
1513
+ *
1514
+ *
1515
+ * @default false
1516
+ * */
1517
+ circularDependency?: boolean;
1518
+ /**
1519
+ * Whether to emit warnings when detecting uses of direct `eval`s.
1520
+ *
1521
+ * See [Avoiding Direct `eval` in Troubleshooting page](https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval) for more details.
1522
+ * @default true
1523
+ * */
1524
+ eval?: boolean;
1525
+ /**
1526
+ * Whether to emit warnings when the `output.globals` option is missing when needed.
1527
+ *
1528
+ * See [`output.globals`](https://rolldown.rs/reference/OutputOptions.globals).
1529
+ * @default true
1530
+ * */
1531
+ missingGlobalName?: boolean;
1532
+ /**
1533
+ * Whether to emit warnings when the `output.name` option is missing when needed.
1534
+ *
1535
+ * See [`output.name`](https://rolldown.rs/reference/OutputOptions.name).
1536
+ * @default true
1537
+ * */
1538
+ missingNameOptionForIifeExport?: boolean;
1539
+ /**
1540
+ * Whether to emit warnings when a `#__PURE__` / `@__PURE__` annotation has no effect due to its position.
1541
+ *
1542
+ * Annotations placed where they cannot annotate a call expression (e.g. before a non-call expression,
1543
+ * before a statement declaration, or between an identifier and `=` in a variable declarator) are
1544
+ * ignored by the parser. Matches Rollup's `INVALID_ANNOTATION` log code.
1545
+ *
1546
+ * By default, warnings are emitted only for local project files inside `cwd` and outside
1547
+ * `node_modules`. Set this option to `false` to disable the warning entirely.
1548
+ * @default true
1549
+ * */
1550
+ invalidAnnotation?: boolean;
1551
+ /**
1552
+ * Whether to emit warnings when the way to export values is ambiguous.
1553
+ *
1554
+ * See [`output.exports`](https://rolldown.rs/reference/OutputOptions.exports).
1555
+ * @default true
1556
+ * */
1557
+ mixedExports?: boolean;
1558
+ /**
1559
+ * Whether to emit warnings when an entrypoint cannot be resolved.
1560
+ * @default true
1561
+ * */
1562
+ unresolvedEntry?: boolean;
1563
+ /**
1564
+ * Whether to emit warnings when an import cannot be resolved.
1565
+ * @default true
1566
+ * */
1567
+ unresolvedImport?: boolean;
1568
+ /**
1569
+ * Whether to emit warnings when files generated have the same name with different contents.
1570
+ *
1571
+ *
1572
+ * @default true
1573
+ * */
1574
+ filenameConflict?: boolean;
1575
+ /**
1576
+ * Whether to emit warnings when a CommonJS variable is used in an ES module.
1577
+ *
1578
+ * CommonJS variables like `module` and `exports` are treated as global variables in ES modules and may not work as expected.
1579
+ *
1580
+ *
1581
+ * @default true
1582
+ * */
1583
+ commonJsVariableInEsm?: boolean;
1584
+ /**
1585
+ * Whether to emit warnings when an imported variable is not exported.
1586
+ *
1587
+ * If the code is importing a variable that is not exported by the imported module, the value will always be `undefined`. This might be a mistake in the code.
1588
+ *
1589
+ *
1590
+ * @default true
1591
+ * */
1592
+ importIsUndefined?: boolean;
1593
+ /**
1594
+ * Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`).
1595
+ *
1596
+ * See [`import.meta` in Non-ESM Output Formats page](https://rolldown.rs/in-depth/non-esm-output-formats#import-meta) for more details.
1597
+ * @default true
1598
+ * */
1599
+ emptyImportMeta?: boolean;
1600
+ /**
1601
+ * Whether to emit warnings when detecting tolerated transform.
1602
+ * @default true
1603
+ * */
1604
+ toleratedTransform?: boolean;
1605
+ /**
1606
+ * Whether to emit warnings when a namespace is called as a function.
1607
+ *
1608
+ * A module namespace object is an object and not a function. Calling it as a function will cause a runtime error.
1609
+ *
1610
+ *
1611
+ * @default true
1612
+ * */
1613
+ cannotCallNamespace?: boolean;
1614
+ /**
1615
+ * Whether to emit warnings when a config value is overridden by another config value with a higher priority.
1616
+ *
1617
+ *
1618
+ * @default true
1619
+ * */
1620
+ configurationFieldConflict?: boolean;
1621
+ /**
1622
+ * Whether to emit warnings when a plugin that is covered by a built-in feature is used.
1623
+ *
1624
+ * Using built-in features is generally more performant than using plugins.
1625
+ * @default true
1626
+ * */
1627
+ preferBuiltinFeature?: boolean;
1628
+ /**
1629
+ * Whether to emit warnings when Rolldown could not clean the output directory.
1630
+ *
1631
+ * See [`output.cleanDir`](https://rolldown.rs/reference/OutputOptions.cleanDir).
1632
+ * @default true
1633
+ * */
1634
+ couldNotCleanDirectory?: boolean;
1635
+ /**
1636
+ * Whether to emit warnings when plugins take significant time during the build process.
1637
+ *
1638
+ *
1639
+ * @default true
1640
+ * */
1641
+ pluginTimings?: boolean;
1642
+ /**
1643
+ * Whether to emit warnings when both the code and postBanner contain shebang
1644
+ *
1645
+ * Having multiple shebangs in a file is a syntax error.
1646
+ * @default true
1647
+ * */
1648
+ duplicateShebang?: boolean;
1649
+ /**
1650
+ * Whether to emit warnings when a tsconfig option or combination of options is not supported.
1651
+ * @default true
1652
+ * */
1653
+ unsupportedTsconfigOption?: boolean;
1654
+ /**
1655
+ * Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting.
1656
+ * @default true
1657
+ * */
1658
+ ineffectiveDynamicImport?: boolean;
1659
+ /**
1660
+ * Whether to emit info logs when a barrel module has a very large number of re-exports (more than 5000).
1661
+ *
1662
+ * Such modules can significantly slow down module resolution. Consider using
1663
+ * [`@rolldown/plugin-transform-imports`](https://github.com/rolldown/plugins/tree/main/packages/transform-imports)
1664
+ * to rewrite barrel imports at the source level so the barrel file is never loaded.
1665
+ *
1666
+ * See [Large barrel modules](https://rolldown.rs/in-depth/lazy-barrel-optimization#large-barrel-modules) for more details.
1667
+ * @default true
1668
+ * */
1669
+ largeBarrelModules?: boolean;
1670
+ /**
1671
+ * Whether to emit warnings when a plugin transforms code without generating a sourcemap.
1672
+ * @default true
1673
+ * */
1674
+ sourcemapBroken?: boolean;
1675
+ }
1676
+ //#endregion
1677
+ //#region src/options/transform-options.d.ts
1678
+ interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
1679
+ /**
1680
+ * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
1681
+ *
1682
+ * See Oxc's [`define` option](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement.html#define) for more details.
1683
+ *
1684
+ * @example
1685
+ * **Replace the global variable `IS_PROD` with `true`**
1686
+ * ```js [rolldown.config.js]
1687
+ * export default defineConfig({
1688
+ * transform: { define: { IS_PROD: 'true' } }
1689
+ * })
1690
+ * ```
1691
+ * Result:
1692
+ * ```js
1693
+ * // Input
1694
+ * if (IS_PROD) {
1695
+ * console.log('Production mode')
1696
+ * }
1697
+ *
1698
+ * // After bundling
1699
+ * if (true) {
1700
+ * console.log('Production mode')
1701
+ * }
1702
+ * ```
1703
+ *
1704
+ * **Replace the property accessor `process.env.NODE_ENV` with `'production'`**
1705
+ * ```js [rolldown.config.js]
1706
+ * export default defineConfig({
1707
+ * transform: { define: { 'process.env.NODE_ENV': "'production'" } }
1708
+ * })
1709
+ * ```
1710
+ * Result:
1711
+ * ```js
1712
+ * // Input
1713
+ * if (process.env.NODE_ENV === 'production') {
1714
+ * console.log('Production mode')
1715
+ * }
1716
+ *
1717
+ * // After bundling
1718
+ * if ('production' === 'production') {
1719
+ * console.log('Production mode')
1720
+ * }
1721
+ * ```
1722
+ */
1723
+ define?: Record<string, string>;
1724
+ /**
1725
+ * Inject import statements on demand.
1726
+ *
1727
+ * The API is aligned with `@rollup/plugin-inject`.
1728
+ *
1729
+ * See Oxc's [`inject` option](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement.html#inject) for more details.
1730
+ *
1731
+ * #### Supported patterns
1732
+ * ```js
1733
+ * {
1734
+ * // import { Promise } from 'es6-promise'
1735
+ * Promise: ['es6-promise', 'Promise'],
1736
+ *
1737
+ * // import { Promise as P } from 'es6-promise'
1738
+ * P: ['es6-promise', 'Promise'],
1739
+ *
1740
+ * // import $ from 'jquery'
1741
+ * $: 'jquery',
1742
+ *
1743
+ * // import * as fs from 'node:fs'
1744
+ * fs: ['node:fs', '*'],
1745
+ *
1746
+ * // Inject shims for property access pattern
1747
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
1748
+ * }
1749
+ * ```
1750
+ */
1751
+ inject?: Record<string, string | [string, string]>;
1752
+ /**
1753
+ * Remove labeled statements with these label names.
1754
+ *
1755
+ * Labeled statements are JavaScript statements prefixed with a label identifier.
1756
+ * This option allows you to strip specific labeled statements from the output,
1757
+ * which is useful for removing debug-only code in production builds.
1758
+ *
1759
+ * @example
1760
+ * ```js rolldown.config.js
1761
+ * export default defineConfig({
1762
+ * transform: { dropLabels: ['DEBUG', 'DEV'] }
1763
+ * })
1764
+ * ```
1765
+ * Result:
1766
+ * ```js
1767
+ * // Input
1768
+ * DEBUG: console.log('Debug info');
1769
+ * DEV: {
1770
+ * console.log('Development mode');
1771
+ * }
1772
+ * console.log('Production code');
1773
+ *
1774
+ * // After bundling
1775
+ * console.log('Production code');
1776
+ * ```
1777
+ */
1778
+ dropLabels?: string[];
1779
+ /**
1780
+ * Controls how JSX syntax is transformed.
1781
+ *
1782
+ * - If set to `false`, an error will be thrown if JSX syntax is encountered.
1783
+ * - If set to `'react'`, JSX syntax will be transformed to classic runtime React code.
1784
+ * - If set to `'react-jsx'`, JSX syntax will be transformed to automatic runtime React code.
1785
+ * - If set to `'preserve'`, JSX syntax will be preserved as-is.
1786
+ */
1787
+ jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
1788
+ }
1789
+ //#endregion
1790
+ //#region src/options/normalized-input-options.d.ts
1791
+ /** @category Plugin APIs */
1792
+ interface NormalizedInputOptions {
1793
+ /** @see {@linkcode InputOptions.input | input} */
1794
+ input: string[] | Record<string, string>;
1795
+ /** @see {@linkcode InputOptions.cwd | cwd} */
1796
+ cwd: string;
1797
+ /** @see {@linkcode InputOptions.platform | platform} */
1798
+ platform: InputOptions["platform"];
1799
+ /** @see {@linkcode InputOptions.shimMissingExports | shimMissingExports} */
1800
+ shimMissingExports: boolean;
1801
+ /** @see {@linkcode InputOptions.context | context} */
1802
+ context: string;
1803
+ /** @see {@linkcode InputOptions.plugins | plugins} */
1804
+ plugins: RolldownPlugin[];
1805
+ }
1806
+ //#endregion
1807
+ //#region src/options/normalized-output-options.d.ts
1808
+ type PathsFunction = (id: string) => string;
1809
+ /**
1810
+ * A normalized version of {@linkcode ModuleFormat}.
1811
+ * @category Plugin APIs
1812
+ */
1813
+ type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
1814
+ /** @category Plugin APIs */
1815
+ interface NormalizedOutputOptions {
1816
+ /** @see {@linkcode OutputOptions.name | name} */
1817
+ name: string | undefined;
1818
+ /** @see {@linkcode OutputOptions.file | file} */
1819
+ file: string | undefined;
1820
+ /** @see {@linkcode OutputOptions.dir | dir} */
1821
+ dir: string | undefined;
1822
+ /** @see {@linkcode OutputOptions.entryFileNames | entryFileNames} */
1823
+ entryFileNames: string | ChunkFileNamesFunction;
1824
+ /** @see {@linkcode OutputOptions.sourcemapFileNames | sourcemapFileNames} */
1825
+ sourcemapFileNames: string | ChunkFileNamesFunction | undefined;
1826
+ /** @see {@linkcode OutputOptions.chunkFileNames | chunkFileNames} */
1827
+ chunkFileNames: string | ChunkFileNamesFunction;
1828
+ /** @see {@linkcode OutputOptions.assetFileNames | assetFileNames} */
1829
+ assetFileNames: string | AssetFileNamesFunction;
1830
+ /** @see {@linkcode OutputOptions.format | format} */
1831
+ format: InternalModuleFormat;
1832
+ /** @see {@linkcode OutputOptions.exports | exports} */
1833
+ exports: NonNullable<OutputOptions["exports"]>;
1834
+ /** @see {@linkcode OutputOptions.sourcemap | sourcemap} */
1835
+ sourcemap: boolean | "inline" | "hidden";
1836
+ /** @see {@linkcode OutputOptions.sourcemapBaseUrl | sourcemapBaseUrl} */
1837
+ sourcemapBaseUrl: string | undefined;
1838
+ /** @see {@linkcode OutputOptions.codeSplitting | codeSplitting} */
1839
+ codeSplitting: boolean;
1840
+ /** @deprecated Use `codeSplitting` instead. */
1841
+ inlineDynamicImports: boolean;
1842
+ /** @see {@linkcode OutputOptions.dynamicImportInCjs | dynamicImportInCjs} */
1843
+ dynamicImportInCjs: boolean;
1844
+ /** @see {@linkcode OutputOptions.externalLiveBindings | externalLiveBindings} */
1845
+ externalLiveBindings: boolean;
1846
+ /** @see {@linkcode OutputOptions.banner | banner} */
1847
+ banner: AddonFunction;
1848
+ /** @see {@linkcode OutputOptions.footer | footer} */
1849
+ footer: AddonFunction;
1850
+ /** @see {@linkcode OutputOptions.postBanner | postBanner} */
1851
+ postBanner: AddonFunction;
1852
+ /** @see {@linkcode OutputOptions.postFooter | postFooter} */
1853
+ postFooter: AddonFunction;
1854
+ /** @see {@linkcode OutputOptions.intro | intro} */
1855
+ intro: AddonFunction;
1856
+ /** @see {@linkcode OutputOptions.outro | outro} */
1857
+ outro: AddonFunction;
1858
+ /** @see {@linkcode OutputOptions.esModule | esModule} */
1859
+ esModule: boolean | "if-default-prop";
1860
+ /** @see {@linkcode OutputOptions.extend | extend} */
1861
+ extend: boolean;
1862
+ /** @see {@linkcode OutputOptions.globals | globals} */
1863
+ globals: Record<string, string> | GlobalsFunction;
1864
+ /** @see {@linkcode OutputOptions.paths | paths} */
1865
+ paths: Record<string, string> | PathsFunction | undefined;
1866
+ /** @see {@linkcode OutputOptions.hashCharacters | hashCharacters} */
1867
+ hashCharacters: "base64" | "base36" | "hex";
1868
+ /** @see {@linkcode OutputOptions.sourcemapDebugIds | sourcemapDebugIds} */
1869
+ sourcemapDebugIds: boolean;
1870
+ /** @see {@linkcode OutputOptions.sourcemapExcludeSources | sourcemapExcludeSources} */
1871
+ sourcemapExcludeSources: boolean;
1872
+ /** @see {@linkcode OutputOptions.sourcemapIgnoreList | sourcemapIgnoreList} */
1873
+ sourcemapIgnoreList: boolean | SourcemapIgnoreListOption | StringOrRegExp | undefined;
1874
+ /** @see {@linkcode OutputOptions.sourcemapPathTransform | sourcemapPathTransform} */
1875
+ sourcemapPathTransform: SourcemapPathTransformOption | undefined;
1876
+ /** @see {@linkcode OutputOptions.minify | minify} */
1877
+ minify: false | MinifyOptions | "dce-only";
1878
+ /**
1879
+ * @deprecated Use `comments.legal` instead.
1880
+ * @see {@linkcode OutputOptions.legalComments | legalComments}
1881
+ */
1882
+ legalComments: "none" | "inline";
1883
+ /** @see {@linkcode OutputOptions.comments | comments} */
1884
+ comments: Required<CommentsOptions>;
1885
+ /** @see {@linkcode OutputOptions.polyfillRequire | polyfillRequire} */
1886
+ polyfillRequire: boolean;
1887
+ /** @see {@linkcode OutputOptions.plugins | plugins} */
1888
+ plugins: RolldownPlugin[];
1889
+ /** @see {@linkcode OutputOptions.preserveModules | preserveModules} */
1890
+ preserveModules: boolean;
1891
+ /** @see {@linkcode OutputOptions.virtualDirname | virtualDirname} */
1892
+ virtualDirname: string;
1893
+ /** @see {@linkcode OutputOptions.preserveModulesRoot | preserveModulesRoot} */
1894
+ preserveModulesRoot?: string;
1895
+ /** @see {@linkcode OutputOptions.topLevelVar | topLevelVar} */
1896
+ topLevelVar?: boolean;
1897
+ /** @see {@linkcode OutputOptions.minifyInternalExports | minifyInternalExports} */
1898
+ minifyInternalExports?: boolean;
1899
+ }
1900
+ //#endregion
1901
+ //#region src/plugin/fs.d.ts
1902
+ /** @category Plugin APIs */
1903
+ interface RolldownFsModule {
1904
+ appendFile(path: string, data: string | Uint8Array, options?: {
1905
+ encoding?: BufferEncoding | null;
1906
+ mode?: string | number;
1907
+ flag?: string | number;
1908
+ }): Promise<void>;
1909
+ copyFile(source: string, destination: string, mode?: string | number): Promise<void>;
1910
+ mkdir(path: string, options?: {
1911
+ recursive?: boolean;
1912
+ mode?: string | number;
1913
+ }): Promise<void>;
1914
+ mkdtemp(prefix: string): Promise<string>;
1915
+ readdir(path: string, options?: {
1916
+ withFileTypes?: false;
1917
+ }): Promise<string[]>;
1918
+ readdir(path: string, options?: {
1919
+ withFileTypes: true;
1920
+ }): Promise<RolldownDirectoryEntry[]>;
1921
+ readFile(path: string, options?: {
1922
+ encoding?: null;
1923
+ flag?: string | number;
1924
+ signal?: AbortSignal;
1925
+ }): Promise<Uint8Array>;
1926
+ readFile(path: string, options?: {
1927
+ encoding: BufferEncoding;
1928
+ flag?: string | number;
1929
+ signal?: AbortSignal;
1930
+ }): Promise<string>;
1931
+ realpath(path: string): Promise<string>;
1932
+ rename(oldPath: string, newPath: string): Promise<void>;
1933
+ rmdir(path: string, options?: {
1934
+ recursive?: boolean;
1935
+ }): Promise<void>;
1936
+ stat(path: string): Promise<RolldownFileStats>;
1937
+ lstat(path: string): Promise<RolldownFileStats>;
1938
+ unlink(path: string): Promise<void>;
1939
+ writeFile(path: string, data: string | Uint8Array, options?: {
1940
+ encoding?: BufferEncoding | null;
1941
+ mode?: string | number;
1942
+ flag?: string | number;
1943
+ }): Promise<void>;
1944
+ }
1945
+ /** @category Plugin APIs */
1946
+ type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
1947
+ /** @category Plugin APIs */
1948
+ interface RolldownDirectoryEntry {
1949
+ isFile(): boolean;
1950
+ isDirectory(): boolean;
1951
+ isSymbolicLink(): boolean;
1952
+ name: string;
1953
+ }
1954
+ /** @category Plugin APIs */
1955
+ interface RolldownFileStats {
1956
+ isFile(): boolean;
1957
+ isDirectory(): boolean;
1958
+ isSymbolicLink(): boolean;
1959
+ size: number;
1960
+ mtime: Date;
1961
+ ctime: Date;
1962
+ atime: Date;
1963
+ birthtime: Date;
1964
+ }
1965
+ //#endregion
1966
+ //#region src/plugin/hook-filter.d.ts
1967
+ /** @category Plugin APIs */
1968
+ type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
1969
+ include?: MaybeArray<Value>;
1970
+ exclude?: MaybeArray<Value>;
1971
+ };
1972
+ interface FormalModuleTypeFilter {
1973
+ include?: ModuleType[];
1974
+ }
1975
+ /** @category Plugin APIs */
1976
+ type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
1977
+ /**
1978
+ * A filter to be used to do a pre-test to determine whether the hook should be called.
1979
+ *
1980
+ * See [Plugin Hook Filters page](https://rolldown.rs/apis/plugin-api/hook-filters) for more details.
1981
+ *
1982
+ * @category Plugin APIs
1983
+ */
1984
+ interface HookFilter {
1985
+ /**
1986
+ * A filter based on the module `id`.
1987
+ *
1988
+ * If the value is a string, it is treated as a glob pattern.
1989
+ * The string type is not available for {@linkcode Plugin.resolveId | resolveId} hook.
1990
+ *
1991
+ * @example
1992
+ * Include all `id`s that contain `node_modules` in the path.
1993
+ * ```js
1994
+ * { id: '**'+'/node_modules/**' }
1995
+ * ```
1996
+ * @example
1997
+ * Include all `id`s that contain `node_modules` or `src` in the path.
1998
+ * ```js
1999
+ * { id: ['**'+'/node_modules/**', '**'+'/src/**'] }
2000
+ * ```
2001
+ * @example
2002
+ * Include all `id`s that start with `http`
2003
+ * ```js
2004
+ * { id: /^http/ }
2005
+ * ```
2006
+ * @example
2007
+ * Exclude all `id`s that contain `node_modules` in the path.
2008
+ * ```js
2009
+ * { id: { exclude: '**'+'/node_modules/**' } }
2010
+ * ```
2011
+ * @example
2012
+ * Formal pattern to define includes and excludes.
2013
+ * ```js
2014
+ * { id : {
2015
+ * include: ['**'+'/foo/**', /bar/],
2016
+ * exclude: ['**'+'/baz/**', /qux/]
2017
+ * }}
2018
+ * ```
2019
+ */
2020
+ id?: GeneralHookFilter;
2021
+ /**
2022
+ * A filter based on the module's `moduleType`.
2023
+ *
2024
+ * Only available for {@linkcode Plugin.transform | transform} hook.
2025
+ */
2026
+ moduleType?: ModuleTypeFilter;
2027
+ /**
2028
+ * A filter based on the module's code.
2029
+ *
2030
+ * Only available for {@linkcode Plugin.transform | transform} hook.
2031
+ */
2032
+ code?: GeneralHookFilter;
2033
+ }
2034
+ //#endregion
2035
+ //#region src/plugin/minimal-plugin-context.d.ts
2036
+ /** @category Plugin APIs */
2037
+ interface PluginContextMeta {
2038
+ /**
2039
+ * A property for Rollup compatibility. A dummy value is set by Rolldown.
2040
+ * @example `'4.23.0'`
2041
+ */
2042
+ rollupVersion: string;
2043
+ /**
2044
+ * The currently running version of Rolldown.
2045
+ * @example `'1.0.0'`
2046
+ */
2047
+ rolldownVersion: string;
2048
+ /**
2049
+ * Whether Rolldown was started via {@linkcode watch | rolldown.watch()} or
2050
+ * from the command line with `--watch`.
2051
+ */
2052
+ watchMode: boolean;
2053
+ }
2054
+ /** @category Plugin APIs */
2055
+ interface MinimalPluginContext {
2056
+ /**
2057
+ * Similar to {@linkcode warn | this.warn}, except that it will also abort
2058
+ * the bundling process with an error.
2059
+ *
2060
+ * If an Error instance is passed, it will be used as-is, otherwise a new Error
2061
+ * instance will be created with the given error message and all additional
2062
+ * provided properties.
2063
+ *
2064
+ * In all hooks except the {@linkcode Plugin.onLog | onLog} hook, the error will
2065
+ * be augmented with {@linkcode RolldownLog.code | code: "PLUGIN_ERROR"} and
2066
+ * {@linkcode RolldownLog.plugin | plugin: plugin.name} properties.
2067
+ * If a `code` property already exists and the code does not start with `PLUGIN_`,
2068
+ * it will be renamed to {@linkcode RolldownLog.pluginCode | pluginCode}.
2069
+ *
2070
+ * @group Logging Methods
2071
+ */
2072
+ error: (e: RolldownError | string) => never;
2073
+ /**
2074
+ * Generate a `"info"` level log.
2075
+ *
2076
+ * {@linkcode RolldownLog.code | code} will be set to `"PLUGIN_LOG"` by Rolldown.
2077
+ * As these logs are displayed by default, use them for information that is not a warning
2078
+ * but makes sense to display to all users on every build.
2079
+ *
2080
+ *
2081
+ *
2082
+ * @inlineType LoggingFunction
2083
+ * @group Logging Methods
2084
+ */
2085
+ info: LoggingFunction;
2086
+ /**
2087
+ * Generate a `"warn"` level log.
2088
+ *
2089
+ * Just like internally generated warnings, these logs will be first passed to and
2090
+ * filtered by plugin {@linkcode Plugin.onLog | onLog} hooks before they are forwarded
2091
+ * to custom {@linkcode InputOptions.onLog | onLog} or
2092
+ * {@linkcode InputOptions.onwarn | onwarn} handlers or printed to the console.
2093
+ *
2094
+ * We encourage you to use objects with a {@linkcode RolldownLog.pluginCode | pluginCode}
2095
+ * property as that will allow users to easily filter for those logs in an `onLog` handler.
2096
+ *
2097
+ *
2098
+ *
2099
+ * @inlineType LoggingFunction
2100
+ * @group Logging Methods
2101
+ */
2102
+ warn: LoggingFunction;
2103
+ /**
2104
+ * Generate a `"debug"` level log.
2105
+ *
2106
+ * {@linkcode RolldownLog.code | code} will be set to `"PLUGIN_LOG"` by Rolldown.
2107
+ * Make sure to add a distinctive {@linkcode RolldownLog.pluginCode | pluginCode} to
2108
+ * those logs for easy filtering.
2109
+ *
2110
+ *
2111
+ *
2112
+ * @inlineType LoggingFunction
2113
+ * @group Logging Methods
2114
+ */
2115
+ debug: LoggingFunction;
2116
+ /** An object containing potentially useful metadata. */
2117
+ meta: PluginContextMeta;
2118
+ }
2119
+ //#endregion
2120
+ //#region src/plugin/parallel-plugin.d.ts
2121
+ type ParallelPlugin = {
2122
+ _parallel: {
2123
+ fileUrl: string;
2124
+ options: unknown;
2125
+ };
2126
+ };
2127
+ /** @internal */
2128
+ type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
2129
+ declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
2130
+ //#endregion
2131
+ //#region src/plugin/plugin-context.d.ts
2132
+ /**
2133
+ * Either a {@linkcode name} or a {@linkcode fileName} can be supplied.
2134
+ * If a {@linkcode fileName} is provided, it will be used unmodified as the name
2135
+ * of the generated file, throwing an error if this causes a conflict.
2136
+ * Otherwise, if a {@linkcode name} is supplied, this will be used as substitution
2137
+ * for `[name]` in the corresponding
2138
+ * {@linkcode OutputOptions.assetFileNames | output.assetFileNames} pattern, possibly
2139
+ * adding a unique number to the end of the file name to avoid conflicts.
2140
+ * If neither a {@linkcode name} nor {@linkcode fileName} is supplied, a default name will be used.
2141
+ *
2142
+ * @category Plugin APIs
2143
+ */
2144
+ interface EmittedAsset {
2145
+ type: "asset";
2146
+ name?: string;
2147
+ fileName?: string;
2148
+ /**
2149
+ * An absolute path to the original file if this asset corresponds to a file on disk.
2150
+ *
2151
+ * This property will be passed on to subsequent plugin hooks that receive a
2152
+ * {@linkcode PreRenderedAsset} or an {@linkcode OutputAsset} like
2153
+ * {@linkcode Plugin.generateBundle | generateBundle}.
2154
+ * In watch mode, Rolldown will also automatically watch this file for changes and
2155
+ * trigger a rebuild if it changes. Therefore, it is not necessary to call
2156
+ * {@linkcode PluginContext.addWatchFile | this.addWatchFile} for this file.
2157
+ */
2158
+ originalFileName?: string;
2159
+ source: AssetSource;
2160
+ }
2161
+ /**
2162
+ * Either a {@linkcode name} or a {@linkcode fileName} can be supplied.
2163
+ * If a {@linkcode fileName} is provided, it will be used unmodified as the name
2164
+ * of the generated file, throwing an error if this causes a conflict.
2165
+ * Otherwise, if a {@linkcode name} is supplied, this will be used as substitution
2166
+ * for `[name]` in the corresponding
2167
+ * {@linkcode OutputOptions.chunkFileNames | output.chunkFileNames} pattern, possibly
2168
+ * adding a unique number to the end of the file name to avoid conflicts.
2169
+ * If neither a {@linkcode name} nor {@linkcode fileName} is supplied, a default name will be used.
2170
+ *
2171
+ * @category Plugin APIs
2172
+ */
2173
+ interface EmittedChunk {
2174
+ type: "chunk";
2175
+ name?: string;
2176
+ fileName?: string;
2177
+ /**
2178
+ * When provided, this will override
2179
+ * {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures} for this particular
2180
+ * chunk.
2181
+ */
2182
+ preserveSignature?: "strict" | "allow-extension" | "exports-only" | false;
2183
+ /**
2184
+ * The module id of the entry point of the chunk.
2185
+ *
2186
+ * It will be passed through build hooks just like regular entry points,
2187
+ * starting with {@linkcode Plugin.resolveId | resolveId}.
2188
+ */
2189
+ id: string;
2190
+ /**
2191
+ * The value to be passed to {@linkcode Plugin.resolveId | resolveId}'s {@linkcode importer} parameter when resolving the entry point.
2192
+ * This is important to properly resolve relative paths. If it is not provided,
2193
+ * paths will be resolved relative to the current working directory.
2194
+ */
2195
+ importer?: string;
2196
+ }
2197
+ /** @category Plugin APIs */
2198
+ interface EmittedPrebuiltChunk {
2199
+ type: "prebuilt-chunk";
2200
+ fileName: string;
2201
+ /**
2202
+ * A semantic name for the chunk. If not provided, `fileName` will be used.
2203
+ */
2204
+ name?: string;
2205
+ /**
2206
+ * The code of this chunk.
2207
+ */
2208
+ code: string;
2209
+ /**
2210
+ * The list of exported variable names from this chunk.
2211
+ *
2212
+ * This should be provided if the chunk exports any variables.
2213
+ */
2214
+ exports?: string[];
2215
+ /**
2216
+ * The corresponding source map for this chunk.
2217
+ */
2218
+ map?: SourceMap;
2219
+ sourcemapFileName?: string;
2220
+ /**
2221
+ * The module id of the facade module for this chunk, if any.
2222
+ */
2223
+ facadeModuleId?: string;
2224
+ /**
2225
+ * Whether this chunk corresponds to an entry point.
2226
+ */
2227
+ isEntry?: boolean;
2228
+ /**
2229
+ * Whether this chunk corresponds to a dynamic entry point.
2230
+ */
2231
+ isDynamicEntry?: boolean;
2232
+ }
2233
+ /** @inline @category Plugin APIs */
2234
+ type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
2235
+ /** @category Plugin APIs */
2236
+ interface PluginContextResolveOptions {
2237
+ /**
2238
+ * The value for {@linkcode ResolveIdExtraOptions.kind | kind} passed to
2239
+ * {@linkcode Plugin.resolveId | resolveId} hooks.
2240
+ */
2241
+ kind?: BindingPluginContextResolveOptions["importKind"];
2242
+ /**
2243
+ * The value for {@linkcode ResolveIdExtraOptions.isEntry | isEntry} passed to
2244
+ * {@linkcode Plugin.resolveId | resolveId} hooks.
2245
+ *
2246
+ * @default `false` if there's an importer, `true` otherwise.
2247
+ */
2248
+ isEntry?: boolean;
2249
+ /**
2250
+ * Whether the {@linkcode Plugin.resolveId | resolveId} hook of the plugin from
2251
+ * which {@linkcode PluginContext.resolve | this.resolve} is called will be skipped
2252
+ * when resolving.
2253
+ *
2254
+ *
2255
+ *
2256
+ * @default true
2257
+ */
2258
+ skipSelf?: boolean;
2259
+ /**
2260
+ * Plugin-specific options.
2261
+ *
2262
+ * See [Custom resolver options section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-resolver-options) for more details.
2263
+ */
2264
+ custom?: CustomPluginOptions;
2265
+ }
2266
+ /** @inline */
2267
+ type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
2268
+ /** @category Plugin APIs */
2269
+ interface PluginContext extends MinimalPluginContext {
2270
+ /**
2271
+ * Provides abstract access to the file system.
2272
+ */
2273
+ fs: RolldownFsModule;
2274
+ /**
2275
+ * Emits a new file that is included in the build output.
2276
+ * You can emit chunks, prebuilt chunks or assets.
2277
+ *
2278
+ *
2279
+ *
2280
+ * @returns A `referenceId` for the emitted file that can be used in various places to reference the emitted file.
2281
+ */
2282
+ emitFile(file: EmittedFile): string;
2283
+ /**
2284
+ * Get the file name of a chunk or asset that has been emitted via
2285
+ * {@linkcode emitFile | this.emitFile}.
2286
+ *
2287
+ * @returns The file name of the emitted file. Relative to {@linkcode OutputOptions.dir | output.dir}.
2288
+ */
2289
+ getFileName(referenceId: string): string;
2290
+ /**
2291
+ * Get all module ids in the current module graph.
2292
+ *
2293
+ * @returns
2294
+ * An iterator of module ids. It can be iterated via
2295
+ * ```js
2296
+ * for (const moduleId of this.getModuleIds()) {
2297
+ * // ...
2298
+ * }
2299
+ * ```
2300
+ * or converted into an array via `Array.from(this.getModuleIds())`.
2301
+ */
2302
+ getModuleIds(): IterableIterator<string>;
2303
+ /**
2304
+ * Get additional information about the module in question.
2305
+ *
2306
+ *
2307
+ *
2308
+ * @returns Module information for that module. `null` if the module could not be found.
2309
+ * @group Methods
2310
+ */
2311
+ getModuleInfo: GetModuleInfo;
2312
+ /**
2313
+ * Adds additional files to be monitored in watch mode so that changes to these files will trigger rebuilds.
2314
+ *
2315
+ *
2316
+ */
2317
+ addWatchFile(id: string): void;
2318
+ /**
2319
+ * Loads and parses the module corresponding to the given id, attaching additional
2320
+ * meta information to the module if provided. This will trigger the same
2321
+ * {@linkcode Plugin.load | load}, {@linkcode Plugin.transform | transform} and
2322
+ * {@linkcode Plugin.moduleParsed | moduleParsed} hooks as if the module was imported
2323
+ * by another module.
2324
+ *
2325
+ *
2326
+ */
2327
+ load(options: {
2328
+ id: string;
2329
+ resolveDependencies?: boolean;
2330
+ } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
2331
+ /**
2332
+ * Use Rolldown's internal parser to parse code to an [ESTree-compatible](https://github.com/estree/estree) AST.
2333
+ */
2334
+ parse(input: string, options?: ParserOptions | null): Program;
2335
+ /**
2336
+ * Resolve imports to module ids (i.e. file names) using the same plugins that Rolldown uses,
2337
+ * and determine if an import should be external.
2338
+ *
2339
+ * When calling this function from a {@linkcode Plugin.resolveId | resolveId} hook, you should
2340
+ * always check if it makes sense for you to pass along the
2341
+ * {@link PluginContextResolveOptions | options}.
2342
+ *
2343
+ * @returns
2344
+ * If `Promise<null>` is returned, the import could not be resolved by Rolldown or any plugin
2345
+ * but was not explicitly marked as external by the user.
2346
+ * If an absolute external id is returned that should remain absolute in the output either
2347
+ * via the
2348
+ * {@linkcode InputOptions.makeAbsoluteExternalsRelative | makeAbsoluteExternalsRelative}
2349
+ * option or by explicit plugin choice in the {@linkcode Plugin.resolveId | resolveId} hook,
2350
+ * `external` will be `"absolute"` instead of `true`.
2351
+ */
2352
+ resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
2353
+ }
2354
+ //#endregion
2355
+ //#region src/plugin/transform-plugin-context.d.ts
2356
+ /** @category Plugin APIs */
2357
+ interface TransformPluginContext extends PluginContext {
2358
+ /**
2359
+ * Same as {@linkcode PluginContext.debug}, but a `position` param can be supplied.
2360
+ *
2361
+ * @inlineType LoggingFunctionWithPosition
2362
+ * @group Logging Methods
2363
+ */
2364
+ debug: LoggingFunctionWithPosition;
2365
+ /**
2366
+ * Same as {@linkcode PluginContext.info}, but a `position` param can be supplied.
2367
+ *
2368
+ * @inlineType LoggingFunctionWithPosition
2369
+ * @group Logging Methods
2370
+ */
2371
+ info: LoggingFunctionWithPosition;
2372
+ /**
2373
+ * Same as {@linkcode PluginContext.warn}, but a `position` param can be supplied.
2374
+ *
2375
+ * @inlineType LoggingFunctionWithPosition
2376
+ * @group Logging Methods
2377
+ */
2378
+ warn: LoggingFunctionWithPosition;
2379
+ /**
2380
+ * Same as {@linkcode PluginContext.error}, but the `id` of the current module will
2381
+ * also be added and a `position` param can be supplied.
2382
+ */
2383
+ error(e: RolldownError | string, pos?: number | {
2384
+ column: number;
2385
+ line: number;
2386
+ }): never;
2387
+ /**
2388
+ * Get the combined source maps of all previous plugins.
2389
+ */
2390
+ getCombinedSourcemap(): SourceMap;
2391
+ }
2392
+ //#endregion
2393
+ //#region src/types/module-side-effects.d.ts
2394
+ interface ModuleSideEffectsRule {
2395
+ test?: RegExp;
2396
+ external?: boolean;
2397
+ sideEffects: boolean;
2398
+ }
2399
+ type ModuleSideEffectsOption = boolean | readonly string[] | ModuleSideEffectsRule[] | ((id: string, external: boolean) => boolean | undefined) | "no-external";
2400
+ /**
2401
+ * When passing an object, you can fine-tune the tree-shaking behavior.
2402
+ */
2403
+ type TreeshakingOptions = {
2404
+ /**
2405
+ * **Values:**
2406
+ *
2407
+ * - **`true`**: All modules are assumed to have side effects and will be included in the bundle even if none of their exports are used.
2408
+ * - **`false`**: No modules have side effects. This enables aggressive tree-shaking, removing any modules whose exports are not used.
2409
+ * - **`string[]`**: Array of module IDs that have side effects. Only modules in this list will be preserved if unused; all others can be tree-shaken when their exports are unused.
2410
+ * - **`'no-external'`**: Assumes no external modules have side effects while preserving the default behavior for local modules.
2411
+ * - **`ModuleSideEffectsRule[]`**: Array of rules with `test`, `external`, and `sideEffects` properties for fine-grained control.
2412
+ * - **`function`**: Function that receives `(id, external)` and returns whether the module has side effects.
2413
+ *
2414
+ * **Important:** Setting this to `false` or using an array/string assumes that your modules and their dependencies have no side effects other than their exports. Only use this if you're certain that removing unused modules won't break your application.
2415
+ *
2416
+ * > [!NOTE]
2417
+ * > **Performance: Prefer `ModuleSideEffectsRule[]` over functions**
2418
+ * >
2419
+ * > When possible, use rule-based configuration instead of functions. Rules are processed entirely in Rust, while JavaScript functions require runtime calls between Rust and JavaScript, which can hurt CPU utilization during builds.
2420
+ * >
2421
+ * > **Functions should be a last resort**: Only use the function signature when your logic cannot be expressed with patterns or simple string matching.
2422
+ * >
2423
+ * > **Rule advantages**: `ModuleSideEffectsRule[]` provides better performance by avoiding Rust-JavaScript runtime calls, clearer intent, and easier maintenance.
2424
+ *
2425
+ * @example
2426
+ * ```js
2427
+ * // Assume no modules have side effects (aggressive tree-shaking)
2428
+ * treeshake: {
2429
+ * moduleSideEffects: false
2430
+ * }
2431
+ *
2432
+ * // Only specific modules have side effects (string array)
2433
+ * treeshake: {
2434
+ * moduleSideEffects: [
2435
+ * 'lodash',
2436
+ * 'react-dom',
2437
+ * ]
2438
+ * }
2439
+ *
2440
+ * // Use rules for pattern matching and granular control
2441
+ * treeshake: {
2442
+ * moduleSideEffects: [
2443
+ * { test: /^node:/, sideEffects: true },
2444
+ * { test: /\.css$/, sideEffects: true },
2445
+ * { test: /some-package/, sideEffects: false, external: false },
2446
+ * ]
2447
+ * }
2448
+ *
2449
+ * // Custom function to determine side effects
2450
+ * treeshake: {
2451
+ * moduleSideEffects: (id, external) => {
2452
+ * if (external) return false; // external modules have no side effects
2453
+ * return id.includes('/side-effects/') || id.endsWith('.css');
2454
+ * }
2455
+ * }
2456
+ *
2457
+ * // Assume no external modules have side effects
2458
+ * treeshake: {
2459
+ * moduleSideEffects: 'no-external',
2460
+ * }
2461
+ * ```
2462
+ *
2463
+ * **Common Use Cases:**
2464
+ * - **CSS files**: `{ test: /\.css$/, sideEffects: true }` - preserve CSS imports
2465
+ * - **Polyfills**: Add specific polyfill modules to the array
2466
+ * - **Plugins**: Modules that register themselves globally on import
2467
+ * - **Library development**: Set to `false` for libraries where unused exports should be removed
2468
+ *
2469
+ * @default true
2470
+ */
2471
+ moduleSideEffects?: ModuleSideEffectsOption;
2472
+ /**
2473
+ * Whether to respect `/*@__PURE__*\/` annotations and other tree-shaking hints in the code.
2474
+ *
2475
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#pure-annotations) for more details.
2476
+ *
2477
+ * @default true
2478
+ */
2479
+ annotations?: boolean;
2480
+ /**
2481
+ * Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure.
2482
+ *
2483
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#define-pure-functions) for more details.
2484
+ *
2485
+ * @example
2486
+ * ```js
2487
+ * treeshake: {
2488
+ * manualPureFunctions: ['console.log', 'debug.trace']
2489
+ * }
2490
+ * ```
2491
+ * @default []
2492
+ */
2493
+ manualPureFunctions?: readonly string[];
2494
+ /**
2495
+ * Whether to assume that accessing unknown global properties might have side effects.
2496
+ *
2497
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-global-variable-access-side-effects) for more details.
2498
+ *
2499
+ * @default true
2500
+ */
2501
+ unknownGlobalSideEffects?: boolean;
2502
+ /**
2503
+ * Whether to assume that invalid import statements might have side effects.
2504
+ *
2505
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-invalid-import-statement-side-effects) for more details.
2506
+ *
2507
+ * @default false
2508
+ */
2509
+ invalidImportSideEffects?: boolean;
2510
+ /**
2511
+ * Whether to enable tree-shaking for CommonJS modules. When `true`, unused exports from CommonJS modules can be eliminated from the bundle, similar to ES modules. When disabled, CommonJS modules will always be included in their entirety.
2512
+ *
2513
+ * This option allows rolldown to analyze `exports.property` assignments in CommonJS modules and remove unused exports while preserving the module's side effects.
2514
+ *
2515
+ * @example
2516
+ * ```js
2517
+ * // source.js (CommonJS)
2518
+ * exports.used = 'This will be kept';
2519
+ * exports.unused = 'This will be tree-shaken away';
2520
+ *
2521
+ * // main.js
2522
+ * import { used } from './source.js';
2523
+ * // With commonjs: true, only the 'used' export is included in the bundle
2524
+ * // With commonjs: false, both exports are included
2525
+ * ```
2526
+ * @default true
2527
+ */
2528
+ commonjs?: boolean;
2529
+ /**
2530
+ * Controls whether reading properties from objects is considered to have side effects.
2531
+ *
2532
+ * Set to `false` for more aggressive tree-shaking behavior.
2533
+ *
2534
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-property-read-side-effects) for more details.
2535
+ *
2536
+ * @default 'always'
2537
+ */
2538
+ propertyReadSideEffects?: false | "always";
2539
+ /**
2540
+ * Controls whether writing properties to objects is considered to have side effects.
2541
+ *
2542
+ * Set to `false` for more aggressive behavior.
2543
+ *
2544
+ * @default 'always'
2545
+ */
2546
+ propertyWriteSideEffects?: false | "always";
2547
+ };
2548
+ //#endregion
2549
+ //#region src/types/output-bundle.d.ts
2550
+ /** @category Plugin APIs */
2551
+ interface OutputBundle {
2552
+ [fileName: string]: OutputAsset | OutputChunk;
2553
+ }
2554
+ //#endregion
2555
+ //#region src/types/sourcemap.d.ts
2556
+ /** @category Plugin APIs */
2557
+ interface ExistingRawSourceMap {
2558
+ file?: string | null;
2559
+ mappings: string;
2560
+ names?: string[];
2561
+ sources?: (string | null)[];
2562
+ sourcesContent?: (string | null | undefined)[];
2563
+ sourceRoot?: string;
2564
+ version?: number;
2565
+ x_google_ignoreList?: number[];
2566
+ }
2567
+ /** @inline @category Plugin APIs */
2568
+ type SourceMapInput = ExistingRawSourceMap | string | null;
2569
+ //#endregion
2570
+ //#region src/utils/error.d.ts
2571
+ /**
2572
+ * The error type that is thrown by Rolldown for the whole build.
2573
+ */
2574
+ type BundleError = Error & {
2575
+ /**
2576
+ * The individual errors that happened during the build.
2577
+ *
2578
+ * This property is a getter to avoid unnecessary expansion of error details when the error is logged.
2579
+ */
2580
+ errors?: RolldownError[];
2581
+ };
2582
+ //#endregion
2583
+ //#region src/constants/version.d.ts
2584
+ /**
2585
+ * The version of Rolldown.
2586
+ * @example `'1.0.0'`
2587
+ *
2588
+ * @category Plugin APIs
2589
+ */
2590
+ declare const VERSION: string;
2591
+ //#endregion
2592
+ //#region src/constants/index.d.ts
2593
+ /**
2594
+ * Runtime helper module ID
2595
+ */
2596
+ declare const RUNTIME_MODULE_ID = "\0rolldown/runtime.js";
2597
+ //#endregion
2598
+ //#region src/builtin-plugin/utils.d.ts
2599
+ declare class BuiltinPlugin {
2600
+ name: BindingBuiltinPluginName;
2601
+ _options?: unknown;
2602
+ /** Vite-specific option to control plugin ordering */
2603
+ enforce?: "pre" | "post";
2604
+ constructor(name: BindingBuiltinPluginName, _options?: unknown);
2605
+ }
2606
+ //#endregion
2607
+ //#region src/constants/plugin.d.ts
2608
+ declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
2609
+ declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
2610
+ declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ...typeof ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, "footer", "banner", "intro", "outro"];
2611
+ /**
2612
+ * Names of all defined hooks. It's like
2613
+ * ```ts
2614
+ * type DefinedHookNames = {
2615
+ * options: 'options',
2616
+ * buildStart: 'buildStart',
2617
+ * ...
2618
+ * }
2619
+ * ```
2620
+ */
2621
+ type DefinedHookNames = { readonly [K in (typeof ENUMERATED_PLUGIN_HOOK_NAMES)[number]]: K; };
2622
+ /**
2623
+ * Names of all defined hooks. It's like
2624
+ * ```js
2625
+ * const DEFINED_HOOK_NAMES ={
2626
+ * options: 'options',
2627
+ * buildStart: 'buildStart',
2628
+ * ...
2629
+ * }
2630
+ * ```
2631
+ */
2632
+ declare const DEFINED_HOOK_NAMES: DefinedHookNames;
2633
+ //#endregion
2634
+ //#region src/plugin/with-filter.d.ts
2635
+ type OverrideFilterObject = {
2636
+ transform?: HookFilterExtension<"transform">["filter"];
2637
+ resolveId?: HookFilterExtension<"resolveId">["filter"];
2638
+ load?: HookFilterExtension<"load">["filter"];
2639
+ pluginNamePattern?: StringOrRegExp[];
2640
+ };
2641
+ /**
2642
+ * A helper function to add plugin hook filters to a plugin or an array of plugins.
2643
+ *
2644
+ * @example
2645
+ * ```ts
2646
+ * import yaml from '@rollup/plugin-yaml';
2647
+ * import { defineConfig } from 'rolldown';
2648
+ * import { withFilter } from 'rolldown/filter';
2649
+ *
2650
+ * export default defineConfig({
2651
+ * plugins: [
2652
+ * // Run the transform hook of the `yaml` plugin
2653
+ * // only for modules which end in `.yaml`
2654
+ * withFilter(
2655
+ * yaml({}),
2656
+ * { transform: { id: /\.yaml$/ } },
2657
+ * ),
2658
+ * ],
2659
+ * });
2660
+ * ```
2661
+ *
2662
+ * @category Config
2663
+ */
2664
+ declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption: T, filterObject: OverrideFilterObject | OverrideFilterObject[]): T;
2665
+ //#endregion
2666
+ //#region src/plugin/index.d.ts
2667
+ type ModuleSideEffects = boolean | "no-treeshake" | null;
2668
+ /** @category Plugin APIs */
2669
+ type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
2670
+ /** @category Plugin APIs */
2671
+ type ImportKind = BindingHookResolveIdExtraArgs["kind"];
2672
+ /**
2673
+ * Descriptive metadata a plugin can expose about itself.
2674
+ *
2675
+ * Set it via the {@linkcode Plugin.meta | meta} property of the plugin object.
2676
+ *
2677
+ * @category Plugin APIs
2678
+ */
2679
+ interface PluginMeta {
2680
+ /**
2681
+ * The name of the npm package the plugin ships in, e.g. `@vitejs/plugin-vue`.
2682
+ */
2683
+ packageName?: string;
2684
+ /**
2685
+ * The version of the npm package the plugin ships in, e.g. `5.0.0`. The
2686
+ * `version` field of that package's `package.json`.
2687
+ */
2688
+ version?: string;
2689
+ /**
2690
+ * A short, human-readable description of what the plugin does.
2691
+ */
2692
+ description?: string;
2693
+ }
2694
+ /** @category Plugin APIs */
2695
+ interface CustomPluginOptions {
2696
+ [plugin: string]: any;
2697
+ }
2698
+ /** @category Plugin APIs */
2699
+ interface ModuleOptions {
2700
+ moduleSideEffects: ModuleSideEffects;
2701
+ /** See [Custom module meta-data section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-module-meta-data) for more details. */
2702
+ meta: CustomPluginOptions;
2703
+ /**
2704
+ * A short, human-readable description of the module.
2705
+ *
2706
+ * This is useful for virtual modules, whose ids (e.g.
2707
+ * `\0vite/modulepreload-polyfill.js`) do not convey their purpose on their own.
2708
+ *
2709
+ * @example
2710
+ * ```js
2711
+ * function polyfillPlugin() {
2712
+ * return {
2713
+ * name: 'vite:modulepreload-polyfill',
2714
+ * load: {
2715
+ * filter: { id: /^\0vite\/modulepreload-polyfill\.js$/ },
2716
+ * handler(id) {
2717
+ * return {
2718
+ * code: '',
2719
+ * description: 'A polyfill for `link` tag with `rel="modulepreload"`',
2720
+ * };
2721
+ * }
2722
+ * },
2723
+ * };
2724
+ * }
2725
+ * ```
2726
+ */
2727
+ description?: string;
2728
+ invalidate?: boolean;
2729
+ packageJsonPath?: string;
2730
+ }
2731
+ /** @category Plugin APIs */
2732
+ interface ResolvedId extends ModuleOptions {
2733
+ external: boolean | "absolute";
2734
+ id: string;
2735
+ }
2736
+ interface SpecifiedModuleOptions {
2737
+ /**
2738
+ * Indicates whether the module has side effects to Rolldown.
2739
+ *
2740
+ * - If `false` is set and no other module imports anything from this module, then this module will not be included in the bundle even if the module would have side effects.
2741
+ * - If `true` is set, Rolldown will use its default algorithm to include all statements in the module that has side effects.
2742
+ * - If `"no-treeshake"` is set, treeshaking will be disabled for this module, and this module will be included in one of the chunks even if it is empty.
2743
+ *
2744
+ * The precedence of this option is as follows (highest to lowest):
2745
+ * 1. {@linkcode Plugin.transform | transform} hook's returned `moduleSideEffects` option
2746
+ * 2. {@linkcode Plugin.load | load} hook's returned `moduleSideEffects` option
2747
+ * 3. {@linkcode Plugin.resolveId | resolveId} hook's returned `moduleSideEffects` option
2748
+ * 4. {@linkcode TreeshakingOptions.moduleSideEffects | treeshake.moduleSideEffects} option
2749
+ * 5. `sideEffects` field in the `package.json` file
2750
+ * 6. `true` (default)
2751
+ */
2752
+ moduleSideEffects?: ModuleSideEffects | null;
2753
+ }
2754
+ /** @category Plugin APIs */
2755
+ interface PartialResolvedId extends SpecifiedModuleOptions, Partial<PartialNull<ModuleOptions>> {
2756
+ /**
2757
+ * Whether this id should be treated as external.
2758
+ *
2759
+ * Relative external ids, i.e. ids starting with `./` or `../`, will not be internally
2760
+ * converted to an absolute id and converted back to a relative id in the output,
2761
+ * but are instead included in the output unchanged.
2762
+ * If you want relative ids to be re-normalized and deduplicated instead, return
2763
+ * an absolute file system location as id and choose `external: "relative"`.
2764
+ *
2765
+ * - If `true`, absolute ids will be converted to relative ids based on the user's choice for the {@linkcode InputOptions.makeAbsoluteExternalsRelative | makeAbsoluteExternalsRelative} option.
2766
+ * - If `'relative'`, absolute ids will always be converted to relative ids.
2767
+ * - If `'absolute'`, absolute ids will always be kept as absolute ids.
2768
+ */
2769
+ external?: boolean | "absolute" | "relative";
2770
+ id: string;
2771
+ }
2772
+ /** @category Plugin APIs */
2773
+ interface SourceDescription extends SpecifiedModuleOptions, Partial<PartialNull<ModuleOptions>> {
2774
+ code: string;
2775
+ /**
2776
+ * The source map for the transformation.
2777
+ *
2778
+ * If the transformation does not move code, you can preserve existing sourcemaps by setting this to `null`.
2779
+ *
2780
+ * See [Source Code Transformations section](https://rolldown.rs/apis/plugin-api/transformations#source-code-transformations) for more details.
2781
+ */
2782
+ map?: SourceMapInput;
2783
+ moduleType?: ModuleType;
2784
+ }
2785
+ /** @inline */
2786
+ interface ResolveIdExtraOptions {
2787
+ /**
2788
+ * Plugin-specific options.
2789
+ *
2790
+ * See [Custom resolver options section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-resolver-options) for more details.
2791
+ */
2792
+ custom?: CustomPluginOptions;
2793
+ /**
2794
+ * Whether this is resolution for an entry point.
2795
+ *
2796
+ *
2797
+ */
2798
+ isEntry: boolean;
2799
+ /**
2800
+ * The kind of import being resolved.
2801
+ *
2802
+ * - `import-statement`: `import { foo } from './lib.js';`
2803
+ * - `dynamic-import`: `import('./lib.js')`
2804
+ * - `require-call`: `require('./lib.js')`
2805
+ * - `import-rule`: `@import 'bg-color.css'` (experimental)
2806
+ * - `url-token`: `url('./icon.png')` (experimental)
2807
+ * - `new-url`: `new URL('./worker.js', import.meta.url)` (experimental)
2808
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})` (experimental)
2809
+ */
2810
+ kind: BindingHookResolveIdExtraArgs["kind"];
2811
+ }
2812
+ /** @inline @category Plugin APIs */
2813
+ type ResolveIdResult = string | NullValue | false | PartialResolvedId;
2814
+ /** @inline @category Plugin APIs */
2815
+ type LoadResult = NullValue | string | SourceDescription;
2816
+ /** @inline @category Plugin APIs */
2817
+ type TransformResult = NullValue | string | (Omit<SourceDescription, "code"> & {
2818
+ code?: string | RolldownMagicString;
2819
+ });
2820
+ type RenderedChunkMeta = {
2821
+ /**
2822
+ * Contains information about all chunks that are being rendered.
2823
+ * This is useful to explore the entire chunk graph.
2824
+ */
2825
+ chunks: Record<string, RenderedChunk>;
2826
+ /**
2827
+ * A lazily-created MagicString instance for the chunk's code.
2828
+ * Use this to perform string transformations with automatic source map support.
2829
+ * This is only available when `experimental.nativeMagicString` is enabled.
2830
+ */
2831
+ magicString?: RolldownMagicString;
2832
+ };
2833
+ /** @category Plugin APIs */
2834
+ interface FunctionPluginHooks {
2835
+ /**
2836
+ * A function that receives and filters logs and warnings generated by Rolldown and
2837
+ * plugins before they are passed to the {@linkcode InputOptions.onLog | onLog} option
2838
+ * or printed to the console.
2839
+ *
2840
+ * If `false` is returned, the log will be filtered out.
2841
+ * Otherwise, the log will be handed to the `onLog` hook of the next plugin,
2842
+ * the {@linkcode InputOptions.onLog | onLog} option, or printed to the console.
2843
+ * Plugins can also change the log level of a log or turn a log into an error by passing
2844
+ * the `log` object to {@linkcode MinimalPluginContext.error | this.error},
2845
+ * {@linkcode MinimalPluginContext.warn | this.warn},
2846
+ * {@linkcode MinimalPluginContext.info | this.info} or
2847
+ * {@linkcode MinimalPluginContext.debug | this.debug} and returning `false`.
2848
+ *
2849
+ *
2850
+ *
2851
+ * @kind sync sequential
2852
+ * @group Build Hooks
2853
+ */
2854
+ [DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RolldownLog) => NullValue | boolean;
2855
+ /**
2856
+ * Replaces or manipulates the options object passed to {@linkcode rolldown | rolldown()}.
2857
+ *
2858
+ * Returning `null` does not replace anything.
2859
+ *
2860
+ * If you just need to read the options, it is recommended to use
2861
+ * the {@linkcode buildStart} hook as that hook has access to the options
2862
+ * after the transformations from all `options` hooks have been taken into account.
2863
+ *
2864
+ * @kind async sequential
2865
+ * @group Build Hooks
2866
+ */
2867
+ [DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
2868
+ /**
2869
+ * Replaces or manipulates the output options object passed to
2870
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
2871
+ * {@linkcode RolldownBuild.write | bundle.write()}.
2872
+ *
2873
+ * Returning null does not replace anything.
2874
+ *
2875
+ * If you just need to read the output options, it is recommended to use
2876
+ * the {@linkcode renderStart} hook as this hook has access to the output options
2877
+ * after the transformations from all `outputOptions` hooks have been taken into account.
2878
+ *
2879
+ * @kind sync sequential
2880
+ * @group Build Hooks
2881
+ */
2882
+ [DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
2883
+ /**
2884
+ * Called on each {@linkcode rolldown | rolldown()} build.
2885
+ *
2886
+ * This is the recommended hook to use when you need access to the options passed to {@linkcode rolldown | rolldown()} as it takes the transformations by all options hooks into account and also contains the right default values for unset options.
2887
+ *
2888
+ * @kind async parallel
2889
+ * @group Build Hooks
2890
+ */
2891
+ [DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
2892
+ /**
2893
+ * Defines a custom resolver.
2894
+ *
2895
+ * A resolver can be useful for e.g. locating third-party dependencies.
2896
+ *
2897
+ * Returning `null` defers to other `resolveId` hooks and eventually the default resolution behavior.
2898
+ * Returning `false` signals that `source` should be treated as an external module and not included in the bundle. If this happens for a relative import, the id will be renormalized the same way as when the {@linkcode InputOptions.external} option is used.
2899
+ * If you return an object, then it is possible to resolve an import to a different id while excluding it from the bundle at the same time.
2900
+ *
2901
+ * Note that while `resolveId` will be called for each import of a module and can therefore
2902
+ * resolve to the same `id` many times, values for `external`, `meta` or `moduleSideEffects`
2903
+ * can only be set once before the module is loaded. The reason is that after this call,
2904
+ * Rolldown will continue with the {@linkcode load} and {@linkcode transform} hooks for that
2905
+ * module that may override these values and should take precedence if they do so.
2906
+ *
2907
+ * @kind async first
2908
+ * @group Build Hooks
2909
+ */
2910
+ [DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
2911
+ /**
2912
+ * Defines a custom resolver for dynamic imports.
2913
+ *
2914
+ * @deprecated
2915
+ * This hook exists only for Rollup compatibility. Please use {@linkcode resolveId} instead.
2916
+ *
2917
+ * @kind async first
2918
+ * @group Build Hooks
2919
+ */
2920
+ [DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
2921
+ /**
2922
+ * Defines a custom loader.
2923
+ *
2924
+ * Returning `null` defers to other `load` hooks or the built-in loading mechanism.
2925
+ *
2926
+ * You can use {@linkcode PluginContext.getModuleInfo | this.getModuleInfo()} to find out the previous values of `meta`, `moduleSideEffects` inside this hook.
2927
+ *
2928
+ * @kind async first
2929
+ * @group Build Hooks
2930
+ */
2931
+ [DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
2932
+ /**
2933
+ * Can be used to transform individual modules.
2934
+ *
2935
+ * Note that it's possible to return only properties and no code transformations.
2936
+ *
2937
+ * You can use {@linkcode PluginContext.getModuleInfo | this.getModuleInfo()} to find out the previous values of `meta`, `moduleSideEffects` inside this hook.
2938
+ *
2939
+ *
2940
+ *
2941
+ * @kind async sequential
2942
+ * @group Build Hooks
2943
+ */
2944
+ [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
2945
+ moduleType: ModuleType;
2946
+ magicString?: RolldownMagicString;
2947
+ ast?: Program;
2948
+ }) => TransformResult;
2949
+ /**
2950
+ * This hook is called each time a module has been fully parsed by Rolldown.
2951
+ *
2952
+ * This hook will wait until all imports are resolved so that the information in
2953
+ * {@linkcode ModuleInfo.importedIds | moduleInfo.importedIds},
2954
+ * {@linkcode ModuleInfo.dynamicallyImportedIds | moduleInfo.dynamicallyImportedIds}
2955
+ * are complete and accurate. Note however that information about importing modules
2956
+ * may be incomplete as additional importers could be discovered later.
2957
+ * If you need this information, use the {@linkcode buildEnd} hook.
2958
+ *
2959
+ * @kind async parallel
2960
+ * @group Build Hooks
2961
+ */
2962
+ [DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
2963
+ /**
2964
+ * Called when Rolldown has finished bundling, but before Output Generation Hooks.
2965
+ * If an error occurred during the build, it is passed on to this hook.
2966
+ *
2967
+ * @kind async parallel
2968
+ * @group Build Hooks
2969
+ */
2970
+ [DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
2971
+ /**
2972
+ * Called initially each time {@linkcode RolldownBuild.generate | bundle.generate()} or
2973
+ * {@linkcode RolldownBuild.write | bundle.write()} is called.
2974
+ *
2975
+ * To get notified when generation has completed, use the {@linkcode generateBundle} and
2976
+ * {@linkcode renderError} hooks.
2977
+ *
2978
+ * This is the recommended hook to use when you need access to the output options passed to
2979
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
2980
+ * {@linkcode RolldownBuild.write | bundle.write()} as it takes the transformations by all outputOptions hooks into account and also contains the right default values for unset options.
2981
+ *
2982
+ * It also receives the input options passed to {@linkcode rolldown | rolldown()} so that
2983
+ * plugins that can be used as output plugins, i.e. plugins that only use generate phase hooks,
2984
+ * can get access to them.
2985
+ *
2986
+ * @kind async parallel
2987
+ * @group Output Generation Hooks
2988
+ */
2989
+ [DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
2990
+ /**
2991
+ * Can be used to transform individual chunks. Called for each Rolldown output chunk file.
2992
+ *
2993
+ * Returning null will apply no transformations. If you change code in this hook and want to support source maps, you need to return a map describing your changes, see [Source Code Transformations section](https://rolldown.rs/apis/plugin-api/transformations#source-code-transformations).
2994
+ *
2995
+ * `chunk` is mutable and changes applied in this hook will propagate to other plugins and
2996
+ * to the generated bundle.
2997
+ * That means if you add or remove imports or exports in this hook, you should update
2998
+ * {@linkcode RenderedChunk.imports | imports}, {@linkcode RenderedChunk.importedBindings | importedBindings} and/or {@linkcode RenderedChunk.exports | exports} accordingly.
2999
+ *
3000
+ * @kind async sequential
3001
+ * @group Output Generation Hooks
3002
+ */
3003
+ [DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | RolldownMagicString | {
3004
+ code: string | RolldownMagicString;
3005
+ map?: SourceMapInput;
3006
+ };
3007
+ /**
3008
+ * Can be used to augment the hash of individual chunks. Called for each Rolldown output chunk.
3009
+ *
3010
+ * Returning a falsy value will not modify the hash.
3011
+ * Truthy values will be used as an additional source for hash calculation.
3012
+ *
3013
+ *
3014
+ *
3015
+ * @kind sync sequential
3016
+ * @group Output Generation Hooks
3017
+ */
3018
+ [DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
3019
+ /**
3020
+ * Called when Rolldown encounters an error during
3021
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
3022
+ * {@linkcode RolldownBuild.write | bundle.write()}.
3023
+ *
3024
+ * To get notified when generation completes successfully, use the
3025
+ * {@linkcode generateBundle} hook.
3026
+ *
3027
+ * @kind async parallel
3028
+ * @group Output Generation Hooks
3029
+ */
3030
+ [DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
3031
+ /**
3032
+ * Called at the end of {@linkcode RolldownBuild.generate | bundle.generate()} or
3033
+ * immediately before the files are written in
3034
+ * {@linkcode RolldownBuild.write | bundle.write()}.
3035
+ *
3036
+ * To modify the files after they have been written, use the {@linkcode writeBundle} hook.
3037
+ *
3038
+ *
3039
+ *
3040
+ * @kind async sequential
3041
+ * @group Output Generation Hooks
3042
+ */
3043
+ [DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
3044
+ /**
3045
+ * Called only at the end of {@linkcode RolldownBuild.write | bundle.write()} once
3046
+ * all files have been written.
3047
+ *
3048
+ * @kind async parallel
3049
+ * @group Output Generation Hooks
3050
+ */
3051
+ [DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
3052
+ /**
3053
+ * Can be used to clean up any external service that may be running.
3054
+ *
3055
+ * Rolldown's CLI will make sure this hook is called after each run, but it is the responsibility
3056
+ * of users of the JavaScript API to manually call
3057
+ * {@linkcode RolldownBuild.close | bundle.close()} once they are done generating bundles.
3058
+ * For that reason, any plugin relying on this feature should carefully mention this in
3059
+ * its documentation.
3060
+ *
3061
+ * If a plugin wants to retain resources across builds in watch mode, they can check for
3062
+ * {@linkcode PluginContextMeta.watchMode | this.meta.watchMode} in this hook and perform
3063
+ * the necessary cleanup for watch mode in closeWatcher.
3064
+ *
3065
+ * @kind async parallel
3066
+ * @group Output Generation Hooks
3067
+ */
3068
+ [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext, error?: Error) => void;
3069
+ /**
3070
+ * Notifies a plugin whenever Rolldown has detected a change to a monitored file in watch mode.
3071
+ *
3072
+ * If a build is currently running, this hook is called once the build finished.
3073
+ * It will be called once for every file that changed.
3074
+ *
3075
+ * This hook cannot be used by output plugins.
3076
+ *
3077
+ * If you need to be notified immediately when a file changed, you can use the {@linkcode WatcherOptions.onInvalidate | watch.onInvalidate} option.
3078
+ *
3079
+ * @kind async parallel
3080
+ * @group Build Hooks
3081
+ */
3082
+ [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
3083
+ event: ChangeEvent;
3084
+ }) => void;
3085
+ /**
3086
+ * Notifies a plugin when the watcher process will close so that all open resources can be closed too.
3087
+ *
3088
+ * This hook cannot be used by output plugins.
3089
+ *
3090
+ * @kind async parallel
3091
+ * @group Build Hooks
3092
+ */
3093
+ [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
3094
+ }
3095
+ type ChangeEvent = "create" | "update" | "delete";
3096
+ type PluginOrder = "pre" | "post" | null;
3097
+ /** @inline */
3098
+ type ObjectHookMeta = {
3099
+ order?: PluginOrder;
3100
+ };
3101
+ /**
3102
+ * A hook in a function or an object form with additional properties.
3103
+ *
3104
+ * @typeParam T - The type of the hook function.
3105
+ * @typeParam O - Additional properties that are specific to some hooks.
3106
+ *
3107
+ *
3108
+ *
3109
+ * @category Plugin APIs
3110
+ */
3111
+ type ObjectHook<T, O = {}> = T | ({
3112
+ handler: T;
3113
+ } & ObjectHookMeta & O);
3114
+ type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
3115
+ /** @category Plugin APIs */
3116
+ type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
3117
+ type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
3118
+ type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
3119
+ interface AddonHooks {
3120
+ /**
3121
+ * A hook equivalent to {@linkcode OutputOptions.banner | output.banner} option.
3122
+ *
3123
+ * @kind async sequential
3124
+ * @group Output Generation Hooks
3125
+ */
3126
+ [DEFINED_HOOK_NAMES.banner]: AddonHook;
3127
+ /**
3128
+ * A hook equivalent to {@linkcode OutputOptions.footer | output.footer} option.
3129
+ *
3130
+ * @kind async sequential
3131
+ * @group Output Generation Hooks
3132
+ */
3133
+ [DEFINED_HOOK_NAMES.footer]: AddonHook;
3134
+ /**
3135
+ * A hook equivalent to {@linkcode OutputOptions.intro | output.intro} option.
3136
+ *
3137
+ * @kind async sequential
3138
+ * @group Output Generation Hooks
3139
+ */
3140
+ [DEFINED_HOOK_NAMES.intro]: AddonHook;
3141
+ /**
3142
+ * A hook equivalent to {@linkcode OutputOptions.outro | output.outro} option.
3143
+ *
3144
+ * @kind async sequential
3145
+ * @group Output Generation Hooks
3146
+ */
3147
+ [DEFINED_HOOK_NAMES.outro]: AddonHook;
3148
+ }
3149
+ type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
3150
+ /** @internal */
3151
+ type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | keyof AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
3152
+ /** @category Plugin APIs */
3153
+ type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
3154
+ filter?: HookFilter | TopLevelFilterExpression[];
3155
+ } : K extends "load" ? {
3156
+ filter?: Pick<HookFilter, "id"> | TopLevelFilterExpression[];
3157
+ } : K extends "resolveId" ? {
3158
+ filter?: {
3159
+ id?: GeneralHookFilter<RegExp>;
3160
+ } | TopLevelFilterExpression[];
3161
+ } : K extends "renderChunk" ? {
3162
+ filter?: Pick<HookFilter, "code"> | TopLevelFilterExpression[];
3163
+ } : {};
3164
+ type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
3165
+ /**
3166
+ * @deprecated
3167
+ * this is only for rollup Plugin type compatibility.
3168
+ * hooks always work as `sequential: true`.
3169
+ */
3170
+ sequential?: boolean;
3171
+ } : {})>; };
3172
+ type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
3173
+ type AddonHook = string | AddonHookFunction;
3174
+ interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPluginHooks]: PluginHooks[K]; }>, Partial<{ [K in keyof AddonHooks]: ObjectHook<AddonHook>; }> {
3175
+ /** The name of the plugin, for use in error messages and logs. */
3176
+ name: string;
3177
+ /** The version of the plugin, for use in inter-plugin communication scenarios. */
3178
+ version?: string;
3179
+ /**
3180
+ * Descriptive metadata about the plugin, such as the npm package it ships in.
3181
+ *
3182
+ * This does not affect bundling; it is informational and intended to be
3183
+ * surfaced by tooling that inspects a build. See {@linkcode PluginMeta}.
3184
+ *
3185
+ * @experimental
3186
+ */
3187
+ meta?: PluginMeta;
3188
+ }
3189
+ /**
3190
+ * The Plugin interface.
3191
+ *
3192
+ * See [Plugin API document](https://rolldown.rs/apis/plugin-api) for details.
3193
+ *
3194
+ * @typeParam A - The type of the {@link Plugin.api | api} property.
3195
+ *
3196
+ * @category Plugin APIs
3197
+ */
3198
+ interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
3199
+ /**
3200
+ * Used for inter-plugin communication.
3201
+ */
3202
+ api?: A;
3203
+ }
3204
+ type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
3205
+ type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | {
3206
+ name: string;
3207
+ } | false | RolldownPluginOption[]>;
3208
+ type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
3209
+ type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | {
3210
+ name: string;
3211
+ } | false | RolldownOutputPluginOption[]>;
3212
+ //#endregion
3213
+ //#region src/options/input-options.d.ts
3214
+ /**
3215
+ * @inline
3216
+ */
3217
+ type InputOption = string | string[] | Record<string, string>;
3218
+ /**
3219
+ * @param id The id of the module being checked.
3220
+ * @param parentId The id of the module importing the id being checked.
3221
+ * @param isResolved Whether the id has been resolved.
3222
+ * @returns Whether the module should be treated as external.
3223
+ */
3224
+ type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
3225
+ /** @inline */
3226
+ type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
3227
+ interface ChunkOptimizationOptions {
3228
+ /**
3229
+ * Merge common chunks into existing entry chunks when it is safe.
3230
+ *
3231
+ * This can reduce the number of emitted chunks by moving shared/common modules
3232
+ * into an entry chunk that already depends on them. Rolldown only applies the
3233
+ * merge when it does not create a circular chunk dependency or change strict
3234
+ * entry export signatures. This pass also covers safe empty-facade cleanup.
3235
+ *
3236
+ * @default true
3237
+ */
3238
+ mergeCommonChunks?: boolean;
3239
+ /**
3240
+ * Avoid emitting redundant chunk loads for dynamic entries.
3241
+ *
3242
+ * This pass can reduce dynamic-entry dependent chunks when the shared modules
3243
+ * are guaranteed to be loaded by every importer of that dynamic entry.
3244
+ *
3245
+ * @default true
3246
+ */
3247
+ avoidRedundantChunkLoads?: boolean;
3248
+ }
3249
+ type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset" | "copy">;
3250
+ interface WatcherFileWatcherOptions {
3251
+ /**
3252
+ * Whether to use polling-based file watching instead of native OS events.
3253
+ *
3254
+ * Polling is useful for environments where native FS events are unreliable,
3255
+ * such as network mounts, Docker volumes, or WSL2.
3256
+ *
3257
+ * @default false
3258
+ */
3259
+ usePolling?: boolean;
3260
+ /**
3261
+ * Interval between each poll in milliseconds.
3262
+ *
3263
+ * This option is only used when {@linkcode usePolling} is `true`.
3264
+ *
3265
+ * @default 100
3266
+ */
3267
+ pollInterval?: number;
3268
+ /**
3269
+ * Whether to compare file contents for poll-based watchers.
3270
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
3271
+ *
3272
+ * This option is only used when {@linkcode usePolling} is `true`.
3273
+ *
3274
+ * @default false
3275
+ */
3276
+ compareContentsForPolling?: boolean;
3277
+ /**
3278
+ * Whether to use debounced event delivery at the filesystem level.
3279
+ * This coalesces rapid filesystem events before they reach the build coordinator.
3280
+ * @default false
3281
+ */
3282
+ useDebounce?: boolean;
3283
+ /**
3284
+ * Debounce delay in milliseconds for fs-level debounced watchers.
3285
+ * Only used when {@linkcode useDebounce} is `true`.
3286
+ * @default 10
3287
+ */
3288
+ debounceDelay?: number;
3289
+ /**
3290
+ * Tick rate in milliseconds for the debouncer's internal polling.
3291
+ * Only used when {@linkcode useDebounce} is `true`.
3292
+ * When undefined, auto-selects 1/4 of debounceDelay.
3293
+ */
3294
+ debounceTickRate?: number;
3295
+ }
3296
+ interface WatcherOptions {
3297
+ /**
3298
+ * Whether to skip the {@linkcode RolldownBuild.write | bundle.write()} step when a rebuild is triggered.
3299
+ * @default false
3300
+ */
3301
+ skipWrite?: boolean;
3302
+ /**
3303
+ * Configures how long Rolldown will wait for further changes until it triggers
3304
+ * a rebuild in milliseconds.
3305
+ *
3306
+ * Even if this value is set to 0, there's a small debounce timeout configured
3307
+ * in the file system watcher. Setting this to a value greater than 0 will mean
3308
+ * that Rolldown will only trigger a rebuild if there was no change for the
3309
+ * configured number of milliseconds. If several configurations are watched,
3310
+ * Rolldown will use the largest configured build delay.
3311
+ *
3312
+ * This option is useful if you use a tool that regenerates multiple source files
3313
+ * very slowly. Rebuilding immediately after the first change could cause Rolldown
3314
+ * to generate a broken intermediate build before generating a successful final
3315
+ * build, which can be confusing and distracting.
3316
+ *
3317
+ * @default 0
3318
+ */
3319
+ buildDelay?: number;
3320
+ /**
3321
+ * File watcher options for configuring how file changes are detected.
3322
+ */
3323
+ watcher?: WatcherFileWatcherOptions;
3324
+ /**
3325
+ * @deprecated Use {@linkcode watcher} instead.
3326
+ */
3327
+ notify?: WatcherFileWatcherOptions;
3328
+ /**
3329
+ * Filter to limit the file-watching to certain files.
3330
+ *
3331
+ * Strings are treated as glob patterns.
3332
+ * Note that this only filters the module graph but does not allow adding
3333
+ * additional watch files.
3334
+ *
3335
+ * @example
3336
+ * ```js
3337
+ * export default defineConfig({
3338
+ * watch: {
3339
+ * include: 'src/**',
3340
+ * },
3341
+ * })
3342
+ * ```
3343
+ * @default []
3344
+ */
3345
+ include?: StringOrRegExp | StringOrRegExp[];
3346
+ /**
3347
+ * Filter to prevent files from being watched.
3348
+ *
3349
+ * Strings are treated as glob patterns.
3350
+ *
3351
+ * @example
3352
+ * ```js
3353
+ * export default defineConfig({
3354
+ * watch: {
3355
+ * exclude: 'node_modules/**',
3356
+ * },
3357
+ * })
3358
+ * ```
3359
+ * @default []
3360
+ */
3361
+ exclude?: StringOrRegExp | StringOrRegExp[];
3362
+ /**
3363
+ * An optional function that will be called immediately every time
3364
+ * a module changes that is part of the build.
3365
+ *
3366
+ * This is different from the {@linkcode Plugin.watchChange | watchChange} plugin hook, which is
3367
+ * only called once the running build has finished. This may for
3368
+ * instance be used to prevent additional steps from being performed
3369
+ * if we know another build will be started anyway once the current
3370
+ * build finished. This callback may be called multiple times per
3371
+ * build as it tracks every change.
3372
+ *
3373
+ * @param id The id of the changed module.
3374
+ */
3375
+ onInvalidate?: (id: string) => void;
3376
+ /**
3377
+ * Whether to clear the screen when a rebuild is triggered.
3378
+ * @default true
3379
+ */
3380
+ clearScreen?: boolean;
3381
+ }
3382
+ /** @inline */
3383
+ type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
3384
+ type DevModeOptions = boolean | {
3385
+ host?: string;
3386
+ port?: number;
3387
+ implement?: string;
3388
+ lazy?: boolean;
3389
+ };
3390
+ type OptimizationOptions = {
3391
+ /**
3392
+ * Inline imported constant values during bundling instead of preserving variable references.
3393
+ *
3394
+ * When enabled, constant values from imported modules will be inlined at their usage sites,
3395
+ * potentially reducing bundle size and improving runtime performance by eliminating variable lookups.
3396
+ *
3397
+ * **Options:**
3398
+ * - `true`: equivalent to `{ mode: 'all', pass: 1 }`, enabling constant inlining for all eligible constants with a single pass.
3399
+ * - `false`: Disable constant inlining
3400
+ * - `{ mode: 'smart' | 'all', pass?: number }`:
3401
+ * - `mode: 'smart'`: Only inline constants in specific scenarios where it is likely to reduce bundle size and improve performance.
3402
+ * Smart mode inlines constants in these specific scenarios:
3403
+ * 1. `if (test) {} else {}` - condition expressions in if statements
3404
+ * 2. `test ? a : b` - condition expressions in ternary operators
3405
+ * 3. `test1 || test2` - logical OR expressions
3406
+ * 4. `test1 && test2` - logical AND expressions
3407
+ * 5. `test1 ?? test2` - nullish coalescing expressions
3408
+ * - `mode: 'all'`: Inline all imported constants wherever they are used.
3409
+ * - `pass`: Number of passes to perform for inlining constants.
3410
+ *
3411
+ * @example
3412
+ * ```js
3413
+ * // Input files:
3414
+ * // constants.js
3415
+ * export const API_URL = 'https://api.example.com';
3416
+ *
3417
+ * // main.js
3418
+ * import { API_URL } from './constants.js';
3419
+ * console.log(API_URL);
3420
+ *
3421
+ * // With inlineConst: true, the bundled output becomes:
3422
+ * console.log('https://api.example.com');
3423
+ *
3424
+ * // Instead of:
3425
+ * const API_URL = 'https://api.example.com';
3426
+ * console.log(API_URL);
3427
+ * ```
3428
+ *
3429
+ * @default { mode: 'smart', pass: 1 }
3430
+ */
3431
+ inlineConst?: boolean | {
3432
+ mode?: "all" | "smart";
3433
+ pass?: number;
3434
+ };
3435
+ /**
3436
+ * Use PIFE pattern for module wrappers.
3437
+ *
3438
+ * Enabling this option improves the start up performance of the generated bundle with the cost of a slight increase in bundle size.
3439
+ *
3440
+ *
3441
+ *
3442
+ * @default true
3443
+ */
3444
+ pifeForModuleWrappers?: boolean;
3445
+ };
3446
+ /** @inline */
3447
+ type AttachDebugOptions = "none" | "simple" | "full";
3448
+ /** @inline */
3449
+ type ChunkModulesOrder = "exec-order" | "module-id";
3450
+ /** @inline */
3451
+ type OnLogFunction = (level: LogLevel, log: RolldownLog, defaultHandler: LogOrStringHandler) => void;
3452
+ /** @inline */
3453
+ type OnwarnFunction = (warning: RolldownLog, defaultHandler: (warning: RolldownLogWithString | (() => RolldownLogWithString)) => void) => void;
3454
+ interface InputOptions {
3455
+ /**
3456
+ * Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the {@linkcode cwd} option.
3457
+ *
3458
+ */
3459
+ input?: InputOption;
3460
+ /**
3461
+ * The list of plugins to use.
3462
+ *
3463
+ * Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins. Nested plugins will be flattened. Async plugins will be awaited and resolved.
3464
+ *
3465
+ * See [Plugin API document](https://rolldown.rs/apis/plugin-api) for more details about creating plugins.
3466
+ *
3467
+ * @example
3468
+ * ```js
3469
+ * import { defineConfig } from 'rolldown'
3470
+ *
3471
+ * export default defineConfig({
3472
+ * plugins: [
3473
+ * examplePlugin1(),
3474
+ * // Conditional plugins
3475
+ * process.env.ENV1 && examplePlugin2(),
3476
+ * // Nested plugins arrays are flattened
3477
+ * [examplePlugin3(), examplePlugin4()],
3478
+ * ]
3479
+ * })
3480
+ * ```
3481
+ */
3482
+ plugins?: RolldownPluginOption;
3483
+ /**
3484
+ * Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output.
3485
+ *
3486
+ */
3487
+ external?: ExternalOption;
3488
+ /**
3489
+ * Options for built-in module resolution feature.
3490
+ */
3491
+ resolve?: {
3492
+ /**
3493
+ * Substitute one package for another.
3494
+ *
3495
+ * One use case for this feature is replacing a node-only package with a browser-friendly package in third-party code that you don't control.
3496
+ *
3497
+ * @example
3498
+ * ```js
3499
+ * resolve: {
3500
+ * alias: {
3501
+ * '@': '/src',
3502
+ * 'utils': './src/utils',
3503
+ * }
3504
+ * }
3505
+ * ```
3506
+ * > [!WARNING]
3507
+ * > `resolve.alias` will not call [`resolveId`](/reference/Interface.Plugin#resolveid) hooks of other plugin.
3508
+ * > If you want to call `resolveId` hooks of other plugin, use `viteAliasPlugin` from `rolldown/experimental` instead.
3509
+ * > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
3510
+ */
3511
+ alias?: Record<string, string[] | string | false>;
3512
+ /**
3513
+ * Fields in package.json to check for aliased paths.
3514
+ *
3515
+ * This option is expected to be used for `browser` field support.
3516
+ *
3517
+ * @default
3518
+ * - `[['browser']]` for `browser` platform
3519
+ * - `[]` for other platforms
3520
+ */
3521
+ aliasFields?: string[][];
3522
+ /**
3523
+ * Condition names to use when resolving exports in package.json.
3524
+ *
3525
+ * @default
3526
+ * Defaults based on platform and import kind:
3527
+ * - `browser` platform
3528
+ * - `["import", "browser", "default"]` for import statements
3529
+ * - `["require", "browser", "default"]` for require() calls
3530
+ * - `node` platform
3531
+ * - `["import", "node", "default"]` for import statements
3532
+ * - `["require", "node", "default"]` for require() calls
3533
+ * - `neutral` platform
3534
+ * - `["import", "default"]` for import statements
3535
+ * - `["require", "default"]` for require() calls
3536
+ */
3537
+ conditionNames?: string[];
3538
+ /**
3539
+ * Map of extensions to alternative extensions.
3540
+ *
3541
+ * With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
3542
+ * You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
3543
+ */
3544
+ extensionAlias?: Record<string, string[]>;
3545
+ /**
3546
+ * Fields in package.json to check for exports.
3547
+ *
3548
+ * @default `[['exports']]`
3549
+ */
3550
+ exportsFields?: string[][];
3551
+ /**
3552
+ * Extensions to try when resolving files. These are tried in order from first to last.
3553
+ *
3554
+ * @default `['.tsx', '.ts', '.jsx', '.js', '.json']`
3555
+ */
3556
+ extensions?: string[];
3557
+ /**
3558
+ * Fields in package.json to check for entry points.
3559
+ *
3560
+ * @default
3561
+ * Defaults based on platform:
3562
+ * - `node` platform: `['main', 'module']`
3563
+ * - `browser` platform: `['browser', 'module', 'main']`
3564
+ * - `neutral` platform: `[]`
3565
+ */
3566
+ mainFields?: string[];
3567
+ /**
3568
+ * Filenames to try when resolving directories.
3569
+ * @default ['index']
3570
+ */
3571
+ mainFiles?: string[];
3572
+ /**
3573
+ * Directories to search for modules.
3574
+ * @default ['node_modules']
3575
+ */
3576
+ modules?: string[];
3577
+ /**
3578
+ * Whether to follow symlinks when resolving modules.
3579
+ * @default true
3580
+ */
3581
+ symlinks?: boolean;
3582
+ /**
3583
+ * @deprecated Use the top-level {@linkcode tsconfig} option instead.
3584
+ */
3585
+ tsconfigFilename?: string;
3586
+ };
3587
+ /**
3588
+ * The working directory to use when resolving relative paths in the configuration.
3589
+ * @default process.cwd()
3590
+ */
3591
+ cwd?: string;
3592
+ /**
3593
+ * Expected platform where the code run.
3594
+ *
3595
+ * When the platform is set to neutral:
3596
+ * - When bundling is enabled the default output format is set to esm, which uses the export syntax introduced with ECMAScript 2015 (i.e. ES6). You can change the output format if this default is not appropriate.
3597
+ * - The main fields setting is empty by default. If you want to use npm-style packages, you will likely have to configure this to be something else such as main for the standard main field used by node.
3598
+ * - The conditions setting does not automatically include any platform-specific values.
3599
+ *
3600
+ * @default
3601
+ * - `'node'` if the format is `'cjs'`
3602
+ * - `'browser'` for other formats
3603
+ *
3604
+ */
3605
+ platform?: "node" | "browser" | "neutral";
3606
+ /**
3607
+ * When `true`, creates shim variables for missing exports instead of throwing an error.
3608
+ * @default false
3609
+ *
3610
+ */
3611
+ shimMissingExports?: boolean;
3612
+ /**
3613
+ * Controls tree-shaking (dead code elimination).
3614
+ *
3615
+ * See the [In-depth Dead Code Elimination Guide](https://rolldown.rs/in-depth/dead-code-elimination) for more details.
3616
+ *
3617
+ * When `false`, tree-shaking will be disabled.
3618
+ * When `true`, it is equivalent to setting each options to the default value.
3619
+ *
3620
+ * @default true
3621
+ */
3622
+ treeshake?: boolean | TreeshakingOptions;
3623
+ /**
3624
+ * Controls the verbosity of console logging during the build.
3625
+ *
3626
+ *
3627
+ *
3628
+ * @default 'info'
3629
+ */
3630
+ logLevel?: LogLevelOption;
3631
+ /**
3632
+ * A function that intercepts log messages. If not supplied, logs are printed to the console.
3633
+ *
3634
+ *
3635
+ *
3636
+ * @example
3637
+ * ```js
3638
+ * export default defineConfig({
3639
+ * onLog(level, log, defaultHandler) {
3640
+ * if (log.code === 'CIRCULAR_DEPENDENCY') {
3641
+ * return; // Ignore circular dependency warnings
3642
+ * }
3643
+ * if (level === 'warn') {
3644
+ * defaultHandler('error', log); // turn other warnings into errors
3645
+ * } else {
3646
+ * defaultHandler(level, log); // otherwise, just print the log
3647
+ * }
3648
+ * }
3649
+ * })
3650
+ * ```
3651
+ */
3652
+ onLog?: OnLogFunction;
3653
+ /**
3654
+ * A function that will intercept warning messages.
3655
+ *
3656
+ *
3657
+ *
3658
+ * @deprecated
3659
+ * This is a legacy API. Consider using {@linkcode onLog} instead for better control over all log types.
3660
+ *
3661
+ *
3662
+ */
3663
+ onwarn?: OnwarnFunction;
3664
+ /**
3665
+ * Maps file patterns to module types, controlling how files are processed.
3666
+ *
3667
+ * This is conceptually similar to [esbuild's `loader`](https://esbuild.github.io/api/#loader) option, allowing you to specify how each file extensions should be handled.
3668
+ *
3669
+ * See [the In-Depth Guide](https://rolldown.rs/in-depth/module-types) for more details.
3670
+ *
3671
+ * @example
3672
+ * ```js
3673
+ * import { defineConfig } from 'rolldown'
3674
+ *
3675
+ * export default defineConfig({
3676
+ * moduleTypes: {
3677
+ * '.frag': 'text',
3678
+ * }
3679
+ * })
3680
+ * ```
3681
+ */
3682
+ moduleTypes?: ModuleTypes;
3683
+ /**
3684
+ * Experimental features that may change in future releases and can introduce behavior change without a major version bump.
3685
+ * @experimental
3686
+ */
3687
+ experimental?: {
3688
+ /**
3689
+ * Enable Vite compatible mode.
3690
+ * @default false
3691
+ * @hidden This option is only meant to be used by Vite. It is not recommended to use this option directly.
3692
+ */
3693
+ viteMode?: boolean;
3694
+ /**
3695
+ * When enabled, `new URL()` calls will be transformed to a stable asset URL which includes the updated name and content hash.
3696
+ * It is necessary to pass `import.meta.url` as the second argument to the
3697
+ * `new URL` constructor, otherwise no transform will be applied.
3698
+ * :::warning
3699
+ * JavaScript and TypeScript files referenced via `new URL('./file.js', import.meta.url)` or `new URL('./file.ts', import.meta.url)` will **not** be transformed or bundled. The file will be copied as-is, meaning TypeScript files remain untransformed and dependencies are not resolved.
3700
+ *
3701
+ * The expected behavior for JS/TS files is still being discussed and may
3702
+ * change in future releases. See [#7258](https://github.com/rolldown/rolldown/issues/7258) for more context.
3703
+ * :::
3704
+ * @example
3705
+ * ```js
3706
+ * // main.js
3707
+ * const url = new URL('./styles.css', import.meta.url);
3708
+ * console.log(url);
3709
+ *
3710
+ * // Example output after bundling WITHOUT the option (default)
3711
+ * const url = new URL('./styles.css', import.meta.url);
3712
+ * console.log(url);
3713
+ *
3714
+ * // Example output after bundling WITH `experimental.resolveNewUrlToAsset` set to `true`
3715
+ * const url = new URL('assets/styles-CjdrdY7X.css', import.meta.url);
3716
+ * console.log(url);
3717
+ * ```
3718
+ * @default false
3719
+ */
3720
+ resolveNewUrlToAsset?: boolean;
3721
+ /**
3722
+ * Dev mode related options.
3723
+ * @hidden not ready for public usage yet
3724
+ */
3725
+ devMode?: DevModeOptions;
3726
+ /**
3727
+ * Control which order should be used when rendering modules in a chunk.
3728
+ *
3729
+ * Available options:
3730
+ * - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
3731
+ * - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
3732
+ *
3733
+ * > [!NOTE]
3734
+ * > Try to sort the modules by their module id if possible (Since rolldown scope hoist all modules in the chunk, we only try to sort those modules by module id if we could ensure runtime behavior is correct after sorting).
3735
+ *
3736
+ * @default 'exec-order'
3737
+ */
3738
+ chunkModulesOrder?: ChunkModulesOrder;
3739
+ /**
3740
+ * Attach debug information to the output bundle.
3741
+ *
3742
+ * Available modes:
3743
+ * - `none`: No debug information is attached.
3744
+ * - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
3745
+ * - `full`: Attach detailed debug information to the output bundle. These comments are using legal comment syntax, so they won't be removed by the minifier.
3746
+ *
3747
+ * @default 'simple'
3748
+ *
3749
+ *
3750
+ */
3751
+ attachDebugInfo?: AttachDebugOptions;
3752
+ /**
3753
+ * Enables automatic generation of a chunk import map asset during build.
3754
+ *
3755
+ * This map only includes chunks with hashed filenames, where keys are derived from the facade module
3756
+ * name or primary chunk name. It produces stable and unique hash-based filenames, effectively preventing
3757
+ * cascading cache invalidation caused by content hashes and maximizing browser cache reuse.
3758
+ *
3759
+ * The output defaults to `importmap.json` unless overridden via `fileName`. A base URL prefix
3760
+ * (default `"/"`) can be applied to all paths. The resulting JSON is a valid import map and can be
3761
+ * directly injected into HTML via `<script type="importmap">`.
3762
+ *
3763
+ * @example
3764
+ * ```js
3765
+ * {
3766
+ * experimental: {
3767
+ * chunkImportMap: {
3768
+ * baseUrl: '/',
3769
+ * fileName: 'importmap.json'
3770
+ * }
3771
+ * },
3772
+ * plugins: [
3773
+ * {
3774
+ * name: 'inject-import-map',
3775
+ * generateBundle(_, bundle) {
3776
+ * const chunkImportMap = bundle['importmap.json'];
3777
+ * if (chunkImportMap?.type === 'asset') {
3778
+ * const htmlPath = path.resolve('index.html');
3779
+ * let html = fs.readFileSync(htmlPath, 'utf-8');
3780
+ *
3781
+ * html = html.replace(
3782
+ * /<script\s+type="importmap"[^>]*>[\s\S]*?<\/script>/i,
3783
+ * `<script type="importmap">${chunkImportMap.source}<\/script>`
3784
+ * );
3785
+ *
3786
+ * fs.writeFileSync(htmlPath, html);
3787
+ * delete bundle['importmap.json'];
3788
+ * }
3789
+ * }
3790
+ * }
3791
+ * ]
3792
+ * }
3793
+ * ```
3794
+ *
3795
+ * > [!TIP]
3796
+ * > If you want to learn more, you can check out the example here: [examples/chunk-import-map](https://github.com/rolldown/rolldown/tree/main/examples/chunk-import-map)
3797
+ *
3798
+ * @default false
3799
+ */
3800
+ chunkImportMap?: boolean | {
3801
+ baseUrl?: string;
3802
+ fileName?: string;
3803
+ };
3804
+ /**
3805
+ * Enable on-demand wrapping of modules.
3806
+ * @default false
3807
+ * @hidden not ready for public usage yet
3808
+ */
3809
+ onDemandWrapping?: boolean;
3810
+ /**
3811
+ * Enable incremental build support. Required to be used with `watch` mode.
3812
+ * @default false
3813
+ */
3814
+ incrementalBuild?: boolean;
3815
+ /**
3816
+ * Use native Rust implementation of MagicString for source map generation.
3817
+ *
3818
+ * [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
3819
+ * for string manipulation and source map generation. When enabled, rolldown will use a native Rust
3820
+ * implementation of MagicString instead of the JavaScript version, providing significantly better performance
3821
+ * during source map generation and code transformation.
3822
+ *
3823
+ * **Benefits**
3824
+ *
3825
+ * - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
3826
+ * especially for large codebases with extensive source maps.
3827
+ * - **Background Processing**: Source map generation is performed asynchronously in a background thread,
3828
+ * allowing the main bundling process to continue without blocking. This parallel processing can significantly
3829
+ * reduce overall build times when working with JavaScript transform hooks.
3830
+ * - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
3831
+ *
3832
+ * @example
3833
+ * ```js
3834
+ * export default {
3835
+ * experimental: {
3836
+ * nativeMagicString: true
3837
+ * },
3838
+ * output: {
3839
+ * sourcemap: true
3840
+ * }
3841
+ * }
3842
+ * ```
3843
+ *
3844
+ * > [!NOTE]
3845
+ * > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
3846
+ * > implementation, there may be edge cases. Please report any discrepancies you encounter.
3847
+ * > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
3848
+ * @default false
3849
+ */
3850
+ nativeMagicString?: boolean;
3851
+ /**
3852
+ * Control chunk optimizations.
3853
+ *
3854
+ * `true` enables both common-chunk merging and redundant dynamic chunk-load avoidance.
3855
+ * `false` disables all chunk optimizations. Use the object form to control
3856
+ * `mergeCommonChunks` and `avoidRedundantChunkLoads` separately.
3857
+ *
3858
+ * These optimizations are automatically disabled when any module uses top-level await (TLA) or contains TLA dependencies,
3859
+ * as they could affect execution order guarantees.
3860
+ *
3861
+ * @default true
3862
+ */
3863
+ chunkOptimization?: boolean | ChunkOptimizationOptions;
3864
+ /**
3865
+ * Control whether to enable lazy barrel optimization.
3866
+ *
3867
+ * Lazy barrel optimization avoids compiling unused re-export modules in side-effect-free barrel modules,
3868
+ * significantly improving build performance for large codebases with many barrel modules.
3869
+ *
3870
+ * This option is planned to be removed in the future. If you need to opt out, please open an issue
3871
+ * describing your use case so we can address it before the option is gone.
3872
+ *
3873
+ * @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
3874
+ * @default false
3875
+ */
3876
+ lazyBarrel?: boolean;
3877
+ };
3878
+ /**
3879
+ * Configure how the code is transformed. This process happens after the `transform` hook.
3880
+ *
3881
+ * @example
3882
+ * **Enable legacy decorators**
3883
+ * ```js
3884
+ * export default defineConfig({
3885
+ * transform: {
3886
+ * decorator: {
3887
+ * legacy: true,
3888
+ * },
3889
+ * },
3890
+ * })
3891
+ * ```
3892
+ * Note that if you have correct `tsconfig.json` file, Rolldown will automatically detect and enable legacy decorators support.
3893
+ *
3894
+ *
3895
+ */
3896
+ transform?: TransformOptions;
3897
+ /**
3898
+ * Watch mode related options.
3899
+ *
3900
+ * These options only take effect when running with the [`--watch`](/apis/cli#w-watch) flag, or using {@linkcode watch | watch()} API.
3901
+ *
3902
+ *
3903
+ *
3904
+ * @experimental
3905
+ */
3906
+ watch?: WatcherOptions | false;
3907
+ /**
3908
+ * Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
3909
+ */
3910
+ checks?: ChecksOptions;
3911
+ /**
3912
+ * Determines if absolute external paths should be converted to relative paths in the output.
3913
+ *
3914
+ * This does not only apply to paths that are absolute in the source but also to paths that are resolved to an absolute path by either a plugin or Rolldown core.
3915
+ *
3916
+ *
3917
+ */
3918
+ makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
3919
+ /**
3920
+ * Devtools integration options.
3921
+ *
3922
+ * When enabled, Rolldown writes JSON-lines devtools output under
3923
+ * `node_modules/.rolldown/{session_id}/`. Consumers can parse the output with
3924
+ * `@rolldown/debug` after `await bundle.close()` resolves.
3925
+ *
3926
+ * @experimental
3927
+ */
3928
+ devtools?: {
3929
+ sessionId?: string;
3930
+ };
3931
+ /**
3932
+ * Controls how entry chunk exports are preserved.
3933
+ *
3934
+ * This determines whether Rolldown needs to create facade chunks (additional wrapper chunks) to maintain the exact export signatures of entry modules, or whether it can combine entry modules with other chunks for optimization.
3935
+ *
3936
+ * @default `'exports-only'`
3937
+ *
3938
+ */
3939
+ preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
3940
+ /**
3941
+ * Configure optimization features for the bundler.
3942
+ */
3943
+ optimization?: OptimizationOptions;
3944
+ /**
3945
+ * The value of `this` at the top level of each module. **Normally, you don't need to set this option.**
3946
+ * @default undefined
3947
+ * @example
3948
+ * **Set custom context**
3949
+ * ```js
3950
+ * export default {
3951
+ * context: 'globalThis',
3952
+ * output: {
3953
+ * format: 'iife',
3954
+ * },
3955
+ * };
3956
+ * ```
3957
+ *
3958
+ */
3959
+ context?: string;
3960
+ /**
3961
+ * Configures TypeScript configuration file resolution and usage.
3962
+ *
3963
+ * @default true
3964
+ */
3965
+ tsconfig?: boolean | string;
3966
+ }
3967
+ //#endregion
3968
+ //#region src/types/rolldown-options.d.ts
3969
+ interface RolldownOptions extends InputOptions {
3970
+ output?: OutputOptions | OutputOptions[];
3971
+ }
3972
+ //#endregion
3973
+ //#region src/utils/define-config.d.ts
3974
+ /**
3975
+ * Type for `default export` of `rolldown.config.js` file.
3976
+ * @category Config
3977
+ */
3978
+ type ConfigExport = RolldownOptions | RolldownOptions[] | RolldownOptionsFunction;
3979
+ /** @category Config */
3980
+ type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => MaybePromise<RolldownOptions | RolldownOptions[]>;
3981
+ /**
3982
+ * A helper to define a rolldown configuration with type hints.
3983
+ *
3984
+ * @example
3985
+ * ```js [rolldown.config.js]
3986
+ * import { defineConfig } from 'rolldown';
3987
+ *
3988
+ * export default defineConfig({
3989
+ * input: 'src/main.js',
3990
+ * output: {
3991
+ * file: 'bundle.js',
3992
+ * },
3993
+ * });
3994
+ * ```
3995
+ *
3996
+ * @category Config
3997
+ */
3998
+ declare function defineConfig(config: RolldownOptions): RolldownOptions;
3999
+ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
4000
+ declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
4001
+ declare function defineConfig(config: ConfigExport): ConfigExport;
4002
+ //#endregion
4003
+ export { MinimalPluginContext as $, SourcemapIgnoreListOption as $t, RolldownPlugin as A, ChunkingContext as At, SourceMapInput as B, OutputOptions as Bt, ParallelPluginHooks as C, BuildOptions as Ct, ResolveIdExtraOptions as D, AdvancedChunksOptions as Dt, PluginMeta as E, AdvancedChunksGroup as Et, BuiltinPlugin as F, GeneratedCodeOptions as Ft, EmittedChunk as G, OutputAsset as Gt, TreeshakingOptions as H, MaybePromise as Ht, RUNTIME_MODULE_ID as I, GeneratedCodePreset as It, GetModuleInfo as J, RenderedModule as Jt, EmittedFile as K, OutputChunk as Kt, VERSION as L, GlobalsFunction as Lt, SourceDescription as M, CodeSplittingNameFunction as Mt, TransformResult as N, CodeSplittingOptions as Nt, ResolveIdResult as O, BuiltinModuleTag as Ot, withFilter as P, CommentsOptions as Pt, defineParallelPlugin as Q, ModuleInfo as Qt, BundleError as R, MinifyOptions as Rt, ObjectHook as S, RolldownBuild as St, Plugin as T, AddonFunction as Tt, TransformPluginContext as U, PartialNull as Ut, OutputBundle as V, PreRenderedAsset as Vt, EmittedAsset as W, StringOrRegExp as Wt, PluginContextResolveOptions as X, SourceMap as Xt, PluginContext as Y, RolldownOutput as Yt, DefineParallelPluginResult as Z, freeExternalMemory as Zt, HookFilterExtension as _, RolldownWatcher as _t, ChunkOptimizationOptions as a, RolldownDirectoryEntry as at, ModuleOptions as b, WatchOptions as bt, InputOption as c, InternalModuleFormat as ct, OptimizationOptions as d, TransformOptions as dt, PluginContextMeta as et, WatcherFileWatcherOptions as f, ChecksOptions as ft, FunctionPluginHooks as g, watch as gt, CustomPluginOptions as h, RolldownMagicString as ht, RolldownOptions as i, BufferEncoding as it, RolldownPluginOption as j, CodeSplittingGroup as jt, ResolvedId as k, ChunkFileNamesFunction as kt, InputOptions as l, NormalizedOutputOptions as lt, AsyncPluginHooks as m, WarningHandlerWithDefault as mt, RolldownOptionsFunction as n, HookFilter as nt, ExternalOption as o, RolldownFileStats as ot, WatcherOptions as p, LoggingFunction as pt, EmittedPrebuiltChunk as q, RenderedChunk as qt, defineConfig as r, ModuleTypeFilter as rt, ExternalOptionFunction as s, RolldownFsModule as st, ConfigExport as t, GeneralHookFilter as tt, ModuleTypes as u, NormalizedInputOptions as ut, ImportKind as v, RolldownWatcherEvent as vt, PartialResolvedId as w, build as wt, ModuleType as x, rolldown as xt, LoadResult as y, RolldownWatcherWatcherEventMap as yt, ExistingRawSourceMap as z, ModuleFormat as zt };