forgepress 0.0.0 → 0.0.1

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