@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731

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