unplugin-cloudflare-tunnel 0.1.0 → 0.1.2

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.
@@ -1,13 +1,20 @@
1
- import { CloudflareTunnelOptions } from "./index.mjs";
1
+ import { t as CloudflareTunnelOptions } from "./options-DI3sWmXl.mjs";
2
2
 
3
- //#region node_modules/rolldown/dist/shared/logging-BpAvp7KV.d.mts
3
+ //#region node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts
4
4
  //#region src/log/logging.d.ts
5
+ /** @inline */
5
6
  type LogLevel = "info" | "debug" | "warn";
7
+ /** @inline */
6
8
  type LogLevelOption = LogLevel | "silent";
9
+ /** @inline */
7
10
  type LogLevelWithError = LogLevel | "error";
8
- interface RollupLog {
11
+ interface RolldownLog {
9
12
  binding?: string;
10
13
  cause?: unknown;
14
+ /**
15
+ * The log code for this log object.
16
+ * @example 'PLUGIN_ERROR'
17
+ */
11
18
  code?: string;
12
19
  exporter?: string;
13
20
  frame?: string;
@@ -19,6 +26,10 @@ interface RollupLog {
19
26
  file?: string;
20
27
  line: number;
21
28
  };
29
+ /**
30
+ * The message for this log object.
31
+ * @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.'
32
+ */
22
33
  message: string;
23
34
  meta?: any;
24
35
  names?: string[];
@@ -29,13 +40,15 @@ interface RollupLog {
29
40
  stack?: string;
30
41
  url?: string;
31
42
  }
32
- type RollupLogWithString = RollupLog | string;
33
- interface RollupError extends RollupLog {
43
+ /** @inline */
44
+ type RolldownLogWithString = RolldownLog | string;
45
+ /** @category Plugin APIs */
46
+ interface RolldownError extends RolldownLog {
34
47
  name?: string;
35
48
  stack?: string;
36
49
  watchFiles?: string[];
37
50
  }
38
- type LogOrStringHandler = (level: LogLevelWithError, log: RollupLogWithString) => void; //#endregion
51
+ type LogOrStringHandler = (level: LogLevelWithError, log: RolldownLogWithString) => void; //#endregion
39
52
  //#endregion
40
53
  //#region node_modules/@oxc-project/types/types.d.ts
41
54
  // Auto-generated code, DO NOT EDIT DIRECTLY!
@@ -467,11 +480,7 @@ interface DebuggerStatement extends Span {
467
480
  type: "DebuggerStatement";
468
481
  parent?: Node;
469
482
  }
470
- type BindingPattern = {
471
- optional?: boolean;
472
- typeAnnotation?: TSTypeAnnotation | null;
473
- } & (BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern);
474
- type BindingPatternKind = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern;
483
+ type BindingPattern = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern;
475
484
  interface AssignmentPattern extends Span {
476
485
  type: "AssignmentPattern";
477
486
  decorators?: [];
@@ -534,7 +543,7 @@ type ParamPattern = FormalParameter | TSParameterProperty | FormalParameterRest;
534
543
  type FunctionType = "FunctionDeclaration" | "FunctionExpression" | "TSDeclareFunction" | "TSEmptyBodyFunctionExpression";
535
544
  interface FormalParameterRest extends Span {
536
545
  type: "RestElement";
537
- argument: BindingPatternKind;
546
+ argument: BindingPattern;
538
547
  decorators?: [];
539
548
  optional?: boolean;
540
549
  typeAnnotation?: TSTypeAnnotation | null;
@@ -1238,8 +1247,8 @@ interface TSConstructorType extends Span {
1238
1247
  }
1239
1248
  interface TSMappedType extends Span {
1240
1249
  type: "TSMappedType";
1241
- key: TSTypeParameter["name"];
1242
- constraint: TSTypeParameter["constraint"];
1250
+ key: BindingIdentifier;
1251
+ constraint: TSType;
1243
1252
  nameType: TSType | null;
1244
1253
  typeAnnotation: TSType | null;
1245
1254
  optional: TSMappedTypeModifierOperator | false;
@@ -1278,7 +1287,7 @@ interface TSImportEqualsDeclaration extends Span {
1278
1287
  importKind: ImportOrExportKind;
1279
1288
  parent?: Node;
1280
1289
  }
1281
- type TSModuleReference = TSExternalModuleReference | TSTypeName;
1290
+ type TSModuleReference = TSExternalModuleReference | IdentifierReference | TSQualifiedName;
1282
1291
  interface TSExternalModuleReference extends Span {
1283
1292
  type: "TSExternalModuleReference";
1284
1293
  expression: StringLiteral;
@@ -1327,20 +1336,20 @@ interface JSDocUnknownType extends Span {
1327
1336
  type: "TSJSDocUnknownType";
1328
1337
  parent?: Node;
1329
1338
  }
1330
- type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
1331
- type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" | "%" | "**" | "<<" | ">>" | ">>>" | "|" | "^" | "&" | "in" | "instanceof";
1332
- type LogicalOperator = "||" | "&&" | "??";
1333
- type UnaryOperator = "+" | "-" | "!" | "~" | "typeof" | "void" | "delete";
1334
- type UpdateOperator = "++" | "--";
1339
+ type ModuleKind = "script" | "module" | "commonjs";
1335
1340
  interface Span {
1336
1341
  start: number;
1337
1342
  end: number;
1338
1343
  range?: [number, number];
1339
1344
  }
1340
- type ModuleKind = "script" | "module";
1345
+ type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
1346
+ type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" | "%" | "**" | "<<" | ">>" | ">>>" | "|" | "^" | "&" | "in" | "instanceof";
1347
+ type LogicalOperator = "||" | "&&" | "??";
1348
+ type UnaryOperator = "+" | "-" | "!" | "~" | "typeof" | "void" | "delete";
1349
+ type UpdateOperator = "++" | "--";
1341
1350
  type Node = Program | IdentifierName | IdentifierReference | BindingIdentifier | LabelIdentifier | ThisExpression | ArrayExpression | ObjectExpression | ObjectProperty | TemplateLiteral | TaggedTemplateExpression | TemplateElement | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | CallExpression | NewExpression | MetaProperty | SpreadElement | UpdateExpression | UnaryExpression | BinaryExpression | PrivateInExpression | LogicalExpression | ConditionalExpression | AssignmentExpression | ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetRest | AssignmentTargetWithDefault | AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty | SequenceExpression | Super | AwaitExpression | ChainExpression | ParenthesizedExpression | Directive | Hashbang | BlockStatement | VariableDeclaration | VariableDeclarator | EmptyStatement | ExpressionStatement | IfStatement | DoWhileStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement | SwitchStatement | SwitchCase | LabeledStatement | ThrowStatement | TryStatement | CatchClause | DebuggerStatement | AssignmentPattern | ObjectPattern | BindingProperty | ArrayPattern | BindingRestElement | Function | FunctionBody | ArrowFunctionExpression | YieldExpression | Class | ClassBody | MethodDefinition | PropertyDefinition | PrivateIdentifier | StaticBlock | AccessorProperty | ImportExpression | ImportDeclaration | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportAttribute | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | ExportSpecifier | V8IntrinsicExpression | BooleanLiteral | NullLiteral | NumericLiteral | StringLiteral | BigIntLiteral | RegExpLiteral | JSXElement | JSXOpeningElement | JSXClosingElement | JSXFragment | JSXOpeningFragment | JSXClosingFragment | JSXNamespacedName | JSXMemberExpression | JSXExpressionContainer | JSXEmptyExpression | JSXAttribute | JSXSpreadAttribute | JSXIdentifier | JSXSpreadChild | JSXText | TSThisParameter | TSEnumDeclaration | TSEnumBody | TSEnumMember | TSTypeAnnotation | TSLiteralType | TSConditionalType | TSUnionType | TSIntersectionType | TSParenthesizedType | TSTypeOperator | TSArrayType | TSIndexedAccessType | TSTupleType | TSNamedTupleMember | TSOptionalType | TSRestType | TSAnyKeyword | TSStringKeyword | TSBooleanKeyword | TSNumberKeyword | TSNeverKeyword | TSIntrinsicKeyword | TSUnknownKeyword | TSNullKeyword | TSUndefinedKeyword | TSVoidKeyword | TSSymbolKeyword | TSThisType | TSObjectKeyword | TSBigIntKeyword | TSTypeReference | TSQualifiedName | TSTypeParameterInstantiation | TSTypeParameter | TSTypeParameterDeclaration | TSTypeAliasDeclaration | TSClassImplements | TSInterfaceDeclaration | TSInterfaceBody | TSPropertySignature | TSIndexSignature | TSCallSignatureDeclaration | TSMethodSignature | TSConstructSignatureDeclaration | TSIndexSignatureName | TSInterfaceHeritage | TSTypePredicate | TSModuleDeclaration | TSGlobalDeclaration | TSModuleBlock | TSTypeLiteral | TSInferType | TSTypeQuery | TSImportType | TSImportTypeQualifiedName | TSFunctionType | TSConstructorType | TSMappedType | TSTemplateLiteralType | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSImportEqualsDeclaration | TSExternalModuleReference | TSNonNullExpression | Decorator | TSExportAssignment | TSNamespaceExportDeclaration | TSInstantiationExpression | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType | ParamPattern;
1342
1351
  //#endregion
1343
- //#region node_modules/rolldown/dist/shared/binding-CDyF6W3D.d.mts
1352
+ //#region node_modules/rolldown/dist/shared/binding-DUEnSb0A.d.mts
1344
1353
  interface CodegenOptions {
1345
1354
  /**
1346
1355
  * Remove whitespace.
@@ -1435,7 +1444,7 @@ interface MangleOptions {
1435
1444
  /**
1436
1445
  * Pass `true` to mangle names declared in the top level scope.
1437
1446
  *
1438
- * @default false
1447
+ * @default true for modules and commonjs, otherwise false
1439
1448
  */
1440
1449
  toplevel?: boolean;
1441
1450
  /**
@@ -1461,11 +1470,6 @@ interface MangleOptionsKeepNames {
1461
1470
  */
1462
1471
  class: boolean;
1463
1472
  }
1464
- /**
1465
- * Minify asynchronously.
1466
- *
1467
- * Note: This function can be slower than `minifySync` due to the overhead of spawning a thread.
1468
- */
1469
1473
  interface MinifyOptions$1 {
1470
1474
  /** Use when minifying an ES module. */
1471
1475
  module?: boolean;
@@ -1506,12 +1510,21 @@ interface TreeShakeOptions {
1506
1510
  * @default true
1507
1511
  */
1508
1512
  unknownGlobalSideEffects?: boolean;
1513
+ /**
1514
+ * Whether invalid import statements have side effects.
1515
+ *
1516
+ * Accessing a non-existing import name will throw an error.
1517
+ * Also import statements that cannot be resolved will throw an error.
1518
+ *
1519
+ * @default true
1520
+ */
1521
+ invalidImportSideEffects?: boolean;
1509
1522
  }
1510
1523
  interface ParserOptions {
1511
1524
  /** Treat the source text as `js`, `jsx`, `ts`, `tsx` or `dts`. */
1512
1525
  lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts';
1513
1526
  /** Treat the source text as `script` or `module` code. */
1514
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1527
+ sourceType?: 'script' | 'module' | 'commonjs' | 'unambiguous' | undefined;
1515
1528
  /**
1516
1529
  * Return an AST which includes TypeScript-related properties, or excludes them.
1517
1530
  *
@@ -1662,7 +1675,7 @@ interface IsolatedDeclarationsOptions {
1662
1675
  /**
1663
1676
  * Configure how TSX and JSX are transformed.
1664
1677
  *
1665
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
1678
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
1666
1679
  */
1667
1680
  interface JsxOptions {
1668
1681
  /**
@@ -1678,8 +1691,6 @@ interface JsxOptions {
1678
1691
  * Emit development-specific information, such as `__source` and `__self`.
1679
1692
  *
1680
1693
  * @default false
1681
- *
1682
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
1683
1694
  */
1684
1695
  development?: boolean;
1685
1696
  /**
@@ -1693,11 +1704,7 @@ interface JsxOptions {
1693
1704
  */
1694
1705
  throwIfNamespace?: boolean;
1695
1706
  /**
1696
- * Enables `@babel/plugin-transform-react-pure-annotations`.
1697
- *
1698
- * It will mark JSX elements and top-level React method calls as pure for tree shaking.
1699
- *
1700
- * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
1707
+ * Mark JSX elements and top-level React method calls as pure for tree shaking.
1701
1708
  *
1702
1709
  * @default true
1703
1710
  */
@@ -1727,23 +1734,6 @@ interface JsxOptions {
1727
1734
  * @default 'React.Fragment'
1728
1735
  */
1729
1736
  pragmaFrag?: string;
1730
- /**
1731
- * When spreading props, use `Object.assign` directly instead of an extend helper.
1732
- *
1733
- * Only used for `classic` {@link runtime}.
1734
- *
1735
- * @default false
1736
- */
1737
- useBuiltIns?: boolean;
1738
- /**
1739
- * When spreading props, use inline object with spread elements directly
1740
- * instead of an extend helper or Object.assign.
1741
- *
1742
- * Only used for `classic` {@link runtime}.
1743
- *
1744
- * @default false
1745
- */
1746
- useSpread?: boolean;
1747
1737
  /**
1748
1738
  * Enable React Fast Refresh .
1749
1739
  *
@@ -1790,7 +1780,7 @@ interface ReactRefreshOptions {
1790
1780
  /**
1791
1781
  * Configure how styled-components are transformed.
1792
1782
  *
1793
- * @see {@link https://styled-components.com/docs/tooling#babel-plugin}
1783
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins#styled-components}
1794
1784
  */
1795
1785
  interface StyledComponentsOptions {
1796
1786
  /**
@@ -1865,20 +1855,6 @@ interface StyledComponentsOptions {
1865
1855
  */
1866
1856
  topLevelImportPaths?: Array<string>;
1867
1857
  }
1868
- /**
1869
- * Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
1870
- *
1871
- * Note: This function can be slower than `transform` due to the overhead of spawning a thread.
1872
- *
1873
- * @param filename The name of the file being transformed. If this is a
1874
- * relative path, consider setting the {@link TransformOptions#cwd} option.
1875
- * @param sourceText the source code itself
1876
- * @param options The options for the transformation. See {@link
1877
- * TransformOptions} for more information.
1878
- *
1879
- * @returns a promise that resolves to an object containing the transformed code,
1880
- * source maps, and any errors that occurred during parsing or transformation.
1881
- */
1882
1858
  /**
1883
1859
  * Options for transforming a JavaScript or TypeScript file.
1884
1860
  *
@@ -1888,7 +1864,7 @@ interface TransformOptions$1 {
1888
1864
  /** Treat the source text as `js`, `jsx`, `ts`, `tsx`, or `dts`. */
1889
1865
  lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts';
1890
1866
  /** Treat the source text as `script` or `module` code. */
1891
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1867
+ sourceType?: 'script' | 'module' | 'commonjs' | 'unambiguous' | undefined;
1892
1868
  /**
1893
1869
  * The current working directory. Used to resolve relative paths in other
1894
1870
  * options.
@@ -1906,9 +1882,15 @@ interface TransformOptions$1 {
1906
1882
  sourcemap?: boolean;
1907
1883
  /** Set assumptions in order to produce smaller output. */
1908
1884
  assumptions?: CompilerAssumptions;
1909
- /** Configure how TypeScript is transformed. */
1885
+ /**
1886
+ * Configure how TypeScript is transformed.
1887
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/typescript}
1888
+ */
1910
1889
  typescript?: TypeScriptOptions;
1911
- /** Configure how TSX and JSX are transformed. */
1890
+ /**
1891
+ * Configure how TSX and JSX are transformed.
1892
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
1893
+ */
1912
1894
  jsx?: 'preserve' | JsxOptions;
1913
1895
  /**
1914
1896
  * Sets the target environment for the generated JavaScript.
@@ -1922,18 +1904,27 @@ interface TransformOptions$1 {
1922
1904
  *
1923
1905
  * @default `esnext` (No transformation)
1924
1906
  *
1925
- * @see [esbuild#target](https://esbuild.github.io/api/#target)
1907
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/lowering#target}
1926
1908
  */
1927
1909
  target?: string | Array<string>;
1928
1910
  /** Behaviour for runtime helpers. */
1929
1911
  helpers?: Helpers;
1930
- /** Define Plugin */
1912
+ /**
1913
+ * Define Plugin
1914
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define}
1915
+ */
1931
1916
  define?: Record<string, string>;
1932
- /** Inject Plugin */
1917
+ /**
1918
+ * Inject Plugin
1919
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#inject}
1920
+ */
1933
1921
  inject?: Record<string, string | [string, string]>;
1934
1922
  /** Decorator plugin */
1935
1923
  decorator?: DecoratorOptions;
1936
- /** Third-party plugins to use. */
1924
+ /**
1925
+ * Third-party plugins to use.
1926
+ * @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins}
1927
+ */
1937
1928
  plugins?: PluginsOptions;
1938
1929
  }
1939
1930
  interface TypeScriptOptions {
@@ -2007,25 +1998,111 @@ interface TypeScriptOptions {
2007
1998
  */
2008
1999
  rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
2009
2000
  }
2001
+ /** A decoded source map with mappings as an array of arrays instead of VLQ-encoded string. */
2002
+ declare class BindingDecodedMap {
2003
+ /** The source map version (always 3). */
2004
+ get version(): number;
2005
+ /** The generated file name. */
2006
+ get file(): string | null;
2007
+ /** The list of original source files. */
2008
+ get sources(): Array<string>;
2009
+ /** The original source contents (if `includeContent` was true). */
2010
+ get sourcesContent(): Array<string | undefined | null>;
2011
+ /** The list of symbol names used in mappings. */
2012
+ get names(): Array<string>;
2013
+ /**
2014
+ * The decoded mappings as an array of line arrays.
2015
+ * Each line is an array of segments, where each segment is [generatedColumn, sourceIndex, originalLine, originalColumn, nameIndex?].
2016
+ */
2017
+ get mappings(): Array<Array<Array<number>>>;
2018
+ /** The list of source indices that should be excluded from debugging. */
2019
+ get x_google_ignoreList(): Array<number> | null;
2020
+ }
2010
2021
  declare class BindingMagicString {
2011
- constructor(source: string);
2012
- replace(from: string, to: string): void;
2013
- replaceAll(from: string, to: string): void;
2014
- prepend(content: string): void;
2015
- append(content: string): void;
2016
- prependLeft(index: number, content: string): void;
2017
- prependRight(index: number, content: string): void;
2018
- appendLeft(index: number, content: string): void;
2019
- appendRight(index: number, content: string): void;
2020
- overwrite(start: number, end: number, content: string): void;
2022
+ constructor(source: string, options?: BindingMagicStringOptions | undefined | null);
2023
+ get original(): string;
2024
+ get filename(): string | null;
2025
+ get indentExclusionRanges(): Array<Array<number>> | Array<number> | null;
2026
+ get ignoreList(): boolean;
2027
+ get offset(): number;
2028
+ set offset(offset: number);
2029
+ replace(from: string, to: string): this;
2030
+ replaceAll(from: string, to: string): this;
2031
+ /**
2032
+ * Returns the UTF-16 offset past the last match, or -1 if no match was found.
2033
+ * The JS wrapper uses this to update `lastIndex` on the caller's RegExp.
2034
+ * Global/sticky behavior is derived from the regex's own flags.
2035
+ */
2036
+ replaceRegex(from: RegExp, to: string): number;
2037
+ prepend(content: string): this;
2038
+ append(content: string): this;
2039
+ prependLeft(index: number, content: string): this;
2040
+ prependRight(index: number, content: string): this;
2041
+ appendLeft(index: number, content: string): this;
2042
+ appendRight(index: number, content: string): this;
2043
+ overwrite(start: number, end: number, content: string, options?: BindingOverwriteOptions | undefined | null): this;
2021
2044
  toString(): string;
2022
2045
  hasChanged(): boolean;
2023
2046
  length(): number;
2024
2047
  isEmpty(): boolean;
2025
- remove(start: number, end: number): void;
2026
- update(start: number, end: number, content: string): void;
2027
- relocate(start: number, end: number, to: number): void;
2028
- indent(indentor?: string | undefined | null): void;
2048
+ remove(start: number, end: number): this;
2049
+ update(start: number, end: number, content: string, options?: BindingUpdateOptions | undefined | null): this;
2050
+ relocate(start: number, end: number, to: number): this;
2051
+ /**
2052
+ * Alias for `relocate` to match the original magic-string API.
2053
+ * Moves the characters from `start` to `end` to `index`.
2054
+ * Returns `this` for method chaining.
2055
+ */
2056
+ move(start: number, end: number, index: number): this;
2057
+ indent(indentor?: string | undefined | null, options?: BindingIndentOptions | undefined | null): this;
2058
+ /** Trims whitespace or specified characters from the start and end. */
2059
+ trim(charType?: string | undefined | null): this;
2060
+ /** Trims whitespace or specified characters from the start. */
2061
+ trimStart(charType?: string | undefined | null): this;
2062
+ /** Trims whitespace or specified characters from the end. */
2063
+ trimEnd(charType?: string | undefined | null): this;
2064
+ /** Trims newlines from the start and end. */
2065
+ trimLines(): this;
2066
+ /**
2067
+ * Deprecated method that throws an error directing users to use prependRight or appendLeft.
2068
+ * This matches the original magic-string API which deprecated this method.
2069
+ */
2070
+ insert(index: number, content: string): void;
2071
+ /** Returns a clone of the MagicString instance. */
2072
+ clone(): BindingMagicString;
2073
+ /** Returns the last character of the generated string, or an empty string if empty. */
2074
+ lastChar(): string;
2075
+ /** Returns the content after the last newline in the generated string. */
2076
+ lastLine(): string;
2077
+ /** Returns the guessed indentation string, or `\t` if none is found. */
2078
+ getIndentString(): string;
2079
+ /** Returns a clone with content outside the specified range removed. */
2080
+ snip(start: number, end: number): BindingMagicString;
2081
+ /**
2082
+ * Resets the portion of the string from `start` to `end` to its original content.
2083
+ * This undoes any modifications made to that range.
2084
+ * Supports negative indices (counting from the end).
2085
+ */
2086
+ reset(start: number, end: number): this;
2087
+ /**
2088
+ * Returns the content between the specified UTF-16 code unit positions (JS string indices).
2089
+ * Supports negative indices (counting from the end).
2090
+ *
2091
+ * When an index falls in the middle of a surrogate pair, the lone surrogate is
2092
+ * included in the result (matching the original magic-string / JS behavior).
2093
+ * This is done by returning a UTF-16 encoded JS string via `napi_create_string_utf16`.
2094
+ */
2095
+ slice(start?: number | undefined | null, end?: number | undefined | null): string;
2096
+ /**
2097
+ * Generates a source map for the transformations applied to this MagicString.
2098
+ * Returns a BindingSourceMap object with version, file, sources, sourcesContent, names, mappings.
2099
+ */
2100
+ generateMap(options?: BindingSourceMapOptions | undefined | null): BindingSourceMap;
2101
+ /**
2102
+ * Generates a decoded source map for the transformations applied to this MagicString.
2103
+ * Returns a BindingDecodedMap object with mappings as an array of arrays.
2104
+ */
2105
+ generateDecodedMap(options?: BindingSourceMapOptions | undefined | null): BindingDecodedMap;
2029
2106
  }
2030
2107
  declare class BindingRenderedChunk {
2031
2108
  get name(): string;
@@ -2043,7 +2120,32 @@ declare class BindingRenderedModule {
2043
2120
  get code(): string | null;
2044
2121
  get renderedExports(): Array<string>;
2045
2122
  }
2046
- type BindingBuiltinPluginName = 'builtin:esm-external-require' | 'builtin:isolated-declaration' | 'builtin:replace' | 'builtin:vite-alias' | 'builtin:vite-asset' | 'builtin:vite-asset-import-meta-url' | 'builtin:vite-build-import-analysis' | 'builtin:vite-css' | 'builtin:vite-css-post' | 'builtin:vite-dynamic-import-vars' | 'builtin:vite-html' | 'builtin:vite-html-inline-proxy' | '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-wasm-fallback' | 'builtin:vite-wasm-helper' | 'builtin:vite-web-worker-post';
2123
+ /** A source map object with properties matching the SourceMap V3 specification. */
2124
+ declare class BindingSourceMap {
2125
+ /** The source map version (always 3). */
2126
+ get version(): number;
2127
+ /** The generated file name. */
2128
+ get file(): string | null;
2129
+ /** The list of original source files. */
2130
+ get sources(): Array<string>;
2131
+ /** The original source contents (if `includeContent` was true). */
2132
+ get sourcesContent(): Array<string | undefined | null>;
2133
+ /** The list of symbol names used in mappings. */
2134
+ get names(): Array<string>;
2135
+ /** The VLQ-encoded mappings string. */
2136
+ get mappings(): string;
2137
+ /** The list of source indices that should be excluded from debugging. */
2138
+ get x_google_ignoreList(): Array<number> | null;
2139
+ /** Returns the source map as a JSON string. */
2140
+ toString(): string;
2141
+ /** Returns the source map as a base64-encoded data URL. */
2142
+ toUrl(): string;
2143
+ }
2144
+ /**
2145
+ * Minimal wrapper around a `BundleHandle` for watcher events.
2146
+ * This is returned from watcher event data to allow calling `result.close()`.
2147
+ */
2148
+ 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-wasm-fallback' | 'builtin:vite-web-worker-post' | 'builtin:oxc-runtime';
2047
2149
  interface BindingHookResolveIdExtraArgs {
2048
2150
  custom?: number;
2049
2151
  isEntry: boolean;
@@ -2058,25 +2160,82 @@ interface BindingHookResolveIdExtraArgs {
2058
2160
  */
2059
2161
  kind: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
2060
2162
  }
2163
+ interface BindingIndentOptions {
2164
+ exclude?: Array<Array<number>> | Array<number>;
2165
+ }
2166
+ interface BindingMagicStringOptions {
2167
+ filename?: string;
2168
+ offset?: number;
2169
+ indentExclusionRanges?: Array<Array<number>> | Array<number>;
2170
+ ignoreList?: boolean;
2171
+ }
2061
2172
  interface BindingModules {
2062
2173
  values: Array<BindingRenderedModule>;
2063
2174
  keys: Array<string>;
2064
2175
  }
2176
+ interface BindingOverwriteOptions {
2177
+ contentOnly?: boolean;
2178
+ }
2179
+ interface BindingPluginContextResolveOptions {
2180
+ /**
2181
+ * - `import-statement`: `import { foo } from './lib.js';`
2182
+ * - `dynamic-import`: `import('./lib.js')`
2183
+ * - `require-call`: `require('./lib.js')`
2184
+ * - `import-rule`: `@import 'bg-color.css'`
2185
+ * - `url-token`: `url('./icon.png')`
2186
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
2187
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
2188
+ */
2189
+ importKind?: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
2190
+ isEntry?: boolean;
2191
+ skipSelf?: boolean;
2192
+ custom?: number;
2193
+ vitePluginCustom?: BindingVitePluginCustom;
2194
+ }
2195
+ interface BindingSourceMapOptions {
2196
+ /** The filename for the generated file (goes into `map.file`) */
2197
+ file?: string;
2198
+ /** The filename of the original source (goes into `map.sources`) */
2199
+ source?: string;
2200
+ includeContent?: boolean;
2201
+ /**
2202
+ * Accepts boolean or string: true, false, "boundary"
2203
+ * - true: high-resolution sourcemaps (character-level)
2204
+ * - false: low-resolution sourcemaps (line-level) - default
2205
+ * - "boundary": high-resolution only at word boundaries
2206
+ */
2207
+ hires?: boolean | string;
2208
+ }
2065
2209
  interface BindingTransformHookExtraArgs {
2066
2210
  moduleType: string;
2067
2211
  }
2212
+ interface BindingUpdateOptions {
2213
+ overwrite?: boolean;
2214
+ }
2215
+ interface BindingVitePluginCustom {
2216
+ 'vite:import-glob'?: ViteImportGlobMeta;
2217
+ }
2068
2218
  interface ExternalMemoryStatus {
2069
2219
  freed: boolean;
2070
2220
  reason?: string;
2071
2221
  }
2072
2222
  /** Error emitted from native side, it only contains kind and message, no stack trace. */
2073
2223
  interface PreRenderedChunk {
2224
+ /** The name of this chunk, which is used in naming patterns. */
2074
2225
  name: string;
2226
+ /** Whether this chunk is a static entry point. */
2075
2227
  isEntry: boolean;
2228
+ /** Whether this chunk is a dynamic entry point. */
2076
2229
  isDynamicEntry: boolean;
2230
+ /** The id of a module that this chunk corresponds to. */
2077
2231
  facadeModuleId?: string;
2232
+ /** The list of ids of modules included in this chunk. */
2078
2233
  moduleIds: Array<string>;
2234
+ /** Exported variable names from this chunk. */
2079
2235
  exports: Array<string>;
2236
+ }
2237
+ interface ViteImportGlobMeta {
2238
+ isSubImportsPattern?: boolean;
2080
2239
  } //#endregion
2081
2240
  //#endregion
2082
2241
  //#region node_modules/@rolldown/pluginutils/dist/filter/composable-filters.d.ts
@@ -2141,26 +2300,66 @@ declare class Exclude$1 {
2141
2300
  constructor(expr: FilterExpression);
2142
2301
  }
2143
2302
  //#endregion
2144
- //#region node_modules/rolldown/dist/shared/define-config-kYHtCO-M.d.mts
2303
+ //#region node_modules/rolldown/dist/shared/define-config-DhJZwTRw.d.mts
2145
2304
  //#region src/types/misc.d.ts
2305
+ /** @inline */
2146
2306
  type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
2307
+ /** @inline */
2147
2308
  type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean; //#endregion
2148
2309
  //#region src/types/module-info.d.ts
2310
+ /** @category Plugin APIs */
2149
2311
  interface ModuleInfo extends ModuleOptions {
2150
2312
  /**
2151
- * Unsupported at rolldown
2313
+ * @hidden Not supported by Rolldown
2152
2314
  */
2153
2315
  ast: any;
2316
+ /**
2317
+ * The source code of the module.
2318
+ *
2319
+ * `null` if external or not yet available.
2320
+ */
2154
2321
  code: string | null;
2322
+ /**
2323
+ * The id of the module for convenience
2324
+ */
2155
2325
  id: string;
2326
+ /**
2327
+ * The ids of all modules that statically import this module.
2328
+ */
2156
2329
  importers: string[];
2330
+ /**
2331
+ * The ids of all modules that dynamically import this module.
2332
+ */
2157
2333
  dynamicImporters: string[];
2334
+ /**
2335
+ * The module ids statically imported by this module.
2336
+ */
2158
2337
  importedIds: string[];
2338
+ /**
2339
+ * The module ids dynamically imported by this module.
2340
+ */
2159
2341
  dynamicallyImportedIds: string[];
2342
+ /**
2343
+ * All exported variables
2344
+ */
2160
2345
  exports: string[];
2346
+ /**
2347
+ * Whether this module is a user- or plugin-defined entry point.
2348
+ */
2161
2349
  isEntry: boolean;
2350
+ /**
2351
+ * The detected format of the module, based on both its syntax and module definition
2352
+ * metadata (such as `package.json` `type` and file extensions like `.mjs`/`.cjs`/`.mts`/`.cts`).
2353
+ * - "esm" for ES modules (has `import`/`export` statements or is defined as ESM by module metadata)
2354
+ * - "cjs" for CommonJS modules (uses `module.exports`, `exports`, top-level `return`, or is defined as CommonJS by module metadata)
2355
+ * - "unknown" when the format could not be determined from either syntax or module definition metadata
2356
+ *
2357
+ * @experimental
2358
+ */
2359
+ inputFormat: "es" | "cjs" | "unknown";
2162
2360
  } //#endregion
2163
2361
  //#region src/utils/asset-source.d.ts
2362
+ /** @inline */
2164
2363
  type AssetSource = string | Uint8Array; //#endregion
2165
2364
  //#region src/types/external-memory-handle.d.ts
2166
2365
  declare const symbolForExternalMemoryHandle: "__rolldown_external_memory_handle__";
@@ -2213,17 +2412,26 @@ interface ExternalMemoryHandle {
2213
2412
  */
2214
2413
  //#endregion
2215
2414
  //#region src/types/rolldown-output.d.ts
2415
+ /**
2416
+ * The information about an asset in the generated bundle.
2417
+ *
2418
+ * @category Plugin APIs
2419
+ */
2216
2420
  interface OutputAsset extends ExternalMemoryHandle {
2217
2421
  type: "asset";
2422
+ /** The file name of this asset. */
2218
2423
  fileName: string;
2219
- /** @deprecated Use "originalFileNames" instead. */
2424
+ /** @deprecated Use {@linkcode originalFileNames} instead. */
2220
2425
  originalFileName: string | null;
2426
+ /** The list of the absolute paths to the original file of this asset. */
2221
2427
  originalFileNames: string[];
2428
+ /** The content of this asset. */
2222
2429
  source: AssetSource;
2223
- /** @deprecated Use "names" instead. */
2430
+ /** @deprecated Use {@linkcode names} instead. */
2224
2431
  name: string | undefined;
2225
2432
  names: string[];
2226
2433
  }
2434
+ /** @category Plugin APIs */
2227
2435
  interface SourceMap {
2228
2436
  file: string;
2229
2437
  mappings: string;
@@ -2236,52 +2444,95 @@ interface SourceMap {
2236
2444
  toString(): string;
2237
2445
  toUrl(): string;
2238
2446
  }
2447
+ /** @category Plugin APIs */
2239
2448
  interface RenderedModule {
2240
2449
  readonly code: string | null;
2241
2450
  renderedLength: number;
2242
2451
  renderedExports: string[];
2243
2452
  }
2453
+ /**
2454
+ * The information about the chunk being rendered.
2455
+ *
2456
+ * Unlike {@link OutputChunk}, `code` and `map` are not set as the chunk has not been rendered yet.
2457
+ * All referenced chunk file names in each property that would contain hashes will contain hash placeholders instead.
2458
+ *
2459
+ * @category Plugin APIs
2460
+ */
2244
2461
  interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
2245
2462
  type: "chunk";
2463
+ /** Information about the modules included in this chunk. */
2246
2464
  modules: {
2247
2465
  [id: string]: RenderedModule;
2248
2466
  };
2467
+ /** The name of this chunk, which is used in naming patterns. */
2249
2468
  name: string;
2469
+ /** Whether this chunk is a static entry point. */
2250
2470
  isEntry: boolean;
2471
+ /** Whether this chunk is a dynamic entry point. */
2251
2472
  isDynamicEntry: boolean;
2473
+ /** The id of a module that this chunk corresponds to. */
2252
2474
  facadeModuleId: string | null;
2475
+ /** The list of ids of modules included in this chunk. */
2253
2476
  moduleIds: Array<string>;
2477
+ /** Exported variable names from this chunk. */
2254
2478
  exports: Array<string>;
2479
+ /** The preliminary file name of this chunk with hash placeholders. */
2255
2480
  fileName: string;
2481
+ /** External modules imported statically by this chunk. */
2256
2482
  imports: Array<string>;
2483
+ /** External modules imported dynamically by this chunk. */
2257
2484
  dynamicImports: Array<string>;
2258
2485
  }
2486
+ /**
2487
+ * The information about a chunk in the generated bundle.
2488
+ *
2489
+ * @category Plugin APIs
2490
+ */
2259
2491
  interface OutputChunk extends ExternalMemoryHandle {
2260
2492
  type: "chunk";
2493
+ /** The generated code of this chunk. */
2261
2494
  code: string;
2495
+ /** The name of this chunk, which is used in naming patterns. */
2262
2496
  name: string;
2497
+ /** Whether this chunk is a static entry point. */
2263
2498
  isEntry: boolean;
2499
+ /** Exported variable names from this chunk. */
2264
2500
  exports: string[];
2501
+ /** The file name of this chunk. */
2265
2502
  fileName: string;
2503
+ /** Information about the modules included in this chunk. */
2266
2504
  modules: {
2267
2505
  [id: string]: RenderedModule;
2268
2506
  };
2507
+ /** External modules imported statically by this chunk. */
2269
2508
  imports: string[];
2509
+ /** External modules imported dynamically by this chunk. */
2270
2510
  dynamicImports: string[];
2511
+ /** The id of a module that this chunk corresponds to. */
2271
2512
  facadeModuleId: string | null;
2513
+ /** Whether this chunk is a dynamic entry point. */
2272
2514
  isDynamicEntry: boolean;
2273
2515
  moduleIds: string[];
2516
+ /** The source map of this chunk if present. */
2274
2517
  map: SourceMap | null;
2275
2518
  sourcemapFileName: string | null;
2519
+ /** The preliminary file name of this chunk with hash placeholders. */
2276
2520
  preliminaryFileName: string;
2277
2521
  }
2522
+ /**
2523
+ * The generated bundle output.
2524
+ *
2525
+ * @category Programmatic APIs
2526
+ */
2278
2527
  //#endregion
2279
2528
  //#region src/types/utils.d.ts
2280
2529
  type MaybePromise<T> = T | Promise<T>;
2530
+ /** @inline */
2281
2531
  type NullValue<T = void> = T | undefined | null | void;
2282
2532
  type PartialNull<T> = { [P in keyof T]: T[P] | null };
2283
2533
  type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
2284
2534
  type MaybeArray<T> = T | T[];
2535
+ /** @inline */
2285
2536
  type StringOrRegExp = string | RegExp; //#endregion
2286
2537
  //#region src/options/output-options.d.ts
2287
2538
  type GeneratedCodePreset = "es5" | "es2015";
@@ -2304,6 +2555,8 @@ interface GeneratedCodeOptions {
2304
2555
  * }
2305
2556
  * };
2306
2557
  * ```
2558
+ *
2559
+ * @default 'es2015'
2307
2560
  */
2308
2561
  preset?: GeneratedCodePreset;
2309
2562
  /**
@@ -2312,70 +2565,156 @@ interface GeneratedCodeOptions {
2312
2565
  * When enabled, generated code will use descriptive variable names that correspond
2313
2566
  * to the original module names, making it easier to profile and debug the bundled code.
2314
2567
  *
2315
- * Note: Enabling this option makes the output more difficult to minify effectively.
2316
- *
2317
2568
  * @default false
2569
+ *
2570
+ *
2318
2571
  */
2319
2572
  profilerNames?: boolean;
2320
2573
  }
2574
+ /** @inline */
2321
2575
  type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
2576
+ /** @inline */
2322
2577
  type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
2578
+ /** @inline */
2323
2579
  type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
2580
+ /** @inline */
2324
2581
  type SanitizeFileNameFunction = (name: string) => string;
2582
+ /** @category Plugin APIs */
2325
2583
  interface PreRenderedAsset {
2326
2584
  type: "asset";
2585
+ /** @deprecated Use {@linkcode names} instead. */
2327
2586
  name?: string;
2328
2587
  names: string[];
2588
+ /** @deprecated Use {@linkcode originalFileNames} instead. */
2329
2589
  originalFileName?: string;
2590
+ /** The list of the absolute paths to the original file of this asset. */
2330
2591
  originalFileNames: string[];
2331
- source: string | Uint8Array;
2592
+ /** The content of this asset. */
2593
+ source: AssetSource;
2332
2594
  }
2595
+ /** @inline */
2333
2596
  type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
2597
+ /** @inline */
2334
2598
  type PathsFunction$1 = (id: string) => string;
2599
+ /** @inline */
2335
2600
  type ManualChunksFunction = (moduleId: string, meta: {
2336
2601
  getModuleInfo: (moduleId: string) => ModuleInfo | null;
2337
2602
  }) => string | NullValue;
2603
+ /** @inline */
2338
2604
  type GlobalsFunction = (name: string) => string;
2339
- type AdvancedChunksNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
2340
- type AdvancedChunksTestFunction = (id: string) => boolean | undefined | void;
2605
+ /** @category Plugin APIs */
2606
+ type CodeSplittingNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
2607
+ /** @inline */
2608
+ type CodeSplittingTestFunction = (id: string) => boolean | undefined | void;
2341
2609
  type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
2610
+ interface CommentsOptions {
2611
+ /**
2612
+ * Comments that contain `@license`, `@preserve` or start with `//!` or `/*!`
2613
+ */
2614
+ legal?: boolean;
2615
+ /**
2616
+ * Comments that contain `@__PURE__`, `@__NO_SIDE_EFFECTS__` or `@vite-ignore`
2617
+ */
2618
+ annotation?: boolean;
2619
+ /**
2620
+ * JSDoc comments
2621
+ */
2622
+ jsdoc?: boolean;
2623
+ }
2624
+ /** @inline */
2342
2625
  interface ChunkingContext {
2343
2626
  getModuleInfo(moduleId: string): ModuleInfo | null;
2344
2627
  }
2345
2628
  interface OutputOptions {
2629
+ /**
2630
+ * The directory in which all generated chunks are placed.
2631
+ *
2632
+ * The {@linkcode file | output.file} option can be used instead if only a single chunk is generated.
2633
+ *
2634
+ *
2635
+ *
2636
+ * @default 'dist'
2637
+ */
2346
2638
  dir?: string;
2639
+ /**
2640
+ * The file path for the single generated chunk.
2641
+ *
2642
+ * The {@linkcode dir | output.dir} option should be used instead if multiple chunks are generated.
2643
+ */
2347
2644
  file?: string;
2645
+ /**
2646
+ * Which exports mode to use.
2647
+ *
2648
+ *
2649
+ *
2650
+ * @default 'auto'
2651
+ */
2348
2652
  exports?: "auto" | "named" | "default" | "none";
2653
+ /**
2654
+ * Specify the character set that Rolldown is allowed to use in file hashes.
2655
+ *
2656
+ * - `'base64'`: Uses url-safe base64 characters (0-9, a-z, A-Z, -, _). This will produce the shortest hashes.
2657
+ * - `'base36'`: Uses alphanumeric characters (0-9, a-z)
2658
+ * - `'hex'`: Uses hexadecimal characters (0-9, a-f)
2659
+ *
2660
+ * @default 'base64'
2661
+ */
2349
2662
  hashCharacters?: "base64" | "base36" | "hex";
2350
2663
  /**
2351
2664
  * Expected format of generated code.
2665
+ *
2352
2666
  * - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
2353
2667
  * - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
2354
2668
  * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
2355
2669
  * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
2356
2670
  *
2357
- * @default 'esm'
2671
+ * @default 'es'
2672
+ *
2673
+ *
2358
2674
  */
2359
2675
  format?: ModuleFormat;
2676
+ /**
2677
+ * Whether to generate sourcemaps.
2678
+ *
2679
+ * - `false`: No sourcemap will be generated.
2680
+ * - `true`: A separate sourcemap file will be generated.
2681
+ * - `'inline'`: The sourcemap will be appended to the output file as a data URL.
2682
+ * - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (`//# sourceMappingURL` comment) will not be included in the output file.
2683
+ *
2684
+ * @default false
2685
+ */
2360
2686
  sourcemap?: boolean | "inline" | "hidden";
2687
+ /**
2688
+ * The base URL for the links to the sourcemap file in the output file.
2689
+ *
2690
+ * 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.
2691
+ */
2361
2692
  sourcemapBaseUrl?: string;
2693
+ /**
2694
+ * Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
2695
+ *
2696
+ * When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
2697
+ *
2698
+ * @default false
2699
+ */
2362
2700
  sourcemapDebugIds?: boolean;
2363
2701
  /**
2364
2702
  * Control which source files are included in the sourcemap ignore list.
2703
+ *
2365
2704
  * Files in the ignore list are excluded from debugger stepping and error stack traces.
2366
2705
  *
2367
- * - `false`: Include all source files in the ignore list
2368
- * - `true`: Include no source files in the ignore list
2706
+ * - `false`: Include no source files in the ignore list
2707
+ * - `true`: Include all source files in the ignore list
2369
2708
  * - `string`: Files containing this string in their path will be included in the ignore list
2370
2709
  * - `RegExp`: Files matching this regular expression will be included in the ignore list
2371
- * - `function`: Custom function `(source: string, sourcemapPath: string) => boolean` to determine if a source should be ignored
2710
+ * - `function`: Custom function to determine if a source should be ignored
2372
2711
  *
2373
2712
  * :::tip Performance
2374
2713
  * Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
2375
2714
  * Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
2376
2715
  * :::
2377
2716
  *
2378
- * ## Examples
2717
+ * @example
2379
2718
  * ```js
2380
2719
  * // ✅ Preferred: Use RegExp for better performance
2381
2720
  * sourcemapIgnoreList: /node_modules/
@@ -2389,66 +2728,247 @@ interface OutputOptions {
2389
2728
  * }
2390
2729
  * ```
2391
2730
  *
2392
- * **default**: /node_modules/
2731
+ * @default /node_modules/
2393
2732
  */
2394
2733
  sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | StringOrRegExp;
2734
+ /**
2735
+ * A transformation to apply to each path in a sourcemap.
2736
+ *
2737
+ * @example
2738
+ * ```js
2739
+ * export default defineConfig({
2740
+ * output: {
2741
+ * sourcemap: true,
2742
+ * sourcemapPathTransform: (source, sourcemapPath) => {
2743
+ * // Remove 'src/' prefix from all source paths
2744
+ * return source.replace(/^src\//, '');
2745
+ * },
2746
+ * },
2747
+ * });
2748
+ * ```
2749
+ */
2395
2750
  sourcemapPathTransform?: SourcemapPathTransformOption;
2751
+ /**
2752
+ * Whether to exclude the original source code from sourcemaps.
2753
+ *
2754
+ * When `true`, the `sourcesContent` field is omitted from the generated sourcemap,
2755
+ * reducing the sourcemap file size. The sourcemap will still contain source file paths
2756
+ * and mappings, so debugging works if the original files are available.
2757
+ *
2758
+ * @default false
2759
+ */
2760
+ sourcemapExcludeSources?: boolean;
2761
+ /**
2762
+ * A string to prepend to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
2763
+ *
2764
+ * See {@linkcode intro | output.intro}, {@linkcode postBanner | output.postBanner} as well.
2765
+ *
2766
+ *
2767
+ */
2396
2768
  banner?: string | AddonFunction;
2769
+ /**
2770
+ * A string to append to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
2771
+ *
2772
+ * See {@linkcode outro | output.outro}, {@linkcode postFooter | output.postFooter} as well.
2773
+ *
2774
+ *
2775
+ */
2397
2776
  footer?: string | AddonFunction;
2398
2777
  /**
2399
- * Similar to `banner` option, but will run after the `renderChunk` hook and builtin minification.
2778
+ * A string to prepend to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
2779
+ *
2780
+ * See {@linkcode banner | output.banner}, {@linkcode intro | output.intro} as well.
2781
+ *
2782
+ *
2400
2783
  */
2401
2784
  postBanner?: string | AddonFunction;
2402
2785
  /**
2403
- * Similar to `footer` option, but will run after the `renderChunk` hook and builtin minification.
2786
+ * A string to append to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
2787
+ *
2788
+ * See {@linkcode footer | output.footer}, {@linkcode outro | output.outro} as well.
2789
+ *
2790
+ *
2404
2791
  */
2405
2792
  postFooter?: string | AddonFunction;
2793
+ /**
2794
+ * A string to prepend inside any {@link OutputOptions.format | format}-specific wrapper.
2795
+ *
2796
+ * See {@linkcode banner | output.banner}, {@linkcode postBanner | output.postBanner} as well.
2797
+ *
2798
+ *
2799
+ */
2406
2800
  intro?: string | AddonFunction;
2801
+ /**
2802
+ * A string to append inside any {@link OutputOptions.format | format}-specific wrapper.
2803
+ *
2804
+ * See {@linkcode footer | output.footer}, {@linkcode postFooter | output.postFooter} as well.
2805
+ *
2806
+ *
2807
+ */
2407
2808
  outro?: string | AddonFunction;
2408
- extend?: boolean;
2409
- esModule?: boolean | "if-default-prop";
2410
- assetFileNames?: string | AssetFileNamesFunction;
2411
- entryFileNames?: string | ChunkFileNamesFunction;
2412
- chunkFileNames?: string | ChunkFileNamesFunction;
2413
- cssEntryFileNames?: string | ChunkFileNamesFunction;
2414
- cssChunkFileNames?: string | ChunkFileNamesFunction;
2415
- sanitizeFileName?: boolean | SanitizeFileNameFunction;
2416
2809
  /**
2417
- * Control code minification.
2810
+ * Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` {@link OutputOptions.format | formats}.
2418
2811
  *
2419
- * - `true`: Enable full minification including code compression and dead code elimination
2420
- * - `false`: Disable minification (default)
2421
- * - `'dce-only'`: Only perform dead code elimination without code compression
2422
- * - `MinifyOptions`: Fine-grained control over minification settings
2812
+ * When `true`, the global variable will be defined as `global.name = global.name || {}`.
2813
+ * When `false`, the global defined by name will be overwritten like `global.name = {}`.
2423
2814
  *
2424
2815
  * @default false
2425
2816
  */
2426
- minify?: boolean | "dce-only" | MinifyOptions;
2427
- name?: string;
2428
- globals?: Record<string, string> | GlobalsFunction;
2817
+ extend?: boolean;
2429
2818
  /**
2430
- * Maps external module IDs to paths.
2819
+ * Whether to add a `__esModule: true` property when generating exports for non-ES {@link OutputOptions.format | formats}.
2431
2820
  *
2432
- * Allows customizing the path used when importing external dependencies.
2433
- * This is particularly useful for loading dependencies from CDNs or custom locations.
2821
+ * 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.
2434
2822
  *
2435
- * - Object form: Maps module IDs to their replacement paths
2436
- * - Function form: Takes a module ID and returns its replacement path
2823
+ * - `true`: Always add the property when using {@link OutputOptions.exports | named exports mode}, which is similar to what other tools do.
2824
+ * - `"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`.
2825
+ * - `false`: Never add the property even if the default export would become a property `.default`.
2437
2826
  *
2438
- * @example
2439
- * ```js
2440
- * {
2441
- * paths: {
2442
- * 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
2443
- * }
2444
- * }
2445
- * ```
2827
+ * @default 'if-default-prop'
2446
2828
  *
2447
- * @example
2448
- * ```js
2449
- * {
2450
- * paths: (id) => {
2451
- * if (id.startsWith('lodash')) {
2829
+ *
2830
+ */
2831
+ esModule?: boolean | "if-default-prop";
2832
+ /**
2833
+ * 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.
2834
+ *
2835
+ * Patterns support the following placeholders:
2836
+ * - `[extname]`: The file extension of the asset including a leading dot, e.g. `.css`.
2837
+ * - `[ext]`: The file extension without a leading dot, e.g. css.
2838
+ * - `[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}.
2839
+ * - `[name]`: The file name of the asset excluding any extension.
2840
+ *
2841
+ * Forward slashes (`/`) can be used to place files in sub-directories.
2842
+ *
2843
+ * See also {@linkcode chunkFileNames | output.chunkFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
2844
+ *
2845
+ * @default 'assets/[name]-[hash][extname]'
2846
+ */
2847
+ assetFileNames?: string | AssetFileNamesFunction;
2848
+ /**
2849
+ * 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.
2850
+ *
2851
+ * Patterns support the following placeholders:
2852
+ * - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
2853
+ * - `[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}.
2854
+ * - `[name]`: The file name (without extension) of the entry point, unless the object form of input was used to define a different name.
2855
+ *
2856
+ * 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.
2857
+ *
2858
+ * See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
2859
+ *
2860
+ * @default '[name].js'
2861
+ */
2862
+ entryFileNames?: string | ChunkFileNamesFunction;
2863
+ /**
2864
+ * 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.
2865
+ *
2866
+ * Patterns support the following placeholders:
2867
+ * - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
2868
+ * - `[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}.
2869
+ * - `[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.
2870
+ *
2871
+ * Forward slashes (`/`) can be used to place files in sub-directories.
2872
+ *
2873
+ * See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
2874
+ *
2875
+ * @default '[name]-[hash].js'
2876
+ */
2877
+ chunkFileNames?: string | ChunkFileNamesFunction;
2878
+ /**
2879
+ * Whether to enable chunk name sanitization (removal of non-URL-safe characters like `\0`, `?` and `*`).
2880
+ *
2881
+ * Set `false` to disable the sanitization. You can also provide a custom sanitization function.
2882
+ *
2883
+ * @default true
2884
+ */
2885
+ sanitizeFileName?: boolean | SanitizeFileNameFunction;
2886
+ /**
2887
+ * Control code minification
2888
+ *
2889
+ * Rolldown uses Oxc Minifier under the hood. See Oxc's [minification documentation](https://oxc.rs/docs/guide/usage/minifier#features) for more details.
2890
+ *
2891
+ * - `true`: Enable full minification including code compression and dead code elimination
2892
+ * - `false`: Disable minification
2893
+ * - `'dce-only'`: Only perform dead code elimination without code compression (default)
2894
+ * - `MinifyOptions`: Fine-grained control over minification settings
2895
+ *
2896
+ * @default 'dce-only'
2897
+ */
2898
+ minify?: boolean | "dce-only" | MinifyOptions;
2899
+ /**
2900
+ * Specifies the global variable name that contains the exports of `umd` / `iife` {@link OutputOptions.format | formats}.
2901
+ *
2902
+ * @example
2903
+ * ```js
2904
+ * export default defineConfig({
2905
+ * output: {
2906
+ * format: 'iife',
2907
+ * name: 'MyBundle',
2908
+ * }
2909
+ * });
2910
+ * ```
2911
+ * ```js
2912
+ * // output
2913
+ * var MyBundle = (function () {
2914
+ * // ...
2915
+ * })();
2916
+ * ```
2917
+ *
2918
+ *
2919
+ */
2920
+ name?: string;
2921
+ /**
2922
+ * Specifies `id: variableName` pairs necessary for {@link InputOptions.external | external} imports in `umd` / `iife` {@link OutputOptions.format | formats}.
2923
+ *
2924
+ * @example
2925
+ * ```js
2926
+ * export default defineConfig({
2927
+ * external: ['jquery'],
2928
+ * output: {
2929
+ * format: 'iife',
2930
+ * name: 'MyBundle',
2931
+ * globals: {
2932
+ * jquery: '$',
2933
+ * }
2934
+ * }
2935
+ * });
2936
+ * ```
2937
+ * ```js
2938
+ * // input
2939
+ * import $ from 'jquery';
2940
+ * ```
2941
+ * ```js
2942
+ * // output
2943
+ * var MyBundle = (function ($) {
2944
+ * // ...
2945
+ * })($);
2946
+ * ```
2947
+ */
2948
+ globals?: Record<string, string> | GlobalsFunction;
2949
+ /**
2950
+ * Maps {@link InputOptions.external | external} module IDs to paths.
2951
+ *
2952
+ * Allows customizing the path used when importing external dependencies.
2953
+ * This is particularly useful for loading dependencies from CDNs or custom locations.
2954
+ *
2955
+ * - Object form: Maps module IDs to their replacement paths
2956
+ * - Function form: Takes a module ID and returns its replacement path
2957
+ *
2958
+ * @example
2959
+ * ```js
2960
+ * {
2961
+ * paths: {
2962
+ * 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
2963
+ * }
2964
+ * }
2965
+ * ```
2966
+ *
2967
+ * @example
2968
+ * ```js
2969
+ * {
2970
+ * paths: (id) => {
2971
+ * if (id.startsWith('lodash')) {
2452
2972
  * return `https://cdn.jsdelivr.net/npm/${id}`
2453
2973
  * }
2454
2974
  * return id
@@ -2457,17 +2977,45 @@ interface OutputOptions {
2457
2977
  * ```
2458
2978
  */
2459
2979
  paths?: Record<string, string> | PathsFunction$1;
2980
+ /**
2981
+ * Which language features Rolldown can safely use in generated code.
2982
+ *
2983
+ * This will not transpile any user code but only change the code Rolldown uses in wrappers and helpers.
2984
+ */
2460
2985
  generatedCode?: Partial<GeneratedCodeOptions>;
2986
+ /**
2987
+ * Whether to generate code to support live bindings for {@link InputOptions.external | external} imports.
2988
+ *
2989
+ * With the default value of `true`, Rolldown will generate code to support live bindings for external imports.
2990
+ *
2991
+ * 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.
2992
+ *
2993
+ * @default true
2994
+ *
2995
+ *
2996
+ */
2461
2997
  externalLiveBindings?: boolean;
2998
+ /**
2999
+ * @deprecated Please use `codeSplitting: false` instead.
3000
+ *
3001
+ * Whether to inline dynamic imports instead of creating new chunks to create a single bundle.
3002
+ *
3003
+ * This option can be used only when a single input is provided.
3004
+ *
3005
+ * @default false
3006
+ */
2462
3007
  inlineDynamicImports?: boolean;
2463
3008
  /**
2464
- * - Type: `((moduleId: string, meta: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue)`
2465
- * - Object form is not supported.
3009
+ * Whether to keep external dynamic imports as `import(...)` expressions in CommonJS output.
2466
3010
  *
2467
- * :::warning
2468
- * - This option is deprecated. Please use `advancedChunks` instead.
2469
- * - If `manualChunks` and `advancedChunks` are both specified, `manualChunks` option will be ignored.
2470
- * :::
3011
+ * If set to `false`, external dynamic imports will be rewritten to use `require(...)` calls.
3012
+ * This may be necessary to support environments that do not support dynamic `import()` in CommonJS modules like old Node.js versions.
3013
+ *
3014
+ * @default true
3015
+ */
3016
+ dynamicImportInCjs?: boolean;
3017
+ /**
3018
+ * Allows you to do manual chunking. Provided for Rollup compatibility.
2471
3019
  *
2472
3020
  * You could use this option for migration purpose. Under the hood,
2473
3021
  *
@@ -2486,7 +3034,7 @@ interface OutputOptions {
2486
3034
  *
2487
3035
  * ```js
2488
3036
  * {
2489
- * advancedChunks: {
3037
+ * codeSplitting: {
2490
3038
  * groups: [
2491
3039
  * {
2492
3040
  * name(moduleId) {
@@ -2502,297 +3050,797 @@ interface OutputOptions {
2502
3050
  *
2503
3051
  * ```
2504
3052
  *
2505
- * @deprecated Please use `advancedChunks` instead.
3053
+ * Note that unlike Rollup, object form is not supported.
3054
+ *
3055
+ * @deprecated
3056
+ * Please use {@linkcode codeSplitting | output.codeSplitting} instead.
3057
+ *
3058
+ * :::warning
3059
+ * If `manualChunks` and `codeSplitting` are both specified, `manualChunks` option will be ignored.
3060
+ * :::
2506
3061
  */
2507
3062
  manualChunks?: ManualChunksFunction;
2508
3063
  /**
2509
- * Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/advanced-chunks).
3064
+ * Controls how code splitting is performed.
3065
+ *
3066
+ * - `true`: Default behavior, automatic code splitting. **(default)**
3067
+ * - `false`: Inline all dynamic imports into a single bundle (equivalent to deprecated `inlineDynamicImports: true`).
3068
+ * - `object`: Advanced manual code splitting configuration.
3069
+ *
3070
+ * For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/manual-code-splitting).
3071
+ *
3072
+ *
3073
+ *
3074
+ * @example
3075
+ * **Basic vendor chunk**
3076
+ * ```js
3077
+ * export default defineConfig({
3078
+ * output: {
3079
+ * codeSplitting: {
3080
+ * minSize: 20000,
3081
+ * groups: [
3082
+ * {
3083
+ * name: 'vendor',
3084
+ * test: /node_modules/,
3085
+ * },
3086
+ * ],
3087
+ * },
3088
+ * },
3089
+ * });
3090
+ * ```
3091
+ *
3092
+ *
3093
+ * @default true
3094
+ */
3095
+ codeSplitting?: boolean | CodeSplittingOptions;
3096
+ /**
3097
+ * @deprecated Please use {@linkcode codeSplitting | output.codeSplitting} instead.
3098
+ *
3099
+ * Allows you to do manual chunking.
3100
+ *
3101
+ * :::warning
3102
+ * If `advancedChunks` and `codeSplitting` are both specified, `advancedChunks` option will be ignored.
3103
+ * :::
2510
3104
  */
2511
3105
  advancedChunks?: {
2512
- /**
2513
- * - Type: `boolean`
2514
- * - Default: `true`
2515
- *
2516
- * By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
2517
- *
2518
- * If you want to disable this behavior, it's recommended to both set
2519
- * - `preserveEntrySignatures: false | 'allow-extension'`
2520
- * - `strictExecutionOrder: true`
2521
- *
2522
- * to avoid generating invalid chunks.
2523
- */
2524
3106
  includeDependenciesRecursively?: boolean;
2525
- /**
2526
- * - Type: `number`
2527
- *
2528
- * Global fallback of [`{group}.minSize`](#advancedchunks-groups-minsize), if it's not specified in the group.
2529
- */
2530
3107
  minSize?: number;
2531
- /**
2532
- * - Type: `number`
2533
- *
2534
- * Global fallback of [`{group}.maxSize`](#advancedchunks-groups-maxsize), if it's not specified in the group.
2535
- */
2536
3108
  maxSize?: number;
2537
- /**
2538
- * - Type: `number`
2539
- *
2540
- * Global fallback of [`{group}.maxModuleSize`](#advancedchunks-groups-maxmodulesize), if it's not specified in the group.
2541
- */
2542
3109
  maxModuleSize?: number;
2543
- /**
2544
- * - Type: `number`
2545
- *
2546
- * Global fallback of [`{group}.minModuleSize`](#advancedchunks-groups-minmodulesize), if it's not specified in the group.
2547
- */
2548
3110
  minModuleSize?: number;
2549
- /**
2550
- * - Type: `number`
2551
- *
2552
- * Global fallback of [`{group}.minShareCount`](#advancedchunks-groups-minsharecount), if it's not specified in the group.
2553
- */
2554
3111
  minShareCount?: number;
2555
- /**
2556
- * Groups to be used for advanced chunking.
2557
- */
2558
- groups?: {
2559
- /**
2560
- * - Type: `string | ((moduleId: string, ctx: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue)`
2561
- *
2562
- * Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
2563
- *
2564
- * For example,
2565
- *
2566
- * ```js
2567
- * import { defineConfig } from 'rolldown';
2568
- *
2569
- * export default defineConfig({
2570
- * advancedChunks: {
2571
- * groups: [
2572
- * {
2573
- * name: 'libs',
2574
- * test: /node_modules/,
2575
- * },
2576
- * ],
2577
- * },
2578
- * });
2579
- * ```
2580
- * will create a chunk named `libs-[hash].js` in the end.
2581
- *
2582
- * It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
2583
- *
2584
- * # Dynamic `name()`
2585
- *
2586
- * 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.
2587
- *
2588
- * Notice, each returned new name will be treated as a separate group.
2589
- *
2590
- * For example,
2591
- *
2592
- * ```js
2593
- * import { defineConfig } from 'rolldown';
2594
- *
2595
- * export default defineConfig({
2596
- * advancedChunks: {
2597
- * groups: [
2598
- * {
2599
- * name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
2600
- * minSize: 100 * 1024,
2601
- * },
2602
- * ],
2603
- * },
2604
- * });
2605
- * ```
2606
- *
2607
- * :::warning
2608
- * Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
2609
- * :::
2610
- */
2611
- name: string | AdvancedChunksNameFunction;
2612
- /**
2613
- * - Type: `string | RegExp | ((id: string) => boolean | undefined | void);`
2614
- *
2615
- * Controls which modules are captured in this group.
2616
- *
2617
- * - If `test` is a string, the module whose id contains the string will be captured.
2618
- * - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
2619
- * - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
2620
- * - If `test` is empty, any module will be considered as matched.
2621
- *
2622
- * :::warning
2623
- * When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
2624
- * - ✅ Recommended: `/node_modules[\\/]react/`
2625
- * - ❌ Not recommended: `/node_modules/react/`
2626
- * :::
2627
- */
2628
- test?: StringOrRegExp | AdvancedChunksTestFunction;
2629
- /**
2630
- * - Type: `number`
2631
- * - Default: `0`
2632
- *
2633
- * 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.
2634
- *
2635
- * If two groups have the same priority, the group whose index is smaller will be chosen.
2636
- *
2637
- * For example,
2638
- *
2639
- * ```js
2640
- * import { defineConfig } from 'rolldown';
2641
- *
2642
- * export default defineConfig({
2643
- * advancedChunks: {
2644
- * groups: [
2645
- * {
2646
- * name: 'react',
2647
- * test: /node_modules[\\/]react/,
2648
- * priority: 1,
2649
- * },
2650
- * {
2651
- * name: 'other-libs',
2652
- * test: /node_modules/,
2653
- * priority: 2,
2654
- * },
2655
- * ],
2656
- * });
2657
- * ```
2658
- *
2659
- * This is a clearly __incorrect__ example. Though `react` group is defined before `other-libs`, it has a lower priority, so the modules in `react` group will be captured in `other-libs` group.
2660
- */
2661
- priority?: number;
2662
- /**
2663
- * - Type: `number`
2664
- * - Default: `0`
2665
- *
2666
- * 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.
2667
- */
2668
- minSize?: number;
2669
- /**
2670
- * - Type: `number`
2671
- * - Default: `1`
2672
- *
2673
- * Controls if a module should be captured based on how many entry chunks reference it.
2674
- */
2675
- minShareCount?: number;
2676
- /**
2677
- * - Type: `number`
2678
- * - Default: `Infinity`
2679
- *
2680
- * 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.
2681
- */
2682
- maxSize?: number;
2683
- /**
2684
- * - Type: `number`
2685
- * - Default: `Infinity`
2686
- *
2687
- * Controls a module could only be captured if its size in bytes is smaller or equal than this value.
2688
- */
2689
- maxModuleSize?: number;
2690
- /**
2691
- * - Type: `number`
2692
- * - Default: `0`
2693
- *
2694
- * Controls a module could only be captured if its size in bytes is larger or equal than this value.
2695
- */
2696
- minModuleSize?: number;
2697
- }[];
3112
+ groups?: CodeSplittingGroup[];
2698
3113
  };
2699
3114
  /**
2700
- * Control comments in the output.
3115
+ * Controls how legal comments are preserved in the output.
2701
3116
  *
2702
- * - `none`: no comments
2703
- * - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
3117
+ * - `none`: no legal comments
3118
+ * - `inline`: preserve legal comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
3119
+ *
3120
+ * @deprecated Use `comments.legal` instead. When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
2704
3121
  */
2705
3122
  legalComments?: "none" | "inline";
3123
+ /**
3124
+ * Control which comments are preserved in the output.
3125
+ *
3126
+ * - `true`: Preserve legal, annotation, and JSDoc comments (default)
3127
+ * - `false`: Strip all comments
3128
+ * - Object: Granular control over comment categories
3129
+ *
3130
+ * Note: Regular line and block comments without these markers
3131
+ * are always removed regardless of this option.
3132
+ *
3133
+ * When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
3134
+ *
3135
+ *
3136
+ *
3137
+ * @default true
3138
+ */
3139
+ comments?: boolean | CommentsOptions;
3140
+ /**
3141
+ * The list of plugins to use only for this output.
3142
+ *
3143
+ * @see {@linkcode InputOptions.plugins | plugins}
3144
+ */
2706
3145
  plugins?: RolldownOutputPluginOption;
3146
+ /**
3147
+ * Whether to add a polyfill for `require()` function in non-CommonJS formats.
3148
+ *
3149
+ * This option is useful when you want to inject your own `require` implementation.
3150
+ *
3151
+ * @default true
3152
+ */
2707
3153
  polyfillRequire?: boolean;
3154
+ /**
3155
+ * This option is not implemented yet.
3156
+ * @hidden
3157
+ */
2708
3158
  hoistTransitiveImports?: false;
3159
+ /**
3160
+ * Whether to use preserve modules mode.
3161
+ *
3162
+ *
3163
+ *
3164
+ * @default false
3165
+ */
2709
3166
  preserveModules?: boolean;
3167
+ /**
3168
+ * Specifies the directory name for "virtual" files that might be emitted by plugins when using {@link OutputOptions.preserveModules | preserve modules mode}.
3169
+ *
3170
+ * @default '_virtual'
3171
+ */
2710
3172
  virtualDirname?: string;
3173
+ /**
3174
+ * A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using {@link OutputOptions.preserveModules | preserve modules mode}.
3175
+ *
3176
+ *
3177
+ */
2711
3178
  preserveModulesRoot?: string;
3179
+ /**
3180
+ * Whether to use `var` declarations at the top level scope instead of function / class / let / const expressions.
3181
+ *
3182
+ * Enabling this option can improve runtime performance of the generated code in certain environments.
3183
+ *
3184
+ * @default false
3185
+ *
3186
+ *
3187
+ */
2712
3188
  topLevelVar?: boolean;
2713
3189
  /**
2714
- * - Type: `boolean`
2715
- * - Default: `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
3190
+ * Whether to minify internal exports as single letter variables to allow for better minification.
3191
+ *
3192
+ * @default
3193
+ * `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
3194
+ *
3195
+ *
3196
+ */
3197
+ minifyInternalExports?: boolean;
3198
+ /**
3199
+ * Clean output directory ({@linkcode dir | output.dir}) before emitting output.
3200
+ *
3201
+ * @default false
3202
+ *
3203
+ *
3204
+ */
3205
+ cleanDir?: boolean;
3206
+ /**
3207
+ * Keep `name` property of functions and classes after bundling.
3208
+ *
3209
+ * When enabled, the bundler will preserve the original `name` property value of functions and
3210
+ * classes in the output. This is useful for debugging and some frameworks that rely on it for
3211
+ * registration and binding purposes.
3212
+ *
3213
+ *
3214
+ *
3215
+ * @default false
3216
+ */
3217
+ keepNames?: boolean;
3218
+ /**
3219
+ * Lets modules be executed in the order they are declared.
3220
+ *
3221
+ * This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
3222
+ *
3223
+ * > [!WARNING]
3224
+ * > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
3225
+ * @default false
3226
+ */
3227
+ strictExecutionOrder?: boolean;
3228
+ /**
3229
+ * Whether to always output `"use strict"` directive in non-ES module outputs.
3230
+ *
3231
+ * - `true` - Always emit `"use strict"` at the top of the output (not applicable for ESM format since ESM is always strict).
3232
+ * - `false` - Never emit `"use strict"` in the output.
3233
+ * - `'auto'` - Respect the `"use strict"` directives from the source code.
3234
+ *
3235
+ * See [In-depth directive guide](https://rolldown.rs/in-depth/directives) for more details.
3236
+ *
3237
+ * @default 'auto'
3238
+ */
3239
+ strict?: boolean | "auto";
3240
+ }
3241
+ type CodeSplittingGroup = {
3242
+ /**
3243
+ * 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.
3244
+ *
3245
+ * For example,
3246
+ *
3247
+ * ```js
3248
+ * import { defineConfig } from 'rolldown';
3249
+ *
3250
+ * export default defineConfig({
3251
+ * output: {
3252
+ * codeSplitting: {
3253
+ * groups: [
3254
+ * {
3255
+ * name: 'libs',
3256
+ * test: /node_modules/,
3257
+ * },
3258
+ * ],
3259
+ * },
3260
+ * },
3261
+ * });
3262
+ * ```
3263
+ * will create a chunk named `libs-[hash].js` in the end.
3264
+ *
3265
+ * It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
3266
+ *
3267
+ * #### Dynamic `name()`
3268
+ *
3269
+ * 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.
2716
3270
  *
2717
- * Whether to minify internal exports.
3271
+ * Notice, each returned new name will be treated as a separate group.
3272
+ *
3273
+ * For example,
3274
+ *
3275
+ * ```js
3276
+ * import { defineConfig } from 'rolldown';
3277
+ *
3278
+ * export default defineConfig({
3279
+ * output: {
3280
+ * codeSplitting: {
3281
+ * groups: [
3282
+ * {
3283
+ * name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
3284
+ * minSize: 100 * 1024,
3285
+ * },
3286
+ * ],
3287
+ * },
3288
+ * },
3289
+ * });
3290
+ * ```
3291
+ *
3292
+ * :::warning
3293
+ * Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
3294
+ * :::
3295
+ */
3296
+ name: string | CodeSplittingNameFunction;
3297
+ /**
3298
+ * Controls which modules are captured in this group.
3299
+ *
3300
+ * - If `test` is a string, the module whose id contains the string will be captured.
3301
+ * - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
3302
+ * - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
3303
+ * - If `test` is empty, any module will be considered as matched.
3304
+ *
3305
+ * :::warning
3306
+ * When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
3307
+ * - ✅ Recommended: `/node_modules[\\/]react/`
3308
+ * - ❌ Not recommended: `/node_modules/react/`
3309
+ * :::
3310
+ */
3311
+ test?: StringOrRegExp | CodeSplittingTestFunction;
3312
+ /**
3313
+ * 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.
3314
+ *
3315
+ * If two groups have the same priority, the group whose index is smaller will be chosen.
3316
+ *
3317
+ * @example
3318
+ * ```js
3319
+ * import { defineConfig } from 'rolldown';
3320
+ *
3321
+ * export default defineConfig({
3322
+ * output: {
3323
+ * codeSplitting: {
3324
+ * groups: [
3325
+ * {
3326
+ * name: 'react',
3327
+ * test: /node_modules[\\/]react/,
3328
+ * priority: 2,
3329
+ * },
3330
+ * {
3331
+ * name: 'other-libs',
3332
+ * test: /node_modules/,
3333
+ * priority: 1,
3334
+ * },
3335
+ * ],
3336
+ * },
3337
+ * },
3338
+ * });
3339
+ * ```
3340
+ *
3341
+ * @default 0
3342
+ */
3343
+ priority?: number;
3344
+ /**
3345
+ * 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.
3346
+ *
3347
+ * @default 0
3348
+ */
3349
+ minSize?: number;
3350
+ /**
3351
+ * Controls if a module should be captured based on how many entry chunks reference it.
3352
+ *
3353
+ * @default 1
3354
+ */
3355
+ minShareCount?: number;
3356
+ /**
3357
+ * 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.
3358
+ *
3359
+ * @default Infinity
3360
+ */
3361
+ maxSize?: number;
3362
+ /**
3363
+ * Controls whether a module can only be captured if its size in bytes is smaller than or equal to this value.
3364
+ *
3365
+ * @default Infinity
3366
+ */
3367
+ maxModuleSize?: number;
3368
+ /**
3369
+ * Controls whether a module can only be captured if its size in bytes is larger than or equal to this value.
3370
+ *
3371
+ * @default 0
3372
+ */
3373
+ minModuleSize?: number;
3374
+ /**
3375
+ * When `false` (default), all matching modules are merged into a single chunk.
3376
+ * Every entry that uses any of these modules must load the entire chunk — even
3377
+ * modules it doesn't need.
3378
+ *
3379
+ * When `true`, matching modules are grouped by which entries actually import them.
3380
+ * Modules shared by the same set of entries go into the same chunk, while modules
3381
+ * shared by a different set go into a separate chunk. This way, each entry only
3382
+ * loads the code it actually uses.
3383
+ *
3384
+ * Example: entries A, B, C all match a `"vendor"` group.
3385
+ * - `moduleX` is used by A, B, C
3386
+ * - `moduleY` is used by A, B only
3387
+ *
3388
+ * With `entriesAware: false` → one `vendor.js` chunk with both modules; C loads `moduleY` unnecessarily.
3389
+ * With `entriesAware: true` → `vendor.js` (moduleX, loaded by all) + `vendor2.js` (moduleY, loaded by A and B only).
3390
+ *
3391
+ * @default false
3392
+ */
3393
+ entriesAware?: boolean;
3394
+ /**
3395
+ * Size threshold in bytes for merging small `entriesAware` subgroups into the
3396
+ * closest neighboring subgroup.
3397
+ *
3398
+ * This option only works when {@linkcode CodeSplittingGroup.entriesAware | entriesAware}
3399
+ * is `true`. Set to `0` to disable subgroup merging.
3400
+ *
3401
+ * @default 0
3402
+ */
3403
+ entriesAwareMergeThreshold?: number;
3404
+ };
3405
+ /**
3406
+ * Alias for {@linkcode CodeSplittingGroup}. Use this type for the `codeSplitting.groups` option.
3407
+ *
3408
+ * @deprecated Please use {@linkcode CodeSplittingGroup} instead.
3409
+ */
3410
+ /**
3411
+ * Configuration options for advanced code splitting.
3412
+ */
3413
+ type CodeSplittingOptions = {
3414
+ /**
3415
+ * By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
3416
+ *
3417
+ * If you want to disable this behavior, it's recommended to both set
3418
+ * - {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures}: `false | 'allow-extension'`
3419
+ * - {@linkcode OutputOptions.strictExecutionOrder | strictExecutionOrder}: `true`
3420
+ *
3421
+ * to avoid generating invalid chunks.
3422
+ *
3423
+ * @default true
3424
+ */
3425
+ includeDependenciesRecursively?: boolean;
3426
+ /**
3427
+ * Global fallback of {@linkcode CodeSplittingGroup.minSize | group.minSize}, if it's not specified in the group.
3428
+ */
3429
+ minSize?: number;
3430
+ /**
3431
+ * Global fallback of {@linkcode CodeSplittingGroup.maxSize | group.maxSize}, if it's not specified in the group.
3432
+ */
3433
+ maxSize?: number;
3434
+ /**
3435
+ * Global fallback of {@linkcode CodeSplittingGroup.maxModuleSize | group.maxModuleSize}, if it's not specified in the group.
3436
+ */
3437
+ maxModuleSize?: number;
3438
+ /**
3439
+ * Global fallback of {@linkcode CodeSplittingGroup.minModuleSize | group.minModuleSize}, if it's not specified in the group.
3440
+ */
3441
+ minModuleSize?: number;
3442
+ /**
3443
+ * Global fallback of {@linkcode CodeSplittingGroup.minShareCount | group.minShareCount}, if it's not specified in the group.
3444
+ */
3445
+ minShareCount?: number;
3446
+ /**
3447
+ * Groups to be used for code splitting.
3448
+ */
3449
+ groups?: CodeSplittingGroup[];
3450
+ };
3451
+ /**
3452
+ * Alias for {@linkcode CodeSplittingOptions}. Use this type for the `codeSplitting` option.
3453
+ *
3454
+ * @deprecated Please use {@linkcode CodeSplittingOptions} instead.
3455
+ */
3456
+ //#endregion
3457
+ //#region src/binding-magic-string.d.ts
3458
+ interface RolldownMagicString extends BindingMagicString {
3459
+ readonly isRolldownMagicString: true;
3460
+ /** Accepts a string or RegExp pattern. RegExp supports `$&`, `$$`, and `$N` substitutions. */
3461
+ replace(from: string | RegExp, to: string): this;
3462
+ /** Accepts a string or RegExp pattern. RegExp must have the global (`g`) flag. */
3463
+ replaceAll(from: string | RegExp, to: string): this;
3464
+ }
3465
+ type RolldownMagicStringConstructor = Omit<typeof BindingMagicString, "prototype"> & {
3466
+ new (...args: ConstructorParameters<typeof BindingMagicString>): RolldownMagicString;
3467
+ prototype: RolldownMagicString;
3468
+ };
3469
+ /**
3470
+ * A native MagicString implementation powered by Rust.
3471
+ *
3472
+ * @experimental
3473
+ */
3474
+ declare const RolldownMagicString: RolldownMagicStringConstructor; //#endregion
3475
+ //#region src/log/log-handler.d.ts
3476
+ type LoggingFunction = (log: RolldownLog | string | (() => RolldownLog | string)) => void;
3477
+ type LoggingFunctionWithPosition = (log: RolldownLog | string | (() => RolldownLog | string), pos?: number | {
3478
+ column: number;
3479
+ line: number;
3480
+ }) => void;
3481
+ //#endregion
3482
+ //#region src/options/generated/checks-options.d.ts
3483
+ interface ChecksOptions {
3484
+ /**
3485
+ * Whether to emit warnings when detecting circular dependency.
3486
+ *
3487
+ * Circular dependencies lead to a bigger bundle size and sometimes cause execution order issues and are better to avoid.
3488
+ *
3489
+ *
3490
+ * @default false
3491
+ * */
3492
+ circularDependency?: boolean;
3493
+ /**
3494
+ * Whether to emit warnings when detecting uses of direct `eval`s.
3495
+ *
3496
+ * See [Avoiding Direct `eval` in Troubleshooting page](https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval) for more details.
3497
+ * @default true
3498
+ * */
3499
+ eval?: boolean;
3500
+ /**
3501
+ * Whether to emit warnings when the `output.globals` option is missing when needed.
3502
+ *
3503
+ * See [`output.globals`](https://rolldown.rs/reference/OutputOptions.globals).
3504
+ * @default true
3505
+ * */
3506
+ missingGlobalName?: boolean;
3507
+ /**
3508
+ * Whether to emit warnings when the `output.name` option is missing when needed.
3509
+ *
3510
+ * See [`output.name`](https://rolldown.rs/reference/OutputOptions.name).
3511
+ * @default true
3512
+ * */
3513
+ missingNameOptionForIifeExport?: boolean;
3514
+ /**
3515
+ * Whether to emit warnings when the way to export values is ambiguous.
3516
+ *
3517
+ * See [`output.exports`](https://rolldown.rs/reference/OutputOptions.exports).
3518
+ * @default true
3519
+ * */
3520
+ mixedExports?: boolean;
3521
+ /**
3522
+ * Whether to emit warnings when an entrypoint cannot be resolved.
3523
+ * @default true
3524
+ * */
3525
+ unresolvedEntry?: boolean;
3526
+ /**
3527
+ * Whether to emit warnings when an import cannot be resolved.
3528
+ * @default true
3529
+ * */
3530
+ unresolvedImport?: boolean;
3531
+ /**
3532
+ * Whether to emit warnings when files generated have the same name with different contents.
3533
+ *
3534
+ *
3535
+ * @default true
3536
+ * */
3537
+ filenameConflict?: boolean;
3538
+ /**
3539
+ * Whether to emit warnings when a CommonJS variable is used in an ES module.
3540
+ *
3541
+ * CommonJS variables like `module` and `exports` are treated as global variables in ES modules and may not work as expected.
3542
+ *
3543
+ *
3544
+ * @default true
3545
+ * */
3546
+ commonJsVariableInEsm?: boolean;
3547
+ /**
3548
+ * Whether to emit warnings when an imported variable is not exported.
3549
+ *
3550
+ * 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.
3551
+ *
3552
+ *
3553
+ * @default true
3554
+ * */
3555
+ importIsUndefined?: boolean;
3556
+ /**
3557
+ * Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`).
3558
+ *
3559
+ * See [`import.meta` in Non-ESM Output Formats page](https://rolldown.rs/in-depth/non-esm-output-formats#import-meta) for more details.
3560
+ * @default true
3561
+ * */
3562
+ emptyImportMeta?: boolean;
3563
+ /**
3564
+ * Whether to emit warnings when detecting tolerated transform.
3565
+ * @default true
3566
+ * */
3567
+ toleratedTransform?: boolean;
3568
+ /**
3569
+ * Whether to emit warnings when a namespace is called as a function.
3570
+ *
3571
+ * A module namespace object is an object and not a function. Calling it as a function will cause a runtime error.
3572
+ *
3573
+ *
3574
+ * @default true
3575
+ * */
3576
+ cannotCallNamespace?: boolean;
3577
+ /**
3578
+ * Whether to emit warnings when a config value is overridden by another config value with a higher priority.
3579
+ *
3580
+ *
3581
+ * @default true
3582
+ * */
3583
+ configurationFieldConflict?: boolean;
3584
+ /**
3585
+ * Whether to emit warnings when a plugin that is covered by a built-in feature is used.
3586
+ *
3587
+ * Using built-in features is generally more performant than using plugins.
3588
+ * @default true
3589
+ * */
3590
+ preferBuiltinFeature?: boolean;
3591
+ /**
3592
+ * Whether to emit warnings when Rolldown could not clean the output directory.
3593
+ *
3594
+ * See [`output.cleanDir`](https://rolldown.rs/reference/OutputOptions.cleanDir).
3595
+ * @default true
3596
+ * */
3597
+ couldNotCleanDirectory?: boolean;
3598
+ /**
3599
+ * Whether to emit warnings when plugins take significant time during the build process.
3600
+ *
3601
+ *
3602
+ * @default true
3603
+ * */
3604
+ pluginTimings?: boolean;
3605
+ /**
3606
+ * Whether to emit warnings when both the code and postBanner contain shebang
3607
+ *
3608
+ * Having multiple shebangs in a file is a syntax error.
3609
+ * @default true
3610
+ * */
3611
+ duplicateShebang?: boolean;
3612
+ /**
3613
+ * Whether to emit warnings when a tsconfig option or combination of options is not supported.
3614
+ * @default true
3615
+ * */
3616
+ unsupportedTsconfigOption?: boolean;
3617
+ /**
3618
+ * Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting.
3619
+ * @default true
3620
+ * */
3621
+ ineffectiveDynamicImport?: boolean;
3622
+ } //#endregion
3623
+ //#region src/options/transform-options.d.ts
3624
+ interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
3625
+ /**
3626
+ * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
3627
+ *
3628
+ * See Oxc's [`define` option](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement.html#define) for more details.
3629
+ *
3630
+ * @example
3631
+ * **Replace the global variable `IS_PROD` with `true`**
3632
+ * ```js [rolldown.config.js]
3633
+ * export default defineConfig({
3634
+ * transform: { define: { IS_PROD: 'true' } }
3635
+ * })
3636
+ * ```
3637
+ * Result:
3638
+ * ```js
3639
+ * // Input
3640
+ * if (IS_PROD) {
3641
+ * console.log('Production mode')
3642
+ * }
3643
+ *
3644
+ * // After bundling
3645
+ * if (true) {
3646
+ * console.log('Production mode')
3647
+ * }
3648
+ * ```
3649
+ *
3650
+ * **Replace the property accessor `process.env.NODE_ENV` with `'production'`**
3651
+ * ```js [rolldown.config.js]
3652
+ * export default defineConfig({
3653
+ * transform: { define: { 'process.env.NODE_ENV': "'production'" } }
3654
+ * })
3655
+ * ```
3656
+ * Result:
3657
+ * ```js
3658
+ * // Input
3659
+ * if (process.env.NODE_ENV === 'production') {
3660
+ * console.log('Production mode')
3661
+ * }
3662
+ *
3663
+ * // After bundling
3664
+ * if ('production' === 'production') {
3665
+ * console.log('Production mode')
3666
+ * }
3667
+ * ```
3668
+ */
3669
+ define?: Record<string, string>;
3670
+ /**
3671
+ * Inject import statements on demand.
3672
+ *
3673
+ * The API is aligned with `@rollup/plugin-inject`.
3674
+ *
3675
+ * See Oxc's [`inject` option](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement.html#inject) for more details.
3676
+ *
3677
+ * #### Supported patterns
3678
+ * ```js
3679
+ * {
3680
+ * // import { Promise } from 'es6-promise'
3681
+ * Promise: ['es6-promise', 'Promise'],
3682
+ *
3683
+ * // import { Promise as P } from 'es6-promise'
3684
+ * P: ['es6-promise', 'Promise'],
3685
+ *
3686
+ * // import $ from 'jquery'
3687
+ * $: 'jquery',
3688
+ *
3689
+ * // import * as fs from 'node:fs'
3690
+ * fs: ['node:fs', '*'],
3691
+ *
3692
+ * // Inject shims for property access pattern
3693
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
3694
+ * }
3695
+ * ```
2718
3696
  */
2719
- minifyInternalExports?: boolean;
3697
+ inject?: Record<string, string | [string, string]>;
2720
3698
  /**
2721
- * - Type: `boolean`
2722
- * - Default: `false`
3699
+ * Remove labeled statements with these label names.
2723
3700
  *
2724
- * Clean output directory before emitting output.
2725
- */
2726
- cleanDir?: boolean;
2727
- /** Keep function and class names after bundling.
3701
+ * Labeled statements are JavaScript statements prefixed with a label identifier.
3702
+ * This option allows you to strip specific labeled statements from the output,
3703
+ * which is useful for removing debug-only code in production builds.
3704
+ *
3705
+ * @example
3706
+ * ```js rolldown.config.js
3707
+ * export default defineConfig({
3708
+ * transform: { dropLabels: ['DEBUG', 'DEV'] }
3709
+ * })
3710
+ * ```
3711
+ * Result:
3712
+ * ```js
3713
+ * // Input
3714
+ * DEBUG: console.log('Debug info');
3715
+ * DEV: {
3716
+ * console.log('Development mode');
3717
+ * }
3718
+ * console.log('Production code');
2728
3719
  *
2729
- * When enabled, the bundler will preserve the original names of functions and classes
2730
- * in the output, which is useful for debugging and error stack traces.
3720
+ * // After bundling
3721
+ * console.log('Production code');
3722
+ * ```
3723
+ */
3724
+ dropLabels?: string[];
3725
+ /**
3726
+ * Controls how JSX syntax is transformed.
2731
3727
  *
2732
- * @default false
3728
+ * - If set to `false`, an error will be thrown if JSX syntax is encountered.
3729
+ * - If set to `'react'`, JSX syntax will be transformed to classic runtime React code.
3730
+ * - If set to `'react-jsx'`, JSX syntax will be transformed to automatic runtime React code.
3731
+ * - If set to `'preserve'`, JSX syntax will be preserved as-is.
2733
3732
  */
2734
- keepNames?: boolean;
3733
+ jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
2735
3734
  } //#endregion
2736
- //#region src/api/build.d.ts
2737
- //#endregion
2738
- //#region src/log/log-handler.d.ts
2739
- type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
2740
- type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
2741
- column: number;
2742
- line: number;
2743
- }) => void;
2744
- //#endregion
2745
3735
  //#region src/options/normalized-input-options.d.ts
3736
+ /** @category Plugin APIs */
2746
3737
  interface NormalizedInputOptions {
3738
+ /** @see {@linkcode InputOptions.input | input} */
2747
3739
  input: string[] | Record<string, string>;
3740
+ /** @see {@linkcode InputOptions.cwd | cwd} */
2748
3741
  cwd: string;
3742
+ /** @see {@linkcode InputOptions.platform | platform} */
2749
3743
  platform: InputOptions["platform"];
3744
+ /** @see {@linkcode InputOptions.shimMissingExports | shimMissingExports} */
2750
3745
  shimMissingExports: boolean;
3746
+ /** @see {@linkcode InputOptions.context | context} */
2751
3747
  context: string;
3748
+ /** @see {@linkcode InputOptions.plugins | plugins} */
3749
+ plugins: RolldownPlugin[];
2752
3750
  } //#endregion
2753
3751
  //#region src/options/normalized-output-options.d.ts
2754
3752
  type PathsFunction = (id: string) => string;
3753
+ /**
3754
+ * A normalized version of {@linkcode ModuleFormat}.
3755
+ * @category Plugin APIs
3756
+ */
2755
3757
  type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
3758
+ /** @category Plugin APIs */
2756
3759
  interface NormalizedOutputOptions {
3760
+ /** @see {@linkcode OutputOptions.name | name} */
2757
3761
  name: string | undefined;
3762
+ /** @see {@linkcode OutputOptions.file | file} */
2758
3763
  file: string | undefined;
3764
+ /** @see {@linkcode OutputOptions.dir | dir} */
2759
3765
  dir: string | undefined;
3766
+ /** @see {@linkcode OutputOptions.entryFileNames | entryFileNames} */
2760
3767
  entryFileNames: string | ChunkFileNamesFunction;
3768
+ /** @see {@linkcode OutputOptions.chunkFileNames | chunkFileNames} */
2761
3769
  chunkFileNames: string | ChunkFileNamesFunction;
3770
+ /** @see {@linkcode OutputOptions.assetFileNames | assetFileNames} */
2762
3771
  assetFileNames: string | AssetFileNamesFunction;
3772
+ /** @see {@linkcode OutputOptions.format | format} */
2763
3773
  format: InternalModuleFormat;
3774
+ /** @see {@linkcode OutputOptions.exports | exports} */
2764
3775
  exports: NonNullable<OutputOptions["exports"]>;
3776
+ /** @see {@linkcode OutputOptions.sourcemap | sourcemap} */
2765
3777
  sourcemap: boolean | "inline" | "hidden";
3778
+ /** @see {@linkcode OutputOptions.sourcemapBaseUrl | sourcemapBaseUrl} */
2766
3779
  sourcemapBaseUrl: string | undefined;
2767
- cssEntryFileNames: string | ChunkFileNamesFunction;
2768
- cssChunkFileNames: string | ChunkFileNamesFunction;
3780
+ /** @see {@linkcode OutputOptions.codeSplitting | codeSplitting} */
3781
+ codeSplitting: boolean;
3782
+ /** @deprecated Use `codeSplitting` instead. */
2769
3783
  inlineDynamicImports: boolean;
3784
+ /** @see {@linkcode OutputOptions.dynamicImportInCjs | dynamicImportInCjs} */
3785
+ dynamicImportInCjs: boolean;
3786
+ /** @see {@linkcode OutputOptions.externalLiveBindings | externalLiveBindings} */
2770
3787
  externalLiveBindings: boolean;
3788
+ /** @see {@linkcode OutputOptions.banner | banner} */
2771
3789
  banner: AddonFunction;
3790
+ /** @see {@linkcode OutputOptions.footer | footer} */
2772
3791
  footer: AddonFunction;
3792
+ /** @see {@linkcode OutputOptions.postBanner | postBanner} */
2773
3793
  postBanner: AddonFunction;
3794
+ /** @see {@linkcode OutputOptions.postFooter | postFooter} */
2774
3795
  postFooter: AddonFunction;
3796
+ /** @see {@linkcode OutputOptions.intro | intro} */
2775
3797
  intro: AddonFunction;
3798
+ /** @see {@linkcode OutputOptions.outro | outro} */
2776
3799
  outro: AddonFunction;
3800
+ /** @see {@linkcode OutputOptions.esModule | esModule} */
2777
3801
  esModule: boolean | "if-default-prop";
3802
+ /** @see {@linkcode OutputOptions.extend | extend} */
2778
3803
  extend: boolean;
3804
+ /** @see {@linkcode OutputOptions.globals | globals} */
2779
3805
  globals: Record<string, string> | GlobalsFunction;
3806
+ /** @see {@linkcode OutputOptions.paths | paths} */
2780
3807
  paths: Record<string, string> | PathsFunction | undefined;
3808
+ /** @see {@linkcode OutputOptions.hashCharacters | hashCharacters} */
2781
3809
  hashCharacters: "base64" | "base36" | "hex";
3810
+ /** @see {@linkcode OutputOptions.sourcemapDebugIds | sourcemapDebugIds} */
2782
3811
  sourcemapDebugIds: boolean;
3812
+ /** @see {@linkcode OutputOptions.sourcemapExcludeSources | sourcemapExcludeSources} */
3813
+ sourcemapExcludeSources: boolean;
3814
+ /** @see {@linkcode OutputOptions.sourcemapIgnoreList | sourcemapIgnoreList} */
2783
3815
  sourcemapIgnoreList: boolean | SourcemapIgnoreListOption | StringOrRegExp | undefined;
3816
+ /** @see {@linkcode OutputOptions.sourcemapPathTransform | sourcemapPathTransform} */
2784
3817
  sourcemapPathTransform: SourcemapPathTransformOption | undefined;
3818
+ /** @see {@linkcode OutputOptions.minify | minify} */
2785
3819
  minify: false | MinifyOptions | "dce-only";
3820
+ /**
3821
+ * @deprecated Use `comments.legal` instead.
3822
+ * @see {@linkcode OutputOptions.legalComments | legalComments}
3823
+ */
2786
3824
  legalComments: "none" | "inline";
3825
+ /** @see {@linkcode OutputOptions.comments | comments} */
3826
+ comments: Required<CommentsOptions>;
3827
+ /** @see {@linkcode OutputOptions.polyfillRequire | polyfillRequire} */
2787
3828
  polyfillRequire: boolean;
3829
+ /** @see {@linkcode OutputOptions.plugins | plugins} */
2788
3830
  plugins: RolldownPlugin[];
3831
+ /** @see {@linkcode OutputOptions.preserveModules | preserveModules} */
2789
3832
  preserveModules: boolean;
3833
+ /** @see {@linkcode OutputOptions.virtualDirname | virtualDirname} */
2790
3834
  virtualDirname: string;
3835
+ /** @see {@linkcode OutputOptions.preserveModulesRoot | preserveModulesRoot} */
2791
3836
  preserveModulesRoot?: string;
3837
+ /** @see {@linkcode OutputOptions.topLevelVar | topLevelVar} */
2792
3838
  topLevelVar?: boolean;
3839
+ /** @see {@linkcode OutputOptions.minifyInternalExports | minifyInternalExports} */
2793
3840
  minifyInternalExports?: boolean;
2794
3841
  } //#endregion
2795
3842
  //#region src/plugin/fs.d.ts
3843
+ /** @category Plugin APIs */
2796
3844
  interface RolldownFsModule {
2797
3845
  appendFile(path: string, data: string | Uint8Array, options?: {
2798
3846
  encoding?: BufferEncoding | null;
@@ -2835,13 +3883,16 @@ interface RolldownFsModule {
2835
3883
  flag?: string | number;
2836
3884
  }): Promise<void>;
2837
3885
  }
3886
+ /** @category Plugin APIs */
2838
3887
  type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
3888
+ /** @category Plugin APIs */
2839
3889
  interface RolldownDirectoryEntry {
2840
3890
  isFile(): boolean;
2841
3891
  isDirectory(): boolean;
2842
3892
  isSymbolicLink(): boolean;
2843
3893
  name: string;
2844
3894
  }
3895
+ /** @category Plugin APIs */
2845
3896
  interface RolldownFileStats {
2846
3897
  isFile(): boolean;
2847
3898
  isDirectory(): boolean;
@@ -2853,6 +3904,7 @@ interface RolldownFileStats {
2853
3904
  birthtime: Date;
2854
3905
  } //#endregion
2855
3906
  //#region src/plugin/hook-filter.d.ts
3907
+ /** @category Plugin APIs */
2856
3908
  type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
2857
3909
  include?: MaybeArray<Value>;
2858
3910
  exclude?: MaybeArray<Value>;
@@ -2860,10 +3912,21 @@ type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
2860
3912
  interface FormalModuleTypeFilter {
2861
3913
  include?: ModuleType[];
2862
3914
  }
3915
+ /** @category Plugin APIs */
2863
3916
  type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
3917
+ /**
3918
+ * A filter to be used to do a pre-test to determine whether the hook should be called.
3919
+ *
3920
+ * See [Plugin Hook Filters page](https://rolldown.rs/apis/plugin-api/hook-filters) for more details.
3921
+ *
3922
+ * @category Plugin APIs
3923
+ */
2864
3924
  interface HookFilter {
2865
3925
  /**
2866
- * This filter is used to do a pre-test to determine whether the hook should be called.
3926
+ * A filter based on the module `id`.
3927
+ *
3928
+ * If the value is a string, it is treated as a glob pattern.
3929
+ * The string type is not available for {@linkcode Plugin.resolveId | resolveId} hook.
2867
3930
  *
2868
3931
  * @example
2869
3932
  * Include all `id`s that contain `node_modules` in the path.
@@ -2887,7 +3950,7 @@ interface HookFilter {
2887
3950
  * ```
2888
3951
  * @example
2889
3952
  * Formal pattern to define includes and excludes.
2890
- * ```
3953
+ * ```js
2891
3954
  * { id : {
2892
3955
  * include: ['**'+'/foo/**', /bar/],
2893
3956
  * exclude: ['**'+'/baz/**', /qux/]
@@ -2895,86 +3958,370 @@ interface HookFilter {
2895
3958
  * ```
2896
3959
  */
2897
3960
  id?: GeneralHookFilter;
3961
+ /**
3962
+ * A filter based on the module's `moduleType`.
3963
+ *
3964
+ * Only available for {@linkcode Plugin.transform | transform} hook.
3965
+ */
2898
3966
  moduleType?: ModuleTypeFilter;
3967
+ /**
3968
+ * A filter based on the module's code.
3969
+ *
3970
+ * Only available for {@linkcode Plugin.transform | transform} hook.
3971
+ */
2899
3972
  code?: GeneralHookFilter;
2900
- }
2901
- type TUnionWithTopLevelFilterExpressionArray<T> = T | TopLevelFilterExpression[]; //#endregion
3973
+ } //#endregion
2902
3974
  //#region src/plugin/minimal-plugin-context.d.ts
3975
+ /** @category Plugin APIs */
2903
3976
  interface PluginContextMeta {
3977
+ /**
3978
+ * A property for Rollup compatibility. A dummy value is set by Rolldown.
3979
+ * @example `'4.23.0'`
3980
+ */
2904
3981
  rollupVersion: string;
3982
+ /**
3983
+ * The currently running version of Rolldown.
3984
+ * @example `'1.0.0'`
3985
+ */
2905
3986
  rolldownVersion: string;
3987
+ /**
3988
+ * Whether Rolldown was started via {@linkcode watch | rolldown.watch()} or
3989
+ * from the command line with `--watch`.
3990
+ */
2906
3991
  watchMode: boolean;
2907
3992
  }
3993
+ /** @category Plugin APIs */
2908
3994
  interface MinimalPluginContext {
2909
- readonly pluginName: string;
2910
- error: (e: RollupError | string) => never;
3995
+ /**
3996
+ * Similar to {@linkcode warn | this.warn}, except that it will also abort
3997
+ * the bundling process with an error.
3998
+ *
3999
+ * If an Error instance is passed, it will be used as-is, otherwise a new Error
4000
+ * instance will be created with the given error message and all additional
4001
+ * provided properties.
4002
+ *
4003
+ * In all hooks except the {@linkcode Plugin.onLog | onLog} hook, the error will
4004
+ * be augmented with {@linkcode RolldownLog.code | code: "PLUGIN_ERROR"} and
4005
+ * {@linkcode RolldownLog.plugin | plugin: plugin.name} properties.
4006
+ * If a `code` property already exists and the code does not start with `PLUGIN_`,
4007
+ * it will be renamed to {@linkcode RolldownLog.pluginCode | pluginCode}.
4008
+ *
4009
+ * @group Logging Methods
4010
+ */
4011
+ error: (e: RolldownError | string) => never;
4012
+ /**
4013
+ * Generate a `"info"` level log.
4014
+ *
4015
+ * {@linkcode RolldownLog.code | code} will be set to `"PLUGIN_LOG"` by Rolldown.
4016
+ * As these logs are displayed by default, use them for information that is not a warning
4017
+ * but makes sense to display to all users on every build.
4018
+ *
4019
+ *
4020
+ *
4021
+ * @inlineType LoggingFunction
4022
+ * @group Logging Methods
4023
+ */
2911
4024
  info: LoggingFunction;
4025
+ /**
4026
+ * Generate a `"warn"` level log.
4027
+ *
4028
+ * Just like internally generated warnings, these logs will be first passed to and
4029
+ * filtered by plugin {@linkcode Plugin.onLog | onLog} hooks before they are forwarded
4030
+ * to custom {@linkcode InputOptions.onLog | onLog} or
4031
+ * {@linkcode InputOptions.onwarn | onwarn} handlers or printed to the console.
4032
+ *
4033
+ * We encourage you to use objects with a {@linkcode RolldownLog.pluginCode | pluginCode}
4034
+ * property as that will allow users to easily filter for those logs in an `onLog` handler.
4035
+ *
4036
+ *
4037
+ *
4038
+ * @inlineType LoggingFunction
4039
+ * @group Logging Methods
4040
+ */
2912
4041
  warn: LoggingFunction;
4042
+ /**
4043
+ * Generate a `"debug"` level log.
4044
+ *
4045
+ * {@linkcode RolldownLog.code | code} will be set to `"PLUGIN_LOG"` by Rolldown.
4046
+ * Make sure to add a distinctive {@linkcode RolldownLog.pluginCode | pluginCode} to
4047
+ * those logs for easy filtering.
4048
+ *
4049
+ *
4050
+ *
4051
+ * @inlineType LoggingFunction
4052
+ * @group Logging Methods
4053
+ */
2913
4054
  debug: LoggingFunction;
4055
+ /** An object containing potentially useful metadata. */
2914
4056
  meta: PluginContextMeta;
2915
4057
  } //#endregion
2916
4058
  //#region src/plugin/parallel-plugin.d.ts
2917
4059
  type ParallelPlugin = {
2918
- /** @internal */_parallel: {
4060
+ _parallel: {
2919
4061
  fileUrl: string;
2920
4062
  options: unknown;
2921
4063
  };
2922
4064
  };
4065
+ /** @internal */
2923
4066
  //#endregion
2924
4067
  //#region src/plugin/plugin-context.d.ts
4068
+ /**
4069
+ * Either a {@linkcode name} or a {@linkcode fileName} can be supplied.
4070
+ * If a {@linkcode fileName} is provided, it will be used unmodified as the name
4071
+ * of the generated file, throwing an error if this causes a conflict.
4072
+ * Otherwise, if a {@linkcode name} is supplied, this will be used as substitution
4073
+ * for `[name]` in the corresponding
4074
+ * {@linkcode OutputOptions.assetFileNames | output.assetFileNames} pattern, possibly
4075
+ * adding a unique number to the end of the file name to avoid conflicts.
4076
+ * If neither a {@linkcode name} nor {@linkcode fileName} is supplied, a default name will be used.
4077
+ *
4078
+ * @category Plugin APIs
4079
+ */
2925
4080
  interface EmittedAsset {
2926
4081
  type: "asset";
2927
4082
  name?: string;
2928
4083
  fileName?: string;
4084
+ /**
4085
+ * An absolute path to the original file if this asset corresponds to a file on disk.
4086
+ *
4087
+ * This property will be passed on to subsequent plugin hooks that receive a
4088
+ * {@linkcode PreRenderedAsset} or an {@linkcode OutputAsset} like
4089
+ * {@linkcode Plugin.generateBundle | generateBundle}.
4090
+ * In watch mode, Rolldown will also automatically watch this file for changes and
4091
+ * trigger a rebuild if it changes. Therefore, it is not necessary to call
4092
+ * {@linkcode PluginContext.addWatchFile | this.addWatchFile} for this file.
4093
+ */
2929
4094
  originalFileName?: string;
2930
4095
  source: AssetSource;
2931
4096
  }
4097
+ /**
4098
+ * Either a {@linkcode name} or a {@linkcode fileName} can be supplied.
4099
+ * If a {@linkcode fileName} is provided, it will be used unmodified as the name
4100
+ * of the generated file, throwing an error if this causes a conflict.
4101
+ * Otherwise, if a {@linkcode name} is supplied, this will be used as substitution
4102
+ * for `[name]` in the corresponding
4103
+ * {@linkcode OutputOptions.chunkFileNames | output.chunkFileNames} pattern, possibly
4104
+ * adding a unique number to the end of the file name to avoid conflicts.
4105
+ * If neither a {@linkcode name} nor {@linkcode fileName} is supplied, a default name will be used.
4106
+ *
4107
+ * @category Plugin APIs
4108
+ */
2932
4109
  interface EmittedChunk {
2933
4110
  type: "chunk";
2934
4111
  name?: string;
2935
4112
  fileName?: string;
4113
+ /**
4114
+ * When provided, this will override
4115
+ * {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures} for this particular
4116
+ * chunk.
4117
+ */
2936
4118
  preserveSignature?: "strict" | "allow-extension" | "exports-only" | false;
4119
+ /**
4120
+ * The module id of the entry point of the chunk.
4121
+ *
4122
+ * It will be passed through build hooks just like regular entry points,
4123
+ * starting with {@linkcode Plugin.resolveId | resolveId}.
4124
+ */
2937
4125
  id: string;
4126
+ /**
4127
+ * The value to be passed to {@linkcode Plugin.resolveId | resolveId}'s {@linkcode importer} parameter when resolving the entry point.
4128
+ * This is important to properly resolve relative paths. If it is not provided,
4129
+ * paths will be resolved relative to the current working directory.
4130
+ */
2938
4131
  importer?: string;
2939
4132
  }
4133
+ /** @category Plugin APIs */
2940
4134
  interface EmittedPrebuiltChunk {
2941
4135
  type: "prebuilt-chunk";
2942
4136
  fileName: string;
4137
+ /**
4138
+ * A semantic name for the chunk. If not provided, `fileName` will be used.
4139
+ */
4140
+ name?: string;
4141
+ /**
4142
+ * The code of this chunk.
4143
+ */
2943
4144
  code: string;
4145
+ /**
4146
+ * The list of exported variable names from this chunk.
4147
+ *
4148
+ * This should be provided if the chunk exports any variables.
4149
+ */
2944
4150
  exports?: string[];
4151
+ /**
4152
+ * The corresponding source map for this chunk.
4153
+ */
2945
4154
  map?: SourceMap;
2946
4155
  sourcemapFileName?: string;
4156
+ /**
4157
+ * The module id of the facade module for this chunk, if any.
4158
+ */
4159
+ facadeModuleId?: string;
4160
+ /**
4161
+ * Whether this chunk corresponds to an entry point.
4162
+ */
4163
+ isEntry?: boolean;
4164
+ /**
4165
+ * Whether this chunk corresponds to a dynamic entry point.
4166
+ */
4167
+ isDynamicEntry?: boolean;
2947
4168
  }
4169
+ /** @inline @category Plugin APIs */
2948
4170
  type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
4171
+ /** @category Plugin APIs */
2949
4172
  interface PluginContextResolveOptions {
4173
+ /**
4174
+ * The value for {@linkcode ResolveIdExtraOptions.kind | kind} passed to
4175
+ * {@linkcode Plugin.resolveId | resolveId} hooks.
4176
+ */
4177
+ kind?: BindingPluginContextResolveOptions["importKind"];
4178
+ /**
4179
+ * The value for {@linkcode ResolveIdExtraOptions.isEntry | isEntry} passed to
4180
+ * {@linkcode Plugin.resolveId | resolveId} hooks.
4181
+ *
4182
+ * @default `false` if there's an importer, `true` otherwise.
4183
+ */
2950
4184
  isEntry?: boolean;
4185
+ /**
4186
+ * Whether the {@linkcode Plugin.resolveId | resolveId} hook of the plugin from
4187
+ * which {@linkcode PluginContext.resolve | this.resolve} is called will be skipped
4188
+ * when resolving.
4189
+ *
4190
+ *
4191
+ *
4192
+ * @default true
4193
+ */
2951
4194
  skipSelf?: boolean;
4195
+ /**
4196
+ * Plugin-specific options.
4197
+ *
4198
+ * See [Custom resolver options section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-resolver-options) for more details.
4199
+ */
2952
4200
  custom?: CustomPluginOptions;
2953
4201
  }
4202
+ /** @inline */
2954
4203
  type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
4204
+ /** @category Plugin APIs */
2955
4205
  interface PluginContext extends MinimalPluginContext {
4206
+ /**
4207
+ * Provides abstract access to the file system.
4208
+ */
2956
4209
  fs: RolldownFsModule;
4210
+ /**
4211
+ * Emits a new file that is included in the build output.
4212
+ * You can emit chunks, prebuilt chunks or assets.
4213
+ *
4214
+ *
4215
+ *
4216
+ * @returns A `referenceId` for the emitted file that can be used in various places to reference the emitted file.
4217
+ */
2957
4218
  emitFile(file: EmittedFile): string;
4219
+ /**
4220
+ * Get the file name of a chunk or asset that has been emitted via
4221
+ * {@linkcode emitFile | this.emitFile}.
4222
+ *
4223
+ * @returns The file name of the emitted file. Relative to {@linkcode OutputOptions.dir | output.dir}.
4224
+ */
2958
4225
  getFileName(referenceId: string): string;
4226
+ /**
4227
+ * Get all module ids in the current module graph.
4228
+ *
4229
+ * @returns
4230
+ * An iterator of module ids. It can be iterated via
4231
+ * ```js
4232
+ * for (const moduleId of this.getModuleIds()) {
4233
+ * // ...
4234
+ * }
4235
+ * ```
4236
+ * or converted into an array via `Array.from(this.getModuleIds())`.
4237
+ */
2959
4238
  getModuleIds(): IterableIterator<string>;
4239
+ /**
4240
+ * Get additional information about the module in question.
4241
+ *
4242
+ *
4243
+ *
4244
+ * @returns Module information for that module. `null` if the module could not be found.
4245
+ * @group Methods
4246
+ */
2960
4247
  getModuleInfo: GetModuleInfo;
4248
+ /**
4249
+ * Adds additional files to be monitored in watch mode so that changes to these files will trigger rebuilds.
4250
+ *
4251
+ *
4252
+ */
2961
4253
  addWatchFile(id: string): void;
4254
+ /**
4255
+ * Loads and parses the module corresponding to the given id, attaching additional
4256
+ * meta information to the module if provided. This will trigger the same
4257
+ * {@linkcode Plugin.load | load}, {@linkcode Plugin.transform | transform} and
4258
+ * {@linkcode Plugin.moduleParsed | moduleParsed} hooks as if the module was imported
4259
+ * by another module.
4260
+ *
4261
+ *
4262
+ */
2962
4263
  load(options: {
2963
4264
  id: string;
2964
4265
  resolveDependencies?: boolean;
2965
4266
  } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
4267
+ /**
4268
+ * Use Rolldown's internal parser to parse code to an [ESTree-compatible](https://github.com/estree/estree) AST.
4269
+ */
2966
4270
  parse(input: string, options?: ParserOptions | null): Program;
4271
+ /**
4272
+ * Resolve imports to module ids (i.e. file names) using the same plugins that Rolldown uses,
4273
+ * and determine if an import should be external.
4274
+ *
4275
+ * When calling this function from a {@linkcode Plugin.resolveId | resolveId} hook, you should
4276
+ * always check if it makes sense for you to pass along the
4277
+ * {@link PluginContextResolveOptions | options}.
4278
+ *
4279
+ * @returns
4280
+ * If `Promise<null>` is returned, the import could not be resolved by Rolldown or any plugin
4281
+ * but was not explicitly marked as external by the user.
4282
+ * If an absolute external id is returned that should remain absolute in the output either
4283
+ * via the
4284
+ * {@linkcode InputOptions.makeAbsoluteExternalsRelative | makeAbsoluteExternalsRelative}
4285
+ * option or by explicit plugin choice in the {@linkcode Plugin.resolveId | resolveId} hook,
4286
+ * `external` will be `"absolute"` instead of `true`.
4287
+ */
2967
4288
  resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
2968
4289
  } //#endregion
2969
4290
  //#region src/plugin/transform-plugin-context.d.ts
4291
+ /** @category Plugin APIs */
2970
4292
  interface TransformPluginContext extends PluginContext {
4293
+ /**
4294
+ * Same as {@linkcode PluginContext.debug}, but a `position` param can be supplied.
4295
+ *
4296
+ * @inlineType LoggingFunctionWithPosition
4297
+ * @group Logging Methods
4298
+ */
2971
4299
  debug: LoggingFunctionWithPosition;
4300
+ /**
4301
+ * Same as {@linkcode PluginContext.info}, but a `position` param can be supplied.
4302
+ *
4303
+ * @inlineType LoggingFunctionWithPosition
4304
+ * @group Logging Methods
4305
+ */
2972
4306
  info: LoggingFunctionWithPosition;
4307
+ /**
4308
+ * Same as {@linkcode PluginContext.warn}, but a `position` param can be supplied.
4309
+ *
4310
+ * @inlineType LoggingFunctionWithPosition
4311
+ * @group Logging Methods
4312
+ */
2973
4313
  warn: LoggingFunctionWithPosition;
2974
- error(e: RollupError | string, pos?: number | {
4314
+ /**
4315
+ * Same as {@linkcode PluginContext.error}, but the `id` of the current module will
4316
+ * also be added and a `position` param can be supplied.
4317
+ */
4318
+ error(e: RolldownError | string, pos?: number | {
2975
4319
  column: number;
2976
4320
  line: number;
2977
4321
  }): never;
4322
+ /**
4323
+ * Get the combined source maps of all previous plugins.
4324
+ */
2978
4325
  getCombinedSourcemap(): SourceMap;
2979
4326
  } //#endregion
2980
4327
  //#region src/types/module-side-effects.d.ts
@@ -2984,22 +4331,161 @@ interface ModuleSideEffectsRule {
2984
4331
  sideEffects: boolean;
2985
4332
  }
2986
4333
  type ModuleSideEffectsOption = boolean | readonly string[] | ModuleSideEffectsRule[] | ((id: string, external: boolean) => boolean | undefined) | "no-external";
4334
+ /**
4335
+ * When passing an object, you can fine-tune the tree-shaking behavior.
4336
+ */
2987
4337
  type TreeshakingOptions = {
4338
+ /**
4339
+ * **Values:**
4340
+ *
4341
+ * - **`true`**: All modules are assumed to have side effects and will be included in the bundle even if none of their exports are used.
4342
+ * - **`false`**: No modules have side effects. This enables aggressive tree-shaking, removing any modules whose exports are not used.
4343
+ * - **`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.
4344
+ * - **`'no-external'`**: Assumes no external modules have side effects while preserving the default behavior for local modules.
4345
+ * - **`ModuleSideEffectsRule[]`**: Array of rules with `test`, `external`, and `sideEffects` properties for fine-grained control.
4346
+ * - **`function`**: Function that receives `(id, external)` and returns whether the module has side effects.
4347
+ *
4348
+ * **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.
4349
+ *
4350
+ * > [!NOTE]
4351
+ * > **Performance: Prefer `ModuleSideEffectsRule[]` over functions**
4352
+ * >
4353
+ * > 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.
4354
+ * >
4355
+ * > **Functions should be a last resort**: Only use the function signature when your logic cannot be expressed with patterns or simple string matching.
4356
+ * >
4357
+ * > **Rule advantages**: `ModuleSideEffectsRule[]` provides better performance by avoiding Rust-JavaScript runtime calls, clearer intent, and easier maintenance.
4358
+ *
4359
+ * @example
4360
+ * ```js
4361
+ * // Assume no modules have side effects (aggressive tree-shaking)
4362
+ * treeshake: {
4363
+ * moduleSideEffects: false
4364
+ * }
4365
+ *
4366
+ * // Only specific modules have side effects (string array)
4367
+ * treeshake: {
4368
+ * moduleSideEffects: [
4369
+ * 'lodash',
4370
+ * 'react-dom',
4371
+ * ]
4372
+ * }
4373
+ *
4374
+ * // Use rules for pattern matching and granular control
4375
+ * treeshake: {
4376
+ * moduleSideEffects: [
4377
+ * { test: /^node:/, sideEffects: true },
4378
+ * { test: /\.css$/, sideEffects: true },
4379
+ * { test: /some-package/, sideEffects: false, external: false },
4380
+ * ]
4381
+ * }
4382
+ *
4383
+ * // Custom function to determine side effects
4384
+ * treeshake: {
4385
+ * moduleSideEffects: (id, external) => {
4386
+ * if (external) return false; // external modules have no side effects
4387
+ * return id.includes('/side-effects/') || id.endsWith('.css');
4388
+ * }
4389
+ * }
4390
+ *
4391
+ * // Assume no external modules have side effects
4392
+ * treeshake: {
4393
+ * moduleSideEffects: 'no-external',
4394
+ * }
4395
+ * ```
4396
+ *
4397
+ * **Common Use Cases:**
4398
+ * - **CSS files**: `{ test: /\.css$/, sideEffects: true }` - preserve CSS imports
4399
+ * - **Polyfills**: Add specific polyfill modules to the array
4400
+ * - **Plugins**: Modules that register themselves globally on import
4401
+ * - **Library development**: Set to `false` for libraries where unused exports should be removed
4402
+ *
4403
+ * @default true
4404
+ */
2988
4405
  moduleSideEffects?: ModuleSideEffectsOption;
4406
+ /**
4407
+ * Whether to respect `/*@__PURE__*\/` annotations and other tree-shaking hints in the code.
4408
+ *
4409
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#pure-annotations) for more details.
4410
+ *
4411
+ * @default true
4412
+ */
2989
4413
  annotations?: boolean;
4414
+ /**
4415
+ * Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure.
4416
+ *
4417
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#define-pure-functions) for more details.
4418
+ *
4419
+ * @example
4420
+ * ```js
4421
+ * treeshake: {
4422
+ * manualPureFunctions: ['console.log', 'debug.trace']
4423
+ * }
4424
+ * ```
4425
+ * @default []
4426
+ */
2990
4427
  manualPureFunctions?: readonly string[];
4428
+ /**
4429
+ * Whether to assume that accessing unknown global properties might have side effects.
4430
+ *
4431
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-global-variable-access-side-effects) for more details.
4432
+ *
4433
+ * @default true
4434
+ */
2991
4435
  unknownGlobalSideEffects?: boolean;
4436
+ /**
4437
+ * Whether to assume that invalid import statements might have side effects.
4438
+ *
4439
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-invalid-import-statement-side-effects) for more details.
4440
+ *
4441
+ * @default false
4442
+ */
4443
+ invalidImportSideEffects?: boolean;
4444
+ /**
4445
+ * 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.
4446
+ *
4447
+ * This option allows rolldown to analyze `exports.property` assignments in CommonJS modules and remove unused exports while preserving the module's side effects.
4448
+ *
4449
+ * @example
4450
+ * ```js
4451
+ * // source.js (CommonJS)
4452
+ * exports.used = 'This will be kept';
4453
+ * exports.unused = 'This will be tree-shaken away';
4454
+ *
4455
+ * // main.js
4456
+ * import { used } from './source.js';
4457
+ * // With commonjs: true, only the 'used' export is included in the bundle
4458
+ * // With commonjs: false, both exports are included
4459
+ * ```
4460
+ * @default true
4461
+ */
2992
4462
  commonjs?: boolean;
4463
+ /**
4464
+ * Controls whether reading properties from objects is considered to have side effects.
4465
+ *
4466
+ * Set to `false` for more aggressive tree-shaking behavior.
4467
+ *
4468
+ * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-property-read-side-effects) for more details.
4469
+ *
4470
+ * @default 'always'
4471
+ */
2993
4472
  propertyReadSideEffects?: false | "always";
4473
+ /**
4474
+ * Controls whether writing properties to objects is considered to have side effects.
4475
+ *
4476
+ * Set to `false` for more aggressive behavior.
4477
+ *
4478
+ * @default 'always'
4479
+ */
2994
4480
  propertyWriteSideEffects?: false | "always";
2995
4481
  }; //#endregion
2996
4482
  //#region src/types/output-bundle.d.ts
4483
+ /** @category Plugin APIs */
2997
4484
  interface OutputBundle {
2998
4485
  [fileName: string]: OutputAsset | OutputChunk;
2999
4486
  } //#endregion
3000
- //#region src/types/rolldown-options-function.d.ts
3001
- //#endregion
3002
4487
  //#region src/types/sourcemap.d.ts
4488
+ /** @category Plugin APIs */
3003
4489
  interface ExistingRawSourceMap {
3004
4490
  file?: string | null;
3005
4491
  mappings: string;
@@ -3010,8 +4496,12 @@ interface ExistingRawSourceMap {
3010
4496
  version?: number;
3011
4497
  x_google_ignoreList?: number[];
3012
4498
  }
4499
+ /** @inline @category Plugin APIs */
3013
4500
  type SourceMapInput = ExistingRawSourceMap | string | null; //#endregion
3014
- //#region src/version.d.ts
4501
+ //#region src/utils/error.d.ts
4502
+ /**
4503
+ * The error type that is thrown by Rolldown for the whole build.
4504
+ */
3015
4505
  //#endregion
3016
4506
  //#region src/builtin-plugin/utils.d.ts
3017
4507
  declare class BuiltinPlugin {
@@ -3035,7 +4525,7 @@ declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_H
3035
4525
  * }
3036
4526
  * ```
3037
4527
  */
3038
- type DefinedHookNames = { readonly [K in typeof ENUMERATED_PLUGIN_HOOK_NAMES[number]]: K };
4528
+ type DefinedHookNames = { readonly [K in (typeof ENUMERATED_PLUGIN_HOOK_NAMES)[number]]: K };
3039
4529
  /**
3040
4530
  * Names of all defined hooks. It's like
3041
4531
  * ```js
@@ -3051,101 +4541,430 @@ declare const DEFINED_HOOK_NAMES: DefinedHookNames; //#endregion
3051
4541
  //#endregion
3052
4542
  //#region src/plugin/index.d.ts
3053
4543
  type ModuleSideEffects = boolean | "no-treeshake" | null;
4544
+ /** @category Plugin APIs */
3054
4545
  type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
4546
+ /** @category Plugin APIs */
4547
+ /** @category Plugin APIs */
3055
4548
  interface CustomPluginOptions {
3056
4549
  [plugin: string]: any;
3057
4550
  }
4551
+ /** @category Plugin APIs */
3058
4552
  interface ModuleOptions {
3059
4553
  moduleSideEffects: ModuleSideEffects;
4554
+ /** See [Custom module meta-data section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-module-meta-data) for more details. */
3060
4555
  meta: CustomPluginOptions;
3061
4556
  invalidate?: boolean;
3062
4557
  packageJsonPath?: string;
3063
4558
  }
4559
+ /** @category Plugin APIs */
3064
4560
  interface ResolvedId extends ModuleOptions {
3065
4561
  external: boolean | "absolute";
3066
4562
  id: string;
3067
4563
  }
3068
- interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
4564
+ interface SpecifiedModuleOptions {
4565
+ /**
4566
+ * Indicates whether the module has side effects to Rolldown.
4567
+ *
4568
+ * - 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.
4569
+ * - If `true` is set, Rolldown will use its default algorithm to include all statements in the module that has side effects.
4570
+ * - 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.
4571
+ *
4572
+ * The precedence of this option is as follows (highest to lowest):
4573
+ * 1. {@linkcode Plugin.transform | transform} hook's returned `moduleSideEffects` option
4574
+ * 2. {@linkcode Plugin.load | load} hook's returned `moduleSideEffects` option
4575
+ * 3. {@linkcode Plugin.resolveId | resolveId} hook's returned `moduleSideEffects` option
4576
+ * 4. {@linkcode TreeshakingOptions.moduleSideEffects | treeshake.moduleSideEffects} option
4577
+ * 5. `sideEffects` field in the `package.json` file
4578
+ * 6. `true` (default)
4579
+ */
4580
+ moduleSideEffects?: ModuleSideEffects | null;
4581
+ }
4582
+ /** @category Plugin APIs */
4583
+ interface PartialResolvedId extends SpecifiedModuleOptions, Partial<PartialNull<ModuleOptions>> {
4584
+ /**
4585
+ * Whether this id should be treated as external.
4586
+ *
4587
+ * Relative external ids, i.e. ids starting with `./` or `../`, will not be internally
4588
+ * converted to an absolute id and converted back to a relative id in the output,
4589
+ * but are instead included in the output unchanged.
4590
+ * If you want relative ids to be re-normalized and deduplicated instead, return
4591
+ * an absolute file system location as id and choose `external: "relative"`.
4592
+ *
4593
+ * - If `true`, absolute ids will be converted to relative ids based on the user's choice for the {@linkcode InputOptions.makeAbsoluteExternalsRelative | makeAbsoluteExternalsRelative} option.
4594
+ * - If `'relative'`, absolute ids will always be converted to relative ids.
4595
+ * - If `'absolute'`, absolute ids will always be kept as absolute ids.
4596
+ */
3069
4597
  external?: boolean | "absolute" | "relative";
3070
4598
  id: string;
3071
4599
  }
3072
- interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
4600
+ /** @category Plugin APIs */
4601
+ interface SourceDescription extends SpecifiedModuleOptions, Partial<PartialNull<ModuleOptions>> {
3073
4602
  code: string;
4603
+ /**
4604
+ * The source map for the transformation.
4605
+ *
4606
+ * If the transformation does not move code, you can preserve existing sourcemaps by setting this to `null`.
4607
+ *
4608
+ * See [Source Code Transformations section](https://rolldown.rs/apis/plugin-api/transformations#source-code-transformations) for more details.
4609
+ */
3074
4610
  map?: SourceMapInput;
3075
4611
  moduleType?: ModuleType;
3076
4612
  }
4613
+ /** @inline */
3077
4614
  interface ResolveIdExtraOptions {
4615
+ /**
4616
+ * Plugin-specific options.
4617
+ *
4618
+ * See [Custom resolver options section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-resolver-options) for more details.
4619
+ */
3078
4620
  custom?: CustomPluginOptions;
4621
+ /**
4622
+ * Whether this is resolution for an entry point.
4623
+ *
4624
+ *
4625
+ */
3079
4626
  isEntry: boolean;
4627
+ /**
4628
+ * The kind of import being resolved.
4629
+ *
4630
+ * - `import-statement`: `import { foo } from './lib.js';`
4631
+ * - `dynamic-import`: `import('./lib.js')`
4632
+ * - `require-call`: `require('./lib.js')`
4633
+ * - `import-rule`: `@import 'bg-color.css'` (experimental)
4634
+ * - `url-token`: `url('./icon.png')` (experimental)
4635
+ * - `new-url`: `new URL('./worker.js', import.meta.url)` (experimental)
4636
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})` (experimental)
4637
+ */
3080
4638
  kind: BindingHookResolveIdExtraArgs["kind"];
3081
4639
  }
4640
+ /** @inline @category Plugin APIs */
3082
4641
  type ResolveIdResult = string | NullValue | false | PartialResolvedId;
4642
+ /** @inline @category Plugin APIs */
3083
4643
  type LoadResult = NullValue | string | SourceDescription;
4644
+ /** @inline @category Plugin APIs */
3084
4645
  type TransformResult = NullValue | string | (Omit<SourceDescription, "code"> & {
3085
- code?: string | BindingMagicString;
4646
+ code?: string | RolldownMagicString;
3086
4647
  });
3087
4648
  type RenderedChunkMeta = {
4649
+ /**
4650
+ * Contains information about all chunks that are being rendered.
4651
+ * This is useful to explore the entire chunk graph.
4652
+ */
3088
4653
  chunks: Record<string, RenderedChunk>;
4654
+ /**
4655
+ * A lazily-created MagicString instance for the chunk's code.
4656
+ * Use this to perform string transformations with automatic source map support.
4657
+ * This is only available when `experimental.nativeMagicString` is enabled.
4658
+ */
4659
+ magicString?: RolldownMagicString;
3089
4660
  };
4661
+ /** @category Plugin APIs */
3090
4662
  interface FunctionPluginHooks {
3091
- [DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
4663
+ /**
4664
+ * A function that receives and filters logs and warnings generated by Rolldown and
4665
+ * plugins before they are passed to the {@linkcode InputOptions.onLog | onLog} option
4666
+ * or printed to the console.
4667
+ *
4668
+ * If `false` is returned, the log will be filtered out.
4669
+ * Otherwise, the log will be handed to the `onLog` hook of the next plugin,
4670
+ * the {@linkcode InputOptions.onLog | onLog} option, or printed to the console.
4671
+ * Plugins can also change the log level of a log or turn a log into an error by passing
4672
+ * the `log` object to {@linkcode MinimalPluginContext.error | this.error},
4673
+ * {@linkcode MinimalPluginContext.warn | this.warn},
4674
+ * {@linkcode MinimalPluginContext.info | this.info} or
4675
+ * {@linkcode MinimalPluginContext.debug | this.debug} and returning `false`.
4676
+ *
4677
+ *
4678
+ *
4679
+ * @group Build Hooks
4680
+ */
4681
+ [DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RolldownLog) => NullValue | boolean;
4682
+ /**
4683
+ * Replaces or manipulates the options object passed to {@linkcode rolldown | rolldown()}.
4684
+ *
4685
+ * Returning `null` does not replace anything.
4686
+ *
4687
+ * If you just need to read the options, it is recommended to use
4688
+ * the {@linkcode buildStart} hook as that hook has access to the options
4689
+ * after the transformations from all `options` hooks have been taken into account.
4690
+ *
4691
+ * @group Build Hooks
4692
+ */
3092
4693
  [DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
4694
+ /**
4695
+ * Replaces or manipulates the output options object passed to
4696
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
4697
+ * {@linkcode RolldownBuild.write | bundle.write()}.
4698
+ *
4699
+ * Returning null does not replace anything.
4700
+ *
4701
+ * If you just need to read the output options, it is recommended to use
4702
+ * the {@linkcode renderStart} hook as this hook has access to the output options
4703
+ * after the transformations from all `outputOptions` hooks have been taken into account.
4704
+ *
4705
+ * @group Build Hooks
4706
+ */
3093
4707
  [DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
4708
+ /**
4709
+ * Called on each {@linkcode rolldown | rolldown()} build.
4710
+ *
4711
+ * 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.
4712
+ *
4713
+ * @group Build Hooks
4714
+ */
3094
4715
  [DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
4716
+ /**
4717
+ * Defines a custom resolver.
4718
+ *
4719
+ * A resolver can be useful for e.g. locating third-party dependencies.
4720
+ *
4721
+ * Returning `null` defers to other `resolveId` hooks and eventually the default resolution behavior.
4722
+ * 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.
4723
+ * 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.
4724
+ *
4725
+ * Note that while `resolveId` will be called for each import of a module and can therefore
4726
+ * resolve to the same `id` many times, values for `external`, `meta` or `moduleSideEffects`
4727
+ * can only be set once before the module is loaded. The reason is that after this call,
4728
+ * Rolldown will continue with the {@linkcode load} and {@linkcode transform} hooks for that
4729
+ * module that may override these values and should take precedence if they do so.
4730
+ *
4731
+ * @group Build Hooks
4732
+ */
3095
4733
  [DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
3096
4734
  /**
4735
+ * Defines a custom resolver for dynamic imports.
4736
+ *
3097
4737
  * @deprecated
3098
- * This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
4738
+ * This hook exists only for Rollup compatibility. Please use {@linkcode resolveId} instead.
4739
+ *
4740
+ * @group Build Hooks
3099
4741
  */
3100
4742
  [DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
4743
+ /**
4744
+ * Defines a custom loader.
4745
+ *
4746
+ * Returning `null` defers to other `load` hooks or the built-in loading mechanism.
4747
+ *
4748
+ * You can use {@linkcode PluginContext.getModuleInfo | this.getModuleInfo()} to find out the previous values of `meta`, `moduleSideEffects` inside this hook.
4749
+ *
4750
+ * @group Build Hooks
4751
+ */
3101
4752
  [DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
4753
+ /**
4754
+ * Can be used to transform individual modules.
4755
+ *
4756
+ * Note that it's possible to return only properties and no code transformations.
4757
+ *
4758
+ * You can use {@linkcode PluginContext.getModuleInfo | this.getModuleInfo()} to find out the previous values of `meta`, `moduleSideEffects` inside this hook.
4759
+ *
4760
+ *
4761
+ *
4762
+ * @group Build Hooks
4763
+ */
3102
4764
  [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
3103
4765
  moduleType: ModuleType;
3104
- magicString?: BindingMagicString;
4766
+ magicString?: RolldownMagicString;
3105
4767
  ast?: Program;
3106
4768
  }) => TransformResult;
4769
+ /**
4770
+ * This hook is called each time a module has been fully parsed by Rolldown.
4771
+ *
4772
+ * This hook will wait until all imports are resolved so that the information in
4773
+ * {@linkcode ModuleInfo.importedIds | moduleInfo.importedIds},
4774
+ * {@linkcode ModuleInfo.dynamicallyImportedIds | moduleInfo.dynamicallyImportedIds}
4775
+ * are complete and accurate. Note however that information about importing modules
4776
+ * may be incomplete as additional importers could be discovered later.
4777
+ * If you need this information, use the {@linkcode buildEnd} hook.
4778
+ *
4779
+ * @group Build Hooks
4780
+ */
3107
4781
  [DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
4782
+ /**
4783
+ * Called when Rolldown has finished bundling, but before Output Generation Hooks.
4784
+ * If an error occurred during the build, it is passed on to this hook.
4785
+ *
4786
+ * @group Build Hooks
4787
+ */
3108
4788
  [DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
4789
+ /**
4790
+ * Called initially each time {@linkcode RolldownBuild.generate | bundle.generate()} or
4791
+ * {@linkcode RolldownBuild.write | bundle.write()} is called.
4792
+ *
4793
+ * To get notified when generation has completed, use the {@linkcode generateBundle} and
4794
+ * {@linkcode renderError} hooks.
4795
+ *
4796
+ * This is the recommended hook to use when you need access to the output options passed to
4797
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
4798
+ * {@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.
4799
+ *
4800
+ * It also receives the input options passed to {@linkcode rolldown | rolldown()} so that
4801
+ * plugins that can be used as output plugins, i.e. plugins that only use generate phase hooks,
4802
+ * can get access to them.
4803
+ *
4804
+ * @group Output Generation Hooks
4805
+ */
3109
4806
  [DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
3110
- [DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | {
3111
- code: string;
4807
+ /**
4808
+ * Can be used to transform individual chunks. Called for each Rolldown output chunk file.
4809
+ *
4810
+ * 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).
4811
+ *
4812
+ * `chunk` is mutable and changes applied in this hook will propagate to other plugins and
4813
+ * to the generated bundle.
4814
+ * That means if you add or remove imports or exports in this hook, you should update
4815
+ * {@linkcode RenderedChunk.imports | imports}, {@linkcode RenderedChunk.importedBindings | importedBindings} and/or {@linkcode RenderedChunk.exports | exports} accordingly.
4816
+ *
4817
+ * @group Output Generation Hooks
4818
+ */
4819
+ [DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | RolldownMagicString | {
4820
+ code: string | RolldownMagicString;
3112
4821
  map?: SourceMapInput;
3113
4822
  };
4823
+ /**
4824
+ * Can be used to augment the hash of individual chunks. Called for each Rolldown output chunk.
4825
+ *
4826
+ * Returning a falsy value will not modify the hash.
4827
+ * Truthy values will be used as an additional source for hash calculation.
4828
+ *
4829
+ *
4830
+ *
4831
+ * @group Output Generation Hooks
4832
+ */
3114
4833
  [DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
4834
+ /**
4835
+ * Called when Rolldown encounters an error during
4836
+ * {@linkcode RolldownBuild.generate | bundle.generate()} or
4837
+ * {@linkcode RolldownBuild.write | bundle.write()}.
4838
+ *
4839
+ * To get notified when generation completes successfully, use the
4840
+ * {@linkcode generateBundle} hook.
4841
+ *
4842
+ * @group Output Generation Hooks
4843
+ */
3115
4844
  [DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
4845
+ /**
4846
+ * Called at the end of {@linkcode RolldownBuild.generate | bundle.generate()} or
4847
+ * immediately before the files are written in
4848
+ * {@linkcode RolldownBuild.write | bundle.write()}.
4849
+ *
4850
+ * To modify the files after they have been written, use the {@linkcode writeBundle} hook.
4851
+ *
4852
+ *
4853
+ *
4854
+ * @group Output Generation Hooks
4855
+ */
3116
4856
  [DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
4857
+ /**
4858
+ * Called only at the end of {@linkcode RolldownBuild.write | bundle.write()} once
4859
+ * all files have been written.
4860
+ *
4861
+ * @group Output Generation Hooks
4862
+ */
3117
4863
  [DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
3118
- [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
4864
+ /**
4865
+ * Can be used to clean up any external service that may be running.
4866
+ *
4867
+ * Rolldown's CLI will make sure this hook is called after each run, but it is the responsibility
4868
+ * of users of the JavaScript API to manually call
4869
+ * {@linkcode RolldownBuild.close | bundle.close()} once they are done generating bundles.
4870
+ * For that reason, any plugin relying on this feature should carefully mention this in
4871
+ * its documentation.
4872
+ *
4873
+ * If a plugin wants to retain resources across builds in watch mode, they can check for
4874
+ * {@linkcode PluginContextMeta.watchMode | this.meta.watchMode} in this hook and perform
4875
+ * the necessary cleanup for watch mode in closeWatcher.
4876
+ *
4877
+ * @group Output Generation Hooks
4878
+ */
4879
+ [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext, error?: Error) => void;
4880
+ /**
4881
+ * Notifies a plugin whenever Rolldown has detected a change to a monitored file in watch mode.
4882
+ *
4883
+ * If a build is currently running, this hook is called once the build finished.
4884
+ * It will be called once for every file that changed.
4885
+ *
4886
+ * This hook cannot be used by output plugins.
4887
+ *
4888
+ * If you need to be notified immediately when a file changed, you can use the {@linkcode WatcherOptions.onInvalidate | watch.onInvalidate} option.
4889
+ *
4890
+ * @group Build Hooks
4891
+ */
3119
4892
  [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
3120
4893
  event: ChangeEvent;
3121
4894
  }) => void;
4895
+ /**
4896
+ * Notifies a plugin when the watcher process will close so that all open resources can be closed too.
4897
+ *
4898
+ * This hook cannot be used by output plugins.
4899
+ *
4900
+ * @group Build Hooks
4901
+ */
3122
4902
  [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
3123
4903
  }
3124
4904
  type ChangeEvent = "create" | "update" | "delete";
3125
4905
  type PluginOrder = "pre" | "post" | null;
4906
+ /** @inline */
3126
4907
  type ObjectHookMeta = {
3127
4908
  order?: PluginOrder;
3128
4909
  };
4910
+ /**
4911
+ * A hook in a function or an object form with additional properties.
4912
+ *
4913
+ * @typeParam T - The type of the hook function.
4914
+ * @typeParam O - Additional properties that are specific to some hooks.
4915
+ *
4916
+ *
4917
+ *
4918
+ * @category Plugin APIs
4919
+ */
3129
4920
  type ObjectHook<T, O = {}> = T | ({
3130
4921
  handler: T;
3131
4922
  } & ObjectHookMeta & O);
3132
4923
  type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
4924
+ /** @category Plugin APIs */
3133
4925
  type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
3134
4926
  type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
3135
4927
  type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
3136
- type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
4928
+ interface AddonHooks {
4929
+ /**
4930
+ * A hook equivalent to {@linkcode OutputOptions.banner | output.banner} option.
4931
+ *
4932
+ * @group Output Generation Hooks
4933
+ */
4934
+ [DEFINED_HOOK_NAMES.banner]: AddonHook;
4935
+ /**
4936
+ * A hook equivalent to {@linkcode OutputOptions.footer | output.footer} option.
4937
+ *
4938
+ * @group Output Generation Hooks
4939
+ */
4940
+ [DEFINED_HOOK_NAMES.footer]: AddonHook;
4941
+ /**
4942
+ * A hook equivalent to {@linkcode OutputOptions.intro | output.intro} option.
4943
+ *
4944
+ * @group Output Generation Hooks
4945
+ */
4946
+ [DEFINED_HOOK_NAMES.intro]: AddonHook;
4947
+ /**
4948
+ * A hook equivalent to {@linkcode OutputOptions.outro | output.outro} option.
4949
+ *
4950
+ * @group Output Generation Hooks
4951
+ */
4952
+ [DEFINED_HOOK_NAMES.outro]: AddonHook;
4953
+ }
3137
4954
  type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
3138
- type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
3139
- type HookFilterExtension<K$1 extends keyof FunctionPluginHooks> = K$1 extends "transform" ? {
3140
- filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
3141
- } : K$1 extends "load" ? {
3142
- filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
3143
- } : K$1 extends "resolveId" ? {
3144
- filter?: TUnionWithTopLevelFilterExpressionArray<{
4955
+ /** @internal */
4956
+ type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | keyof AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
4957
+ /** @category Plugin APIs */
4958
+ type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
4959
+ filter?: HookFilter | TopLevelFilterExpression[];
4960
+ } : K extends "load" ? {
4961
+ filter?: Pick<HookFilter, "id"> | TopLevelFilterExpression[];
4962
+ } : K extends "resolveId" ? {
4963
+ filter?: {
3145
4964
  id?: GeneralHookFilter<RegExp>;
3146
- }>;
3147
- } : K$1 extends "renderChunk" ? {
3148
- filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
4965
+ } | TopLevelFilterExpression[];
4966
+ } : K extends "renderChunk" ? {
4967
+ filter?: Pick<HookFilter, "code"> | TopLevelFilterExpression[];
3149
4968
  } : {};
3150
4969
  type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
3151
4970
  /**
@@ -3157,10 +4976,25 @@ type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends Asyn
3157
4976
  } : {})> };
3158
4977
  type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
3159
4978
  type AddonHook = string | AddonHookFunction;
3160
- interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
4979
+ interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in keyof AddonHooks]: ObjectHook<AddonHook> }> {
4980
+ /** The name of the plugin, for use in error messages and logs. */
3161
4981
  name: string;
4982
+ /** The version of the plugin, for use in inter-plugin communication scenarios. */
4983
+ version?: string;
3162
4984
  }
4985
+ /**
4986
+ * The Plugin interface.
4987
+ *
4988
+ * See [Plugin API document](https://rolldown.rs/apis/plugin-api) for details.
4989
+ *
4990
+ * @typeParam A - The type of the {@link Plugin.api | api} property.
4991
+ *
4992
+ * @category Plugin APIs
4993
+ */
3163
4994
  interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
4995
+ /**
4996
+ * Used for inter-plugin communication.
4997
+ */
3164
4998
  api?: A;
3165
4999
  }
3166
5000
  type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
@@ -3171,211 +5005,154 @@ type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
3171
5005
  type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | {
3172
5006
  name: string;
3173
5007
  } | false | RolldownOutputPluginOption[]>; //#endregion
3174
- //#region src/options/generated/checks-options.d.ts
3175
- interface ChecksOptions {
5008
+ //#region src/options/input-options.d.ts
5009
+ /**
5010
+ * @inline
5011
+ */
5012
+ type InputOption = string | string[] | Record<string, string>;
5013
+ /**
5014
+ * @param id The id of the module being checked.
5015
+ * @param parentId The id of the module importing the id being checked.
5016
+ * @param isResolved Whether the id has been resolved.
5017
+ * @returns Whether the module should be treated as external.
5018
+ */
5019
+ type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
5020
+ /** @inline */
5021
+ type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
5022
+ type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset" | "copy">;
5023
+ interface WatcherFileWatcherOptions {
3176
5024
  /**
3177
- * Whether to emit warning when detecting circular dependency
5025
+ * Whether to use polling-based file watching instead of native OS events.
5026
+ *
5027
+ * Polling is useful for environments where native FS events are unreliable,
5028
+ * such as network mounts, Docker volumes, or WSL2.
5029
+ *
3178
5030
  * @default false
3179
5031
  */
3180
- circularDependency?: boolean;
3181
- /**
3182
- * Whether to emit warning when detecting eval
3183
- * @default true
3184
- */
3185
- eval?: boolean;
3186
- /**
3187
- * Whether to emit warning when detecting missing global name
3188
- * @default true
3189
- */
3190
- missingGlobalName?: boolean;
3191
- /**
3192
- * Whether to emit warning when detecting missing name option for iife export
3193
- * @default true
3194
- */
3195
- missingNameOptionForIifeExport?: boolean;
3196
- /**
3197
- * Whether to emit warning when detecting mixed exports
3198
- * @default true
3199
- */
3200
- mixedExports?: boolean;
3201
- /**
3202
- * Whether to emit warning when detecting unresolved entry
3203
- * @default true
3204
- */
3205
- unresolvedEntry?: boolean;
3206
- /**
3207
- * Whether to emit warning when detecting unresolved import
3208
- * @default true
3209
- */
3210
- unresolvedImport?: boolean;
3211
- /**
3212
- * Whether to emit warning when detecting filename conflict
3213
- * @default true
3214
- */
3215
- filenameConflict?: boolean;
3216
- /**
3217
- * Whether to emit warning when detecting common js variable in esm
3218
- * @default true
3219
- */
3220
- commonJsVariableInEsm?: boolean;
3221
- /**
3222
- * Whether to emit warning when detecting import is undefined
3223
- * @default true
3224
- */
3225
- importIsUndefined?: boolean;
3226
- /**
3227
- * Whether to emit warning when detecting empty import meta
3228
- * @default true
3229
- */
3230
- emptyImportMeta?: boolean;
5032
+ usePolling?: boolean;
3231
5033
  /**
3232
- * Whether to emit warning when detecting cannot call namespace
3233
- * @default true
5034
+ * Interval between each poll in milliseconds.
5035
+ *
5036
+ * This option is only used when {@linkcode usePolling} is `true`.
5037
+ *
5038
+ * @default 100
3234
5039
  */
3235
- cannotCallNamespace?: boolean;
5040
+ pollInterval?: number;
3236
5041
  /**
3237
- * Whether to emit warning when detecting configuration field conflict
3238
- * @default true
5042
+ * Whether to compare file contents for poll-based watchers.
5043
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
5044
+ *
5045
+ * This option is only used when {@linkcode usePolling} is `true`.
5046
+ *
5047
+ * @default false
3239
5048
  */
3240
- configurationFieldConflict?: boolean;
5049
+ compareContentsForPolling?: boolean;
3241
5050
  /**
3242
- * Whether to emit warning when detecting prefer builtin feature
3243
- * @default true
5051
+ * Whether to use debounced event delivery at the filesystem level.
5052
+ * This coalesces rapid filesystem events before they reach the build coordinator.
5053
+ * @default false
3244
5054
  */
3245
- preferBuiltinFeature?: boolean;
5055
+ useDebounce?: boolean;
3246
5056
  /**
3247
- * Whether to emit warning when detecting could not clean directory
3248
- * @default true
5057
+ * Debounce delay in milliseconds for fs-level debounced watchers.
5058
+ * Only used when {@linkcode useDebounce} is `true`.
5059
+ * @default 10
3249
5060
  */
3250
- couldNotCleanDirectory?: boolean;
5061
+ debounceDelay?: number;
3251
5062
  /**
3252
- * Whether to emit warning when detecting plugin timings
3253
- * @default true
5063
+ * Tick rate in milliseconds for the debouncer's internal polling.
5064
+ * Only used when {@linkcode useDebounce} is `true`.
5065
+ * When undefined, auto-selects 1/4 of debounceDelay.
3254
5066
  */
3255
- pluginTimings?: boolean;
3256
- } //#endregion
3257
- //#region src/options/transform-options.d.ts
3258
- interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
5067
+ debounceTickRate?: number;
5068
+ }
5069
+ interface WatcherOptions {
3259
5070
  /**
3260
- * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
3261
- *
3262
- * # Examples
3263
- *
3264
- * - Replace the global variable `IS_PROD` with `true`
3265
- *
3266
- * ```js rolldown.config.js
3267
- * export default defineConfig({ transform: { define: { IS_PROD: 'true' } } })
3268
- * ```
3269
- *
3270
- * Result:
3271
- *
3272
- * ```js
3273
- * // Input
3274
- * if (IS_PROD) {
3275
- * console.log('Production mode')
3276
- * }
3277
- *
3278
- * // After bundling
3279
- * if (true) {
3280
- * console.log('Production mode')
3281
- * }
3282
- * ```
3283
- *
3284
- * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
3285
- *
3286
- * ```js rolldown.config.js
3287
- * export default defineConfig({ transform: { define: { 'process.env.NODE_ENV': "'production'" } } })
3288
- * ```
3289
- *
3290
- * Result:
3291
- *
3292
- * ```js
3293
- * // Input
3294
- * if (process.env.NODE_ENV === 'production') {
3295
- * console.log('Production mode')
3296
- * }
3297
- *
3298
- * // After bundling
3299
- * if ('production' === 'production') {
3300
- * console.log('Production mode')
3301
- * }
3302
- *
3303
- * ```
5071
+ * Whether to skip the {@linkcode RolldownBuild.write | bundle.write()} step when a rebuild is triggered.
5072
+ * @default false
3304
5073
  */
3305
- define?: Record<string, string>;
5074
+ skipWrite?: boolean;
3306
5075
  /**
3307
- * Inject import statements on demand.
3308
- *
3309
- * The API is aligned with `@rollup/plugin-inject`.
3310
- *
3311
- * ## Supported patterns
3312
- * ```js
3313
- * {
3314
- * // import { Promise } from 'es6-promise'
3315
- * Promise: ['es6-promise', 'Promise'],
3316
- *
3317
- * // import { Promise as P } from 'es6-promise'
3318
- * P: ['es6-promise', 'Promise'],
5076
+ * Configures how long Rolldown will wait for further changes until it triggers
5077
+ * a rebuild in milliseconds.
3319
5078
  *
3320
- * // import $ from 'jquery'
3321
- * $: 'jquery',
5079
+ * Even if this value is set to 0, there's a small debounce timeout configured
5080
+ * in the file system watcher. Setting this to a value greater than 0 will mean
5081
+ * that Rolldown will only trigger a rebuild if there was no change for the
5082
+ * configured number of milliseconds. If several configurations are watched,
5083
+ * Rolldown will use the largest configured build delay.
3322
5084
  *
3323
- * // import * as fs from 'node:fs'
3324
- * fs: ['node:fs', '*'],
5085
+ * This option is useful if you use a tool that regenerates multiple source files
5086
+ * very slowly. Rebuilding immediately after the first change could cause Rolldown
5087
+ * to generate a broken intermediate build before generating a successful final
5088
+ * build, which can be confusing and distracting.
3325
5089
  *
3326
- * // Inject shims for property access pattern
3327
- * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
3328
- * }
3329
- * ```
5090
+ * @default 0
3330
5091
  */
3331
- inject?: Record<string, string | [string, string]>;
5092
+ buildDelay?: number;
3332
5093
  /**
3333
- * Remove labeled statements with these label names.
3334
- *
3335
- * Labeled statements are JavaScript statements prefixed with a label identifier.
3336
- * This option allows you to strip specific labeled statements from the output,
3337
- * which is useful for removing debug-only code in production builds.
5094
+ * File watcher options for configuring how file changes are detected.
5095
+ */
5096
+ watcher?: WatcherFileWatcherOptions;
5097
+ /**
5098
+ * @deprecated Use {@linkcode watcher} instead.
5099
+ */
5100
+ notify?: WatcherFileWatcherOptions;
5101
+ /**
5102
+ * Filter to limit the file-watching to certain files.
3338
5103
  *
3339
- * ## Example
5104
+ * Strings are treated as glob patterns.
5105
+ * Note that this only filters the module graph but does not allow adding
5106
+ * additional watch files.
3340
5107
  *
3341
- * ```js rolldown.config.js
3342
- * export default defineConfig({ transform: { dropLabels: ['DEBUG', 'DEV'] } })
5108
+ * @example
5109
+ * ```js
5110
+ * export default defineConfig({
5111
+ * watch: {
5112
+ * include: 'src/**',
5113
+ * },
5114
+ * })
3343
5115
  * ```
5116
+ * @default []
5117
+ */
5118
+ include?: StringOrRegExp | StringOrRegExp[];
5119
+ /**
5120
+ * Filter to prevent files from being watched.
3344
5121
  *
3345
- * Result:
5122
+ * Strings are treated as glob patterns.
3346
5123
  *
5124
+ * @example
3347
5125
  * ```js
3348
- * // Input
3349
- * DEBUG: console.log('Debug info');
3350
- * DEV: {
3351
- * console.log('Development mode');
3352
- * }
3353
- * console.log('Production code');
3354
- *
3355
- * // After bundling
3356
- * console.log('Production code');
5126
+ * export default defineConfig({
5127
+ * watch: {
5128
+ * exclude: 'node_modules/**',
5129
+ * },
5130
+ * })
3357
5131
  * ```
5132
+ * @default []
3358
5133
  */
3359
- dropLabels?: string[];
3360
- jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
3361
- } //#endregion
3362
- //#region src/options/input-options.d.ts
3363
- type InputOption = string | string[] | Record<string, string>;
3364
- type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
3365
- type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
3366
- type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
3367
- interface WatcherOptions {
3368
- skipWrite?: boolean;
3369
- buildDelay?: number;
3370
- notify?: {
3371
- pollInterval?: number;
3372
- compareContents?: boolean;
3373
- };
3374
- include?: StringOrRegExp | StringOrRegExp[];
3375
5134
  exclude?: StringOrRegExp | StringOrRegExp[];
5135
+ /**
5136
+ * An optional function that will be called immediately every time
5137
+ * a module changes that is part of the build.
5138
+ *
5139
+ * This is different from the {@linkcode Plugin.watchChange | watchChange} plugin hook, which is
5140
+ * only called once the running build has finished. This may for
5141
+ * instance be used to prevent additional steps from being performed
5142
+ * if we know another build will be started anyway once the current
5143
+ * build finished. This callback may be called multiple times per
5144
+ * build as it tracks every change.
5145
+ *
5146
+ * @param id The id of the changed module.
5147
+ */
3376
5148
  onInvalidate?: (id: string) => void;
5149
+ /**
5150
+ * Whether to clear the screen when a rebuild is triggered.
5151
+ * @default true
5152
+ */
3377
5153
  clearScreen?: boolean;
3378
5154
  }
5155
+ /** @inline */
3379
5156
  type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
3380
5157
  type DevModeOptions = boolean | {
3381
5158
  host?: string;
@@ -3389,7 +5166,8 @@ type OptimizationOptions = {
3389
5166
  *
3390
5167
  * When enabled, constant values from imported modules will be inlined at their usage sites,
3391
5168
  * potentially reducing bundle size and improving runtime performance by eliminating variable lookups.
3392
- * **options**:
5169
+ *
5170
+ * **Options:**
3393
5171
  * - `true`: equivalent to `{ mode: 'all', pass: 1 }`, enabling constant inlining for all eligible constants with a single pass.
3394
5172
  * - `false`: Disable constant inlining
3395
5173
  * - `{ mode: 'smart' | 'all', pass?: number }`:
@@ -3403,7 +5181,7 @@ type OptimizationOptions = {
3403
5181
  * - `mode: 'all'`: Inline all imported constants wherever they are used.
3404
5182
  * - `pass`: Number of passes to perform for inlining constants.
3405
5183
  *
3406
- * **example**
5184
+ * @example
3407
5185
  * ```js
3408
5186
  * // Input files:
3409
5187
  * // constants.js
@@ -3421,34 +5199,114 @@ type OptimizationOptions = {
3421
5199
  * console.log(API_URL);
3422
5200
  * ```
3423
5201
  *
3424
- * @default false
5202
+ * @default { mode: 'smart', pass: 1 }
3425
5203
  */
3426
5204
  inlineConst?: boolean | {
3427
5205
  mode?: "all" | "smart";
3428
5206
  pass?: number;
3429
5207
  };
3430
5208
  /**
3431
- * Use PIFE pattern for module wrappers
5209
+ * Use PIFE pattern for module wrappers.
5210
+ *
5211
+ * Enabling this option improves the start up performance of the generated bundle with the cost of a slight increase in bundle size.
5212
+ *
5213
+ *
5214
+ *
5215
+ * @default true
3432
5216
  */
3433
5217
  pifeForModuleWrappers?: boolean;
3434
5218
  };
5219
+ /** @inline */
3435
5220
  type AttachDebugOptions = "none" | "simple" | "full";
5221
+ /** @inline */
3436
5222
  type ChunkModulesOrder = "exec-order" | "module-id";
3437
- type OnLogFunction = (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
3438
- type OnwarnFunction = (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
5223
+ /** @inline */
5224
+ type OnLogFunction = (level: LogLevel, log: RolldownLog, defaultHandler: LogOrStringHandler) => void;
5225
+ /** @inline */
5226
+ type OnwarnFunction = (warning: RolldownLog, defaultHandler: (warning: RolldownLogWithString | (() => RolldownLogWithString)) => void) => void;
3439
5227
  interface InputOptions {
5228
+ /**
5229
+ * Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the {@linkcode cwd} option.
5230
+ *
5231
+ */
3440
5232
  input?: InputOption;
5233
+ /**
5234
+ * The list of plugins to use.
5235
+ *
5236
+ * 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.
5237
+ *
5238
+ * See [Plugin API document](https://rolldown.rs/apis/plugin-api) for more details about creating plugins.
5239
+ *
5240
+ * @example
5241
+ * ```js
5242
+ * import { defineConfig } from 'rolldown'
5243
+ *
5244
+ * export default defineConfig({
5245
+ * plugins: [
5246
+ * examplePlugin1(),
5247
+ * // Conditional plugins
5248
+ * process.env.ENV1 && examplePlugin2(),
5249
+ * // Nested plugins arrays are flattened
5250
+ * [examplePlugin3(), examplePlugin4()],
5251
+ * ]
5252
+ * })
5253
+ * ```
5254
+ */
3441
5255
  plugins?: RolldownPluginOption;
5256
+ /**
5257
+ * Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output.
5258
+ *
5259
+ */
3442
5260
  external?: ExternalOption;
5261
+ /**
5262
+ * Options for built-in module resolution feature.
5263
+ */
3443
5264
  resolve?: {
3444
5265
  /**
5266
+ * Substitute one package for another.
5267
+ *
5268
+ * 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.
5269
+ *
5270
+ * @example
5271
+ * ```js
5272
+ * resolve: {
5273
+ * alias: {
5274
+ * '@': '/src',
5275
+ * 'utils': './src/utils',
5276
+ * }
5277
+ * }
5278
+ * ```
3445
5279
  * > [!WARNING]
3446
- * > `resolve.alias` will not call `resolveId` hooks of other plugin.
5280
+ * > `resolve.alias` will not call [`resolveId`](/reference/Interface.Plugin#resolveid) hooks of other plugin.
3447
5281
  * > If you want to call `resolveId` hooks of other plugin, use `viteAliasPlugin` from `rolldown/experimental` instead.
3448
5282
  * > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
3449
5283
  */
3450
5284
  alias?: Record<string, string[] | string | false>;
5285
+ /**
5286
+ * Fields in package.json to check for aliased paths.
5287
+ *
5288
+ * This option is expected to be used for `browser` field support.
5289
+ *
5290
+ * @default
5291
+ * - `[['browser']]` for `browser` platform
5292
+ * - `[]` for other platforms
5293
+ */
3451
5294
  aliasFields?: string[][];
5295
+ /**
5296
+ * Condition names to use when resolving exports in package.json.
5297
+ *
5298
+ * @default
5299
+ * Defaults based on platform and import kind:
5300
+ * - `browser` platform
5301
+ * - `["import", "browser", "default"]` for import statements
5302
+ * - `["require", "browser", "default"]` for require() calls
5303
+ * - `node` platform
5304
+ * - `["import", "node", "default"]` for import statements
5305
+ * - `["require", "node", "default"]` for require() calls
5306
+ * - `neutral` platform
5307
+ * - `["import", "default"]` for import statements
5308
+ * - `["require", "default"]` for require() calls
5309
+ */
3452
5310
  conditionNames?: string[];
3453
5311
  /**
3454
5312
  * Map of extensions to alternative extensions.
@@ -3457,17 +5315,52 @@ interface InputOptions {
3457
5315
  * You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
3458
5316
  */
3459
5317
  extensionAlias?: Record<string, string[]>;
5318
+ /**
5319
+ * Fields in package.json to check for exports.
5320
+ *
5321
+ * @default `[['exports']]`
5322
+ */
3460
5323
  exportsFields?: string[][];
5324
+ /**
5325
+ * Extensions to try when resolving files. These are tried in order from first to last.
5326
+ *
5327
+ * @default `['.tsx', '.ts', '.jsx', '.js', '.json']`
5328
+ */
3461
5329
  extensions?: string[];
5330
+ /**
5331
+ * Fields in package.json to check for entry points.
5332
+ *
5333
+ * @default
5334
+ * Defaults based on platform:
5335
+ * - `node` platform: `['main', 'module']`
5336
+ * - `browser` platform: `['browser', 'module', 'main']`
5337
+ * - `neutral` platform: `[]`
5338
+ */
3462
5339
  mainFields?: string[];
5340
+ /**
5341
+ * Filenames to try when resolving directories.
5342
+ * @default ['index']
5343
+ */
3463
5344
  mainFiles?: string[];
5345
+ /**
5346
+ * Directories to search for modules.
5347
+ * @default ['node_modules']
5348
+ */
3464
5349
  modules?: string[];
5350
+ /**
5351
+ * Whether to follow symlinks when resolving modules.
5352
+ * @default true
5353
+ */
3465
5354
  symlinks?: boolean;
3466
5355
  /**
3467
- * @deprecated Use the top-level `tsconfig` option instead.
5356
+ * @deprecated Use the top-level {@linkcode tsconfig} option instead.
3468
5357
  */
3469
5358
  tsconfigFilename?: string;
3470
5359
  };
5360
+ /**
5361
+ * The working directory to use when resolving relative paths in the configuration.
5362
+ * @default process.cwd()
5363
+ */
3471
5364
  cwd?: string;
3472
5365
  /**
3473
5366
  * Expected platform where the code run.
@@ -3478,57 +5371,155 @@ interface InputOptions {
3478
5371
  * - The conditions setting does not automatically include any platform-specific values.
3479
5372
  *
3480
5373
  * @default
3481
- * - 'node' if the format is 'cjs'
3482
- * - 'browser' for other formats
5374
+ * - `'node'` if the format is `'cjs'`
5375
+ * - `'browser'` for other formats
5376
+ *
3483
5377
  */
3484
5378
  platform?: "node" | "browser" | "neutral";
5379
+ /**
5380
+ * When `true`, creates shim variables for missing exports instead of throwing an error.
5381
+ * @default false
5382
+ *
5383
+ */
3485
5384
  shimMissingExports?: boolean;
5385
+ /**
5386
+ * Controls tree-shaking (dead code elimination).
5387
+ *
5388
+ * See the [In-depth Dead Code Elimination Guide](https://rolldown.rs/in-depth/dead-code-elimination) for more details.
5389
+ *
5390
+ * When `false`, tree-shaking will be disabled.
5391
+ * When `true`, it is equivalent to setting each options to the default value.
5392
+ *
5393
+ * @default true
5394
+ */
3486
5395
  treeshake?: boolean | TreeshakingOptions;
5396
+ /**
5397
+ * Controls the verbosity of console logging during the build.
5398
+ *
5399
+ *
5400
+ *
5401
+ * @default 'info'
5402
+ */
3487
5403
  logLevel?: LogLevelOption;
5404
+ /**
5405
+ * A function that intercepts log messages. If not supplied, logs are printed to the console.
5406
+ *
5407
+ *
5408
+ *
5409
+ * @example
5410
+ * ```js
5411
+ * export default defineConfig({
5412
+ * onLog(level, log, defaultHandler) {
5413
+ * if (log.code === 'CIRCULAR_DEPENDENCY') {
5414
+ * return; // Ignore circular dependency warnings
5415
+ * }
5416
+ * if (level === 'warn') {
5417
+ * defaultHandler('error', log); // turn other warnings into errors
5418
+ * } else {
5419
+ * defaultHandler(level, log); // otherwise, just print the log
5420
+ * }
5421
+ * }
5422
+ * })
5423
+ * ```
5424
+ */
3488
5425
  onLog?: OnLogFunction;
5426
+ /**
5427
+ * A function that will intercept warning messages.
5428
+ *
5429
+ *
5430
+ *
5431
+ * @deprecated
5432
+ * This is a legacy API. Consider using {@linkcode onLog} instead for better control over all log types.
5433
+ *
5434
+ *
5435
+ */
3489
5436
  onwarn?: OnwarnFunction;
5437
+ /**
5438
+ * Maps file patterns to module types, controlling how files are processed.
5439
+ *
5440
+ * 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.
5441
+ *
5442
+ * See [the In-Depth Guide](https://rolldown.rs/in-depth/module-types) for more details.
5443
+ *
5444
+ * @example
5445
+ * ```js
5446
+ * import { defineConfig } from 'rolldown'
5447
+ *
5448
+ * export default defineConfig({
5449
+ * moduleTypes: {
5450
+ * '.frag': 'text',
5451
+ * }
5452
+ * })
5453
+ * ```
5454
+ */
3490
5455
  moduleTypes?: ModuleTypes;
5456
+ /**
5457
+ * Experimental features that may change in future releases and can introduce behavior change without a major version bump.
5458
+ * @experimental
5459
+ */
3491
5460
  experimental?: {
3492
5461
  /**
3493
- * Lets modules be executed in the order they are declared.
5462
+ * Enable Vite compatible mode.
5463
+ * @default false
5464
+ * @hidden This option is only meant to be used by Vite. It is not recommended to use this option directly.
5465
+ */
5466
+ viteMode?: boolean;
5467
+ /**
5468
+ * When enabled, `new URL()` calls will be transformed to a stable asset URL which includes the updated name and content hash.
5469
+ * It is necessary to pass `import.meta.url` as the second argument to the
5470
+ * `new URL` constructor, otherwise no transform will be applied.
5471
+ * :::warning
5472
+ * 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.
3494
5473
  *
3495
- * - Type: `boolean`
3496
- * - Default: `false`
5474
+ * The expected behavior for JS/TS files is still being discussed and may
5475
+ * change in future releases. See [#7258](https://github.com/rolldown/rolldown/issues/7258) for more context.
5476
+ * :::
5477
+ * @example
5478
+ * ```js
5479
+ * // main.js
5480
+ * const url = new URL('./styles.css', import.meta.url);
5481
+ * console.log(url);
3497
5482
  *
3498
- * This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
5483
+ * // Example output after bundling WITHOUT the option (default)
5484
+ * const url = new URL('./styles.css', import.meta.url);
5485
+ * console.log(url);
3499
5486
  *
3500
- * > [!WARNING]
3501
- * > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
5487
+ * // Example output after bundling WITH `experimental.resolveNewUrlToAsset` set to `true`
5488
+ * const url = new URL('assets/styles-CjdrdY7X.css', import.meta.url);
5489
+ * console.log(url);
5490
+ * ```
5491
+ * @default false
3502
5492
  */
3503
- strictExecutionOrder?: boolean;
3504
- disableLiveBindings?: boolean;
3505
- viteMode?: boolean;
3506
5493
  resolveNewUrlToAsset?: boolean;
5494
+ /**
5495
+ * Dev mode related options.
5496
+ * @hidden not ready for public usage yet
5497
+ */
3507
5498
  devMode?: DevModeOptions;
3508
5499
  /**
3509
- * Control which order should use when rendering modules in chunk
3510
- *
3511
- * - Type: `'exec-order' | 'module-id'
3512
- * - Default: `'exec-order'`
5500
+ * Control which order should be used when rendering modules in a chunk.
3513
5501
  *
5502
+ * Available options:
3514
5503
  * - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
3515
5504
  * - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
5505
+ *
3516
5506
  * > [!NOTE]
3517
- * > 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).
5507
+ * > 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).
5508
+ *
5509
+ * @default 'exec-order'
3518
5510
  */
3519
5511
  chunkModulesOrder?: ChunkModulesOrder;
3520
5512
  /**
3521
5513
  * Attach debug information to the output bundle.
3522
5514
  *
3523
- * - Type: `'none' | 'simple' | 'full'`
3524
- * - Default: `'simple'`
3525
- *
5515
+ * Available modes:
3526
5516
  * - `none`: No debug information is attached.
3527
5517
  * - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
3528
5518
  * - `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.
3529
5519
  *
3530
- * > [!WARNING]
3531
- * > You shouldn't use `full` in the production build.
5520
+ * @default 'simple'
5521
+ *
5522
+ *
3532
5523
  */
3533
5524
  attachDebugInfo?: AttachDebugOptions;
3534
5525
  /**
@@ -3542,8 +5533,7 @@ interface InputOptions {
3542
5533
  * (default `"/"`) can be applied to all paths. The resulting JSON is a valid import map and can be
3543
5534
  * directly injected into HTML via `<script type="importmap">`.
3544
5535
  *
3545
- * Example configuration snippet:
3546
- *
5536
+ * @example
3547
5537
  * ```js
3548
5538
  * {
3549
5539
  * experimental: {
@@ -3575,31 +5565,35 @@ interface InputOptions {
3575
5565
  * }
3576
5566
  * ```
3577
5567
  *
3578
- * > [!NOTE]
5568
+ * > [!TIP]
3579
5569
  * > 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)
5570
+ *
5571
+ * @default false
3580
5572
  */
3581
5573
  chunkImportMap?: boolean | {
3582
5574
  baseUrl?: string;
3583
5575
  fileName?: string;
3584
5576
  };
5577
+ /**
5578
+ * Enable on-demand wrapping of modules.
5579
+ * @default false
5580
+ * @hidden not ready for public usage yet
5581
+ */
3585
5582
  onDemandWrapping?: boolean;
3586
5583
  /**
3587
- * Required to be used with `watch` mode.
5584
+ * Enable incremental build support. Required to be used with `watch` mode.
5585
+ * @default false
3588
5586
  */
3589
5587
  incrementalBuild?: boolean;
3590
- transformHiresSourcemap?: boolean | "boundary";
3591
5588
  /**
3592
5589
  * Use native Rust implementation of MagicString for source map generation.
3593
5590
  *
3594
- * - Type: `boolean`
3595
- * - Default: `false`
3596
- *
3597
5591
  * [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
3598
5592
  * for string manipulation and source map generation. When enabled, rolldown will use a native Rust
3599
5593
  * implementation of MagicString instead of the JavaScript version, providing significantly better performance
3600
5594
  * during source map generation and code transformation.
3601
5595
  *
3602
- * ## Benefits
5596
+ * **Benefits**
3603
5597
  *
3604
5598
  * - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
3605
5599
  * especially for large codebases with extensive source maps.
@@ -3608,8 +5602,7 @@ interface InputOptions {
3608
5602
  * reduce overall build times when working with JavaScript transform hooks.
3609
5603
  * - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
3610
5604
  *
3611
- * ## Example
3612
- *
5605
+ * @example
3613
5606
  * ```js
3614
5607
  * export default {
3615
5608
  * experimental: {
@@ -3625,14 +5618,38 @@ interface InputOptions {
3625
5618
  * > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
3626
5619
  * > implementation, there may be edge cases. Please report any discrepancies you encounter.
3627
5620
  * > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
5621
+ * @default false
3628
5622
  */
3629
5623
  nativeMagicString?: boolean;
5624
+ /**
5625
+ * Control whether to optimize chunks by allowing entry chunks to have different exports than the underlying entry module.
5626
+ * This optimization can reduce the number of generated chunks.
5627
+ *
5628
+ * When enabled, rolldown will try to insert common modules directly into existing chunks rather than creating
5629
+ * separate chunks for them, which can result in fewer output files and better performance.
5630
+ *
5631
+ * This optimization is automatically disabled when any module uses top-level await (TLA) or contains TLA dependencies,
5632
+ * as it could affect execution order guarantees.
5633
+ *
5634
+ * @default true
5635
+ */
5636
+ chunkOptimization?: boolean;
5637
+ /**
5638
+ * Control whether to enable lazy barrel optimization.
5639
+ *
5640
+ * Lazy barrel optimization avoids compiling unused re-export modules in side-effect-free barrel modules,
5641
+ * significantly improving build performance for large codebases with many barrel modules.
5642
+ *
5643
+ * @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
5644
+ * @default false
5645
+ */
5646
+ lazyBarrel?: boolean;
3630
5647
  };
3631
5648
  /**
3632
5649
  * Configure how the code is transformed. This process happens after the `transform` hook.
3633
5650
  *
3634
- * To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
3635
- *
5651
+ * @example
5652
+ * **Enable legacy decorators**
3636
5653
  * ```js
3637
5654
  * export default defineConfig({
3638
5655
  * transform: {
@@ -3642,41 +5659,75 @@ interface InputOptions {
3642
5659
  * },
3643
5660
  * })
3644
5661
  * ```
5662
+ * Note that if you have correct `tsconfig.json` file, Rolldown will automatically detect and enable legacy decorators support.
5663
+ *
3645
5664
  *
3646
- * For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
3647
5665
  */
3648
5666
  transform?: TransformOptions;
5667
+ /**
5668
+ * Watch mode related options.
5669
+ *
5670
+ * These options only take effect when running with the [`--watch`](/apis/cli#w-watch) flag, or using {@linkcode watch | watch()} API.
5671
+ *
5672
+ *
5673
+ *
5674
+ * @experimental
5675
+ */
3649
5676
  watch?: WatcherOptions | false;
5677
+ /**
5678
+ * Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
5679
+ */
3650
5680
  checks?: ChecksOptions;
5681
+ /**
5682
+ * Determines if absolute external paths should be converted to relative paths in the output.
5683
+ *
5684
+ * 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.
5685
+ *
5686
+ *
5687
+ */
3651
5688
  makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
3652
- debug?: {
5689
+ /**
5690
+ * Devtools integration options.
5691
+ * @experimental
5692
+ */
5693
+ devtools?: {
3653
5694
  sessionId?: string;
3654
5695
  };
3655
- preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
3656
- optimization?: OptimizationOptions;
3657
- context?: string;
3658
5696
  /**
3659
- * Configures TypeScript configuration file resolution and usage.
5697
+ * Controls how entry chunk exports are preserved.
3660
5698
  *
3661
- * ## Options
5699
+ * 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.
3662
5700
  *
3663
- * - `true`: Auto-discovery mode (similar to Vite). For each module, both resolver and transformer
3664
- * will find the nearest tsconfig.json. If the tsconfig has `references`, the file extension is
3665
- * allowed, and the tsconfig's `include`/`exclude` patterns don't match the file, the referenced
3666
- * tsconfigs will be searched for a match. Falls back to the original tsconfig if no match is found.
3667
- * - `string`: Path to a specific tsconfig.json file (relative to cwd or absolute path).
5701
+ * @default `'exports-only'`
3668
5702
  *
3669
- * ## What's used from tsconfig
3670
- *
3671
- * - **Resolver**: Uses `compilerOptions.paths` and `compilerOptions.baseUrl` for path mapping
3672
- * - **Transformer**: Uses select compiler options (jsx, decorators, typescript, etc.)
5703
+ */
5704
+ preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
5705
+ /**
5706
+ * Configure optimization features for the bundler.
5707
+ */
5708
+ optimization?: OptimizationOptions;
5709
+ /**
5710
+ * The value of `this` at the top level of each module. **Normally, you don't need to set this option.**
5711
+ * @default undefined
5712
+ * @example
5713
+ * **Set custom context**
5714
+ * ```js
5715
+ * export default {
5716
+ * context: 'globalThis',
5717
+ * output: {
5718
+ * format: 'iife',
5719
+ * },
5720
+ * };
5721
+ * ```
3673
5722
  *
3674
- * > [!NOTE]
3675
- * > Priority: Top-level `transform` options always take precedence over tsconfig settings.
5723
+ */
5724
+ context?: string;
5725
+ /**
5726
+ * Configures TypeScript configuration file resolution and usage.
3676
5727
  *
3677
- * @default undefined (no tsconfig resolution)
5728
+ * @default true
3678
5729
  */
3679
- tsconfig?: true | string;
5730
+ tsconfig?: boolean | string;
3680
5731
  } //#endregion
3681
5732
  //#region src/types/rolldown-options.d.ts
3682
5733
  //#endregion