@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10

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