rolldown 1.0.0-beta.42 → 1.0.0-beta.44

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.
@@ -45,13 +45,30 @@ interface CompressOptions {
45
45
  */
46
46
  dropDebugger?: boolean;
47
47
  /**
48
- * Drop unreferenced functions and variables.
48
+ * Pass `true` to drop unreferenced functions and variables.
49
49
  *
50
- * Simple direct variable assignments do not count as references unless set to "keep_assign".
50
+ * Simple direct variable assignments do not count as references unless set to `keep_assign`.
51
+ * @default true
51
52
  */
52
- unused?: true | false | 'keep_assign';
53
+ unused?: boolean | 'keep_assign';
53
54
  /** Keep function / class names. */
54
55
  keepNames?: CompressOptionsKeepNames;
56
+ /**
57
+ * Join consecutive var, let and const statements.
58
+ *
59
+ * @default true
60
+ */
61
+ joinVars?: boolean;
62
+ /**
63
+ * Join consecutive simple statements using the comma operator.
64
+ *
65
+ * `a; b` -> `a, b`
66
+ *
67
+ * @default true
68
+ */
69
+ sequences?: boolean;
70
+ /** Limit the maximum number of iterations for debugging purpose. */
71
+ maxIterations?: number;
55
72
  }
56
73
  interface CompressOptionsKeepNames {
57
74
  /**
@@ -1164,9 +1181,21 @@ declare class BindingBundlerImpl {
1164
1181
  get closed(): boolean;
1165
1182
  getWatchFiles(): Promise<Array<string>>;
1166
1183
  }
1167
- declare class BindingClientHmrUpdate {
1168
- get clientId(): string;
1169
- get update(): BindingHmrUpdate;
1184
+ declare class BindingMagicString {
1185
+ constructor(source: string);
1186
+ replace(from: string, to: string): void;
1187
+ replaceAll(from: string, to: string): void;
1188
+ prepend(content: string): void;
1189
+ append(content: string): void;
1190
+ prependLeft(index: number, content: string): void;
1191
+ prependRight(index: number, content: string): void;
1192
+ appendLeft(index: number, content: string): void;
1193
+ appendRight(index: number, content: string): void;
1194
+ overwrite(start: number, end: number, content: string): void;
1195
+ toString(): string;
1196
+ hasChanged(): boolean;
1197
+ length(): number;
1198
+ isEmpty(): boolean;
1170
1199
  }
1171
1200
  declare class BindingOutputAsset {
1172
1201
  get fileName(): string;
@@ -1212,6 +1241,9 @@ declare class BindingRenderedModule {
1212
1241
  get code(): string | null;
1213
1242
  get renderedExports(): Array<string>;
1214
1243
  }
1244
+ declare class BindingUrlResolver {
1245
+ call(url: string, importer?: string): Promise<[string, string | undefined]>;
1246
+ }
1215
1247
  declare class BindingWatcherChangeData {
1216
1248
  path: string;
1217
1249
  kind: string;
@@ -1224,15 +1256,15 @@ declare class BindingWatcherEvent {
1224
1256
  bundleErrorData(): BindingBundleErrorEventData;
1225
1257
  }
1226
1258
  interface BindingAssetPluginConfig {
1227
- isLib?: boolean;
1228
- isSsr?: boolean;
1229
- isWorker?: boolean;
1230
- urlBase?: string;
1231
- publicDir?: string;
1232
- decodedBase?: string;
1233
- isSkipAssets?: boolean;
1234
- assetsInclude?: Array<BindingStringOrRegex>;
1235
- assetInlineLimit?: number | ((file: string, content: Buffer) => boolean | undefined);
1259
+ isLib: boolean;
1260
+ isSsr: boolean;
1261
+ isWorker: boolean;
1262
+ urlBase: string;
1263
+ publicDir: string;
1264
+ decodedBase: string;
1265
+ isSkipAssets: boolean;
1266
+ assetsInclude: Array<BindingStringOrRegex>;
1267
+ assetInlineLimit: number | ((file: string, content: Buffer) => boolean | undefined);
1236
1268
  renderBuiltUrl?: (filename: string, type: BindingRenderBuiltUrlConfig) => MaybePromise<VoidNullable<string | BindingRenderBuiltUrlRet>>;
1237
1269
  }
1238
1270
  interface BindingAssetSource {
@@ -1245,7 +1277,11 @@ interface BindingBuildImportAnalysisPluginConfig {
1245
1277
  renderBuiltUrl: boolean;
1246
1278
  isRelativeBase: boolean;
1247
1279
  }
1248
- type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-preload-polyfill' | 'builtin:react-refresh-wrapper' | 'builtin:reporter' | 'builtin:replace' | 'builtin:esm-external-require' | 'builtin:transform' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
1280
+ type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:esm-external-require' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-preload-polyfill' | 'builtin:react-refresh-wrapper' | 'builtin:reporter' | 'builtin:replace' | 'builtin:transform' | 'builtin:vite-css' | 'builtin:vite-css-post' | 'builtin:vite-html' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
1281
+ interface BindingClientHmrUpdate {
1282
+ clientId: string;
1283
+ update: BindingHmrUpdate;
1284
+ }
1249
1285
  interface BindingDynamicImportVarsPluginConfig {
1250
1286
  include?: Array<BindingStringOrRegex>;
1251
1287
  exclude?: Array<BindingStringOrRegex>;
@@ -1306,6 +1342,16 @@ interface BindingJsonPluginConfig {
1306
1342
  stringify?: BindingJsonPluginStringify;
1307
1343
  }
1308
1344
  type BindingJsonPluginStringify = boolean | string;
1345
+ interface BindingJsonSourcemap {
1346
+ file?: string;
1347
+ mappings?: string;
1348
+ sourceRoot?: string;
1349
+ sources?: Array<string | undefined | null>;
1350
+ sourcesContent?: Array<string | undefined | null>;
1351
+ names?: Array<string>;
1352
+ debugId?: string;
1353
+ x_google_ignoreList?: Array<number>;
1354
+ }
1309
1355
  interface BindingManifestPluginConfig {
1310
1356
  root: string;
1311
1357
  outPath: string;
@@ -1357,6 +1403,9 @@ interface BindingReporterPluginConfig {
1357
1403
  warnLargeChunks: boolean;
1358
1404
  reportCompressedSize: boolean;
1359
1405
  }
1406
+ interface BindingSourcemap {
1407
+ inner: string | BindingJsonSourcemap;
1408
+ }
1360
1409
  interface BindingTransformHookExtraArgs {
1361
1410
  moduleType: string;
1362
1411
  }
@@ -1369,6 +1418,48 @@ interface BindingTransformPluginConfig {
1369
1418
  jsxInject?: string;
1370
1419
  transformOptions?: TransformOptions;
1371
1420
  }
1421
+ interface BindingViteCssPluginConfig {
1422
+ isLib: boolean;
1423
+ publicDir: string;
1424
+ compileCSS: (url: string, importer: string, resolver: BindingUrlResolver) => Promise<{
1425
+ code: string;
1426
+ map?: BindingSourcemap;
1427
+ modules?: Record<string, string>;
1428
+ deps?: Set<string>;
1429
+ }>;
1430
+ resolveUrl: (url: string, importer?: string) => MaybePromise<string | undefined>;
1431
+ assetInlineLimit: number | ((file: string, content: Buffer) => boolean | undefined);
1432
+ }
1433
+ interface BindingViteCssPostPluginConfig {
1434
+ isLib: boolean;
1435
+ isSsr: boolean;
1436
+ isWorker: boolean;
1437
+ isClient: boolean;
1438
+ cssCodeSplit: boolean;
1439
+ sourcemap: boolean;
1440
+ assetsDir: string;
1441
+ urlBase: string;
1442
+ decodedBase: string;
1443
+ libCssFilename?: string;
1444
+ isLegacy?: () => boolean;
1445
+ cssMinify?: (css: string) => Promise<string>;
1446
+ renderBuiltUrl?: (filename: string, type: BindingRenderBuiltUrlConfig) => MaybePromise<VoidNullable<string | BindingRenderBuiltUrlRet>>;
1447
+ }
1448
+ interface BindingViteHtmlPluginConfig {
1449
+ isLib: boolean;
1450
+ isSsr: boolean;
1451
+ urlBase: string;
1452
+ publicDir: string;
1453
+ decodedBase: string;
1454
+ cssCodeSplit: boolean;
1455
+ modulePreloadPolyfill: boolean;
1456
+ assetInlineLimit: number | ((file: string, content: Buffer) => boolean | undefined);
1457
+ renderBuiltUrl?: (filename: string, type: BindingRenderBuiltUrlConfig) => MaybePromise<VoidNullable<string | BindingRenderBuiltUrlRet>>;
1458
+ resolveDependencies?: boolean | ((filename: string, dependencies: string[], context: {
1459
+ hostId: string;
1460
+ hostType: 'html' | 'js';
1461
+ }) => Promise<string[]>);
1462
+ }
1372
1463
  interface BindingViteResolvePluginConfig {
1373
1464
  resolveOptions: BindingViteResolvePluginResolveOptions;
1374
1465
  environmentConsumer: string;
@@ -1417,4 +1508,4 @@ interface PreRenderedChunk {
1417
1508
  exports: Array<string>;
1418
1509
  }
1419
1510
  //#endregion
1420
- export { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingBundlerImpl, BindingClientHmrUpdate, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReactRefreshWrapperPluginConfig, BindingRebuildStrategy, BindingRenderedChunk, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, BindingWatcherEvent, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, MinifyOptions, NapiResolveOptions, ParseResult, ParserOptions, PreRenderedChunk, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform };
1511
+ export { IsolatedDeclarationsResult as A, TransformResult as B, BindingViteCssPluginConfig as C, BindingWasmHelperPluginConfig as D, BindingViteResolvePluginConfig as E, ParserOptions as F, moduleRunnerTransform as H, PreRenderedChunk as I, ResolveResult as L, MinifyOptions as M, NapiResolveOptions as N, BindingWatcherEvent as O, ParseResult as P, ResolverFactory as R, BindingUrlResolver as S, BindingViteHtmlPluginConfig as T, transform as U, isolatedDeclaration as V, BindingRenderedChunk as _, BindingClientHmrUpdate as a, BindingTransformHookExtraArgs as b, BindingHookResolveIdExtraArgs as c, BindingJsonPluginConfig as d, BindingMagicString as f, BindingRebuildStrategy as g, BindingReactRefreshWrapperPluginConfig as h, BindingBundlerImpl as i, JsxOptions as j, IsolatedDeclarationsOptions as k, BindingImportGlobPluginConfig as l, BindingModulePreloadPolyfillPluginConfig as m, BindingBuildImportAnalysisPluginConfig as n, BindingDynamicImportVarsPluginConfig as o, BindingManifestPluginConfig as p, BindingBuiltinPluginName as r, BindingEsmExternalRequirePluginConfig as s, BindingAssetPluginConfig as t, BindingIsolatedDeclarationPluginConfig as u, BindingReplacePluginConfig as v, BindingViteCssPostPluginConfig as w, BindingTransformPluginConfig as x, BindingReporterPluginConfig as y, TransformOptions as z };
@@ -1,4 +1,4 @@
1
- import { BindingBuiltinPluginName, BindingBundlerImpl, BindingHookResolveIdExtraArgs, BindingRenderedChunk, BindingTransformHookExtraArgs, BindingWatcherEvent, MinifyOptions as MinifyOptions$1, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding-CtbNz6TD.mjs";
1
+ import { F as ParserOptions, I as PreRenderedChunk, M as MinifyOptions$1, O as BindingWatcherEvent, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, j as JsxOptions, r as BindingBuiltinPluginName, z as TransformOptions$1 } from "./binding-QBosa6N8.mjs";
2
2
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
3
3
  import { Program } from "@oxc-project/types";
4
4
 
@@ -159,6 +159,15 @@ interface GeneratedCodeOptions {
159
159
  * ```
160
160
  */
161
161
  preset?: GeneratedCodePreset;
162
+ /**
163
+ * Whether to add readable names to internal variables for profiling purposes.
164
+ *
165
+ * When enabled, generated code will use descriptive variable names that correspond
166
+ * to the original module names, making it easier to profile and debug the bundled code.
167
+ *
168
+ * @default true when minification is disabled, false when minification is enabled
169
+ */
170
+ profilerNames?: boolean;
162
171
  }
163
172
  type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
164
173
  type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
@@ -253,6 +262,37 @@ interface OutputOptions {
253
262
  minify?: boolean | "dce-only" | MinifyOptions;
254
263
  name?: string;
255
264
  globals?: Record<string, string> | GlobalsFunction;
265
+ /**
266
+ * Maps external module IDs to paths.
267
+ *
268
+ * Allows customizing the path used when importing external dependencies.
269
+ * This is particularly useful for loading dependencies from CDNs or custom locations.
270
+ *
271
+ * - Object form: Maps module IDs to their replacement paths
272
+ * - Function form: Takes a module ID and returns its replacement path
273
+ *
274
+ * @example
275
+ * ```js
276
+ * {
277
+ * paths: {
278
+ * 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
279
+ * }
280
+ * }
281
+ * ```
282
+ *
283
+ * @example
284
+ * ```js
285
+ * {
286
+ * paths: (id) => {
287
+ * if (id.startsWith('lodash')) {
288
+ * return `https://cdn.jsdelivr.net/npm/${id}`
289
+ * }
290
+ * return id
291
+ * }
292
+ * }
293
+ * ```
294
+ */
295
+ paths?: Record<string, string> | ((id: string) => string);
256
296
  generatedCode?: Partial<GeneratedCodeOptions>;
257
297
  externalLiveBindings?: boolean;
258
298
  inlineDynamicImports?: boolean;
@@ -314,7 +354,7 @@ interface OutputOptions {
314
354
  * By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
315
355
  *
316
356
  * If you want to disable this behavior, it's recommended to both set
317
- * - `preserveEntrySignatures: false`
357
+ * - `preserveEntrySignatures: false | 'allow-extension'`
318
358
  * - `strictExecutionOrder: true`
319
359
  *
320
360
  * to avoid generating invalid chunks.
@@ -510,11 +550,26 @@ interface OutputOptions {
510
550
  topLevelVar?: boolean;
511
551
  /**
512
552
  * - Type: `boolean`
513
- * - Default: `false`
553
+ * - Default: `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
514
554
  *
515
555
  * Whether to minify internal exports.
516
556
  */
517
557
  minifyInternalExports?: boolean;
558
+ /**
559
+ * - Type: `boolean`
560
+ * - Default: `false`
561
+ *
562
+ * Clean output directory before emitting output.
563
+ */
564
+ cleanDir?: boolean;
565
+ /** Keep function and class names after bundling.
566
+ *
567
+ * When enabled, the bundler will preserve the original names of functions and classes
568
+ * in the output, which is useful for debugging and error stack traces.
569
+ *
570
+ * @default false
571
+ */
572
+ keepNames?: boolean;
518
573
  }
519
574
  //#endregion
520
575
  //#region src/api/build.d.ts
@@ -612,6 +667,7 @@ interface NormalizedInputOptions {
612
667
  }
613
668
  //#endregion
614
669
  //#region src/options/normalized-output-options.d.ts
670
+ type PathsFunction = (id: string) => string;
615
671
  type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
616
672
  interface NormalizedOutputOptions {
617
673
  name: string | undefined;
@@ -635,6 +691,7 @@ interface NormalizedOutputOptions {
635
691
  esModule: boolean | "if-default-prop";
636
692
  extend: boolean;
637
693
  globals: Record<string, string> | GlobalsFunction;
694
+ paths: Record<string, string> | PathsFunction | undefined;
638
695
  hashCharacters: "base64" | "base36" | "hex";
639
696
  sourcemapDebugIds: boolean;
640
697
  sourcemapIgnoreList: boolean | SourcemapIgnoreListOption | StringOrRegExp | undefined;
@@ -952,7 +1009,9 @@ interface ResolveIdExtraOptions {
952
1009
  }
953
1010
  type ResolveIdResult = string | NullValue | false | PartialResolvedId;
954
1011
  type LoadResult = NullValue | string | SourceDescription;
955
- type TransformResult = NullValue | string | Partial<SourceDescription>;
1012
+ type TransformResult = NullValue | string | Omit<SourceDescription, "code"> & {
1013
+ code?: string | BindingMagicString;
1014
+ };
956
1015
  type RenderedChunkMeta = {
957
1016
  chunks: Record<string, RenderedChunk>;
958
1017
  };
@@ -970,6 +1029,7 @@ interface FunctionPluginHooks {
970
1029
  [DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
971
1030
  [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
972
1031
  moduleType: ModuleType;
1032
+ magicString?: BindingMagicString;
973
1033
  }) => TransformResult;
974
1034
  [DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
975
1035
  [DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
@@ -1003,15 +1063,15 @@ type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBund
1003
1063
  type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
1004
1064
  type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
1005
1065
  type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
1006
- type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
1066
+ type HookFilterExtension<K$1 extends keyof FunctionPluginHooks> = K$1 extends "transform" ? {
1007
1067
  filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
1008
- } : K extends "load" ? {
1068
+ } : K$1 extends "load" ? {
1009
1069
  filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
1010
- } : K extends "resolveId" ? {
1070
+ } : K$1 extends "resolveId" ? {
1011
1071
  filter?: TUnionWithTopLevelFilterExpressionArray<{
1012
1072
  id?: GeneralHookFilter<RegExp>;
1013
1073
  }>;
1014
- } : K extends "renderChunk" ? {
1074
+ } : K$1 extends "renderChunk" ? {
1015
1075
  filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
1016
1076
  } : {};
1017
1077
  type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
@@ -1108,9 +1168,114 @@ interface ChecksOptions {
1108
1168
  preferBuiltinFeature?: boolean;
1109
1169
  }
1110
1170
  //#endregion
1171
+ //#region src/options/transform-options.d.ts
1172
+ interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
1173
+ /**
1174
+ * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
1175
+ *
1176
+ * # Examples
1177
+ *
1178
+ * - Replace the global variable `IS_PROD` with `true`
1179
+ *
1180
+ * ```js rolldown.config.js
1181
+ * export default defineConfig({ transform: { define: { IS_PROD: 'true' } } })
1182
+ * ```
1183
+ *
1184
+ * Result:
1185
+ *
1186
+ * ```js
1187
+ * // Input
1188
+ * if (IS_PROD) {
1189
+ * console.log('Production mode')
1190
+ * }
1191
+ *
1192
+ * // After bundling
1193
+ * if (true) {
1194
+ * console.log('Production mode')
1195
+ * }
1196
+ * ```
1197
+ *
1198
+ * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
1199
+ *
1200
+ * ```js rolldown.config.js
1201
+ * export default defineConfig({ transform: { define: { 'process.env.NODE_ENV': "'production'" } } })
1202
+ * ```
1203
+ *
1204
+ * Result:
1205
+ *
1206
+ * ```js
1207
+ * // Input
1208
+ * if (process.env.NODE_ENV === 'production') {
1209
+ * console.log('Production mode')
1210
+ * }
1211
+ *
1212
+ * // After bundling
1213
+ * if ('production' === 'production') {
1214
+ * console.log('Production mode')
1215
+ * }
1216
+ *
1217
+ * ```
1218
+ */
1219
+ define?: Record<string, string>;
1220
+ /**
1221
+ * Inject import statements on demand.
1222
+ *
1223
+ * The API is aligned with `@rollup/plugin-inject`.
1224
+ *
1225
+ * ## Supported patterns
1226
+ * ```js
1227
+ * {
1228
+ * // import { Promise } from 'es6-promise'
1229
+ * Promise: ['es6-promise', 'Promise'],
1230
+ *
1231
+ * // import { Promise as P } from 'es6-promise'
1232
+ * P: ['es6-promise', 'Promise'],
1233
+ *
1234
+ * // import $ from 'jquery'
1235
+ * $: 'jquery',
1236
+ *
1237
+ * // import * as fs from 'node:fs'
1238
+ * fs: ['node:fs', '*'],
1239
+ *
1240
+ * // Inject shims for property access pattern
1241
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
1242
+ * }
1243
+ * ```
1244
+ */
1245
+ inject?: Record<string, string | [string, string]>;
1246
+ /**
1247
+ * Remove labeled statements with these label names.
1248
+ *
1249
+ * Labeled statements are JavaScript statements prefixed with a label identifier.
1250
+ * This option allows you to strip specific labeled statements from the output,
1251
+ * which is useful for removing debug-only code in production builds.
1252
+ *
1253
+ * ## Example
1254
+ *
1255
+ * ```js rolldown.config.js
1256
+ * export default defineConfig({ transform: { dropLabels: ['DEBUG', 'DEV'] } })
1257
+ * ```
1258
+ *
1259
+ * Result:
1260
+ *
1261
+ * ```js
1262
+ * // Input
1263
+ * DEBUG: console.log('Debug info');
1264
+ * DEV: {
1265
+ * console.log('Development mode');
1266
+ * }
1267
+ * console.log('Production code');
1268
+ *
1269
+ * // After bundling
1270
+ * console.log('Production code');
1271
+ * ```
1272
+ */
1273
+ dropLabels?: string[];
1274
+ jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
1275
+ }
1276
+ //#endregion
1111
1277
  //#region src/options/input-options.d.ts
1112
1278
  type InputOption = string | string[] | Record<string, string>;
1113
- type OxcTransformOption = Omit<TransformOptions, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject">;
1114
1279
  type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
1115
1280
  type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
1116
1281
  interface WatcherOptions {
@@ -1178,13 +1343,6 @@ type OptimizationOptions = {
1178
1343
  };
1179
1344
  type AttachDebugOptions = "none" | "simple" | "full";
1180
1345
  type ChunkModulesOrder = "exec-order" | "module-id";
1181
- interface RollupJsxOptions {
1182
- mode?: "classic" | "automatic" | "preserve";
1183
- factory?: string;
1184
- fragment?: string;
1185
- importSource?: string;
1186
- jsxImportSource?: string;
1187
- }
1188
1346
  interface InputOptions {
1189
1347
  input?: InputOption;
1190
1348
  plugins?: RolldownPluginOption;
@@ -1238,6 +1396,17 @@ interface InputOptions {
1238
1396
  onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
1239
1397
  moduleTypes?: ModuleTypes;
1240
1398
  experimental?: {
1399
+ /**
1400
+ * Lets modules be executed in the order they are declared.
1401
+ *
1402
+ * - Type: `boolean`
1403
+ * - Default: `false`
1404
+ *
1405
+ * 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.
1406
+ *
1407
+ * > [!WARNING]
1408
+ * > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
1409
+ */
1241
1410
  strictExecutionOrder?: boolean;
1242
1411
  disableLiveBindings?: boolean;
1243
1412
  viteMode?: boolean;
@@ -1326,93 +1495,73 @@ interface InputOptions {
1326
1495
  */
1327
1496
  incrementalBuild?: boolean;
1328
1497
  transformHiresSourcemap?: boolean | "boundary";
1498
+ /**
1499
+ * Use native Rust implementation of MagicString for source map generation.
1500
+ *
1501
+ * - Type: `boolean`
1502
+ * - Default: `false`
1503
+ *
1504
+ * [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
1505
+ * for string manipulation and source map generation. When enabled, rolldown will use a native Rust
1506
+ * implementation of MagicString instead of the JavaScript version, providing significantly better performance
1507
+ * during source map generation and code transformation.
1508
+ *
1509
+ * ## Benefits
1510
+ *
1511
+ * - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
1512
+ * especially for large codebases with extensive source maps.
1513
+ * - **Background Processing**: Source map generation is performed asynchronously in a background thread,
1514
+ * allowing the main bundling process to continue without blocking. This parallel processing can significantly
1515
+ * reduce overall build times when working with JavaScript transform hooks.
1516
+ * - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
1517
+ *
1518
+ * ## Example
1519
+ *
1520
+ * ```js
1521
+ * export default {
1522
+ * experimental: {
1523
+ * nativeMagicString: true
1524
+ * },
1525
+ * output: {
1526
+ * sourcemap: true
1527
+ * }
1528
+ * }
1529
+ * ```
1530
+ *
1531
+ * > [!NOTE]
1532
+ * > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
1533
+ * > implementation, there may be edge cases. Please report any discrepancies you encounter.
1534
+ * > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
1535
+ */
1536
+ nativeMagicString?: boolean;
1329
1537
  };
1330
1538
  /**
1331
1539
  * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
1332
1540
  *
1333
- * # Examples
1334
- *
1335
- * - Replace the global variable `IS_PROD` with `true`
1336
- *
1337
- * ```js rolldown.config.js
1338
- * export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
1339
- * ```
1340
- *
1341
- * Result:
1342
- *
1343
- * ```js
1344
- * // Input
1345
- * if (IS_PROD) {
1346
- * console.log('Production mode')
1347
- * }
1348
- *
1349
- * // After bundling
1350
- * if (true) {
1351
- * console.log('Production mode')
1352
- * }
1353
- * ```
1354
- *
1355
- * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
1356
- *
1357
- * ```js rolldown.config.js
1358
- * export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
1359
- * ```
1360
- *
1361
- * Result:
1541
+ * @deprecated Use `transform.define` instead. This top-level option will be removed in a future release.
1362
1542
  *
1363
- * ```js
1364
- * // Input
1365
- * if (process.env.NODE_ENV === 'production') {
1366
- * console.log('Production mode')
1367
- * }
1368
- *
1369
- * // After bundling
1370
- * if ('production' === 'production') {
1371
- * console.log('Production mode')
1372
- * }
1373
- *
1374
- * ```
1543
+ * See `transform.define` for detailed documentation and examples.
1375
1544
  */
1376
1545
  define?: Record<string, string>;
1377
1546
  /**
1378
1547
  * Inject import statements on demand.
1379
1548
  *
1380
- * ## Supported patterns
1381
- * ```js
1382
- * {
1383
- * // import { Promise } from 'es6-promise'
1384
- * Promise: ['es6-promise', 'Promise'],
1385
- *
1386
- * // import { Promise as P } from 'es6-promise'
1387
- * P: ['es6-promise', 'Promise'],
1388
- *
1389
- * // import $ from 'jquery'
1390
- * $: 'jquery',
1549
+ * @deprecated Use `transform.inject` instead. This top-level option will be removed in a future release.
1391
1550
  *
1392
- * // import * as fs from 'node:fs'
1393
- * fs: ['node:fs', '*'],
1394
- *
1395
- * // Inject shims for property access pattern
1396
- * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
1397
- * }
1398
- * ```
1551
+ * See `transform.inject` for detailed documentation and examples.
1399
1552
  */
1400
1553
  inject?: Record<string, string | [string, string]>;
1401
- profilerNames?: boolean;
1402
1554
  /**
1403
- * @deprecated Use `transform.jsx` instead.
1555
+ * Whether to add readable names to internal variables for profiling purposes.
1404
1556
  *
1405
- * This top-level `jsx` option will be removed in a future release.
1406
- * It is only kept for backward compatibility and will be mapped internally to `transform.jsx`.
1557
+ * When enabled, generated code will use descriptive variable names that correspond
1558
+ * to the original module names, making it easier to profile and debug the bundled code.
1407
1559
  *
1408
- * - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
1409
- * - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
1410
- * - `"react"` enables the `classic` JSX transformer.
1411
- * - `"react-jsx"` enables the `automatic` JSX transformer.
1560
+ * @default true when minification is disabled, false when minification is enabled
1412
1561
  *
1413
- * @default runtime = "automatic"
1562
+ * @deprecated Use `output.generatedCode.profilerNames` instead. This top-level option will be removed in a future release.
1414
1563
  */
1415
- jsx?: false | "react" | "react-jsx" | "preserve" | RollupJsxOptions;
1564
+ profilerNames?: boolean;
1416
1565
  /**
1417
1566
  * Configure how the code is transformed. This process happens after the `transform` hook.
1418
1567
  *
@@ -1430,9 +1579,23 @@ interface InputOptions {
1430
1579
  *
1431
1580
  * For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
1432
1581
  */
1433
- transform?: OxcTransformOption;
1582
+ transform?: TransformOptions;
1434
1583
  watch?: WatcherOptions | false;
1584
+ /**
1585
+ * Remove labeled statements with these label names.
1586
+ *
1587
+ * @deprecated Use `transform.dropLabels` instead. This top-level option will be removed in a future release.
1588
+ *
1589
+ * See `transform.dropLabels` for detailed documentation and examples.
1590
+ */
1435
1591
  dropLabels?: string[];
1592
+ /**
1593
+ * Keep function and class names after bundling.
1594
+ *
1595
+ * @deprecated Use `output.keepNames` instead. This top-level option will be removed in a future release.
1596
+ *
1597
+ * See `output.keepNames` for detailed documentation.
1598
+ */
1436
1599
  keepNames?: boolean;
1437
1600
  checks?: ChecksOptions;
1438
1601
  makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
@@ -1472,4 +1635,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
1472
1635
  declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
1473
1636
  declare function defineConfig(config: ConfigExport): ConfigExport;
1474
1637
  //#endregion
1475
- export { type AddonFunction, type AsyncPluginHooks, type BufferEncoding, type BuildOptions, BuiltinPlugin, type ChunkFileNamesFunction, type ChunkingContext, type ConfigExport, type CustomPluginOptions, type DefineParallelPluginResult, type EmittedAsset, type EmittedFile, type ExistingRawSourceMap, type ExternalOption, type FunctionPluginHooks, type GeneralHookFilter, type GeneratedCodeOptions, type GeneratedCodePreset, type GetModuleInfo, type GlobalsFunction, type HookFilter, type HookFilterExtension, type ImportKind, type InputOption, type InputOptions, type InternalModuleFormat, type LoadResult, type LogLevel, type LogLevelOption, type LogOrStringHandler, type LoggingFunction, MaybePromise, type MinifyOptions, type MinimalPluginContext, type ModuleFormat, type ModuleInfo, type ModuleOptions, type ModuleType, type ModuleTypeFilter, type ModuleTypes, type NormalizedInputOptions, type NormalizedOutputOptions, type ObjectHook, type OptimizationOptions, type OutputAsset, type OutputBundle, type OutputChunk, type OutputOptions, type ParallelPluginHooks, type PartialNull, type PartialResolvedId, type Plugin, type PluginContext, type PluginContextMeta, type PreRenderedAsset, type RenderedChunk, type RenderedModule, type ResolveIdExtraOptions, type ResolveIdResult, type ResolvedId, type RolldownBuild, type RolldownDirectoryEntry, type RolldownFileStats, type RolldownFsModule, type RolldownOptions, type RolldownOptionsFunction, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatcher, type RolldownWatcherEvent, type RollupError, type RollupLog, type RollupLogWithString, type SourceDescription, type SourceMap, type SourceMapInput, type SourcemapIgnoreListOption, StringOrRegExp, type TransformPluginContext, type TransformResult, type TreeshakingOptions, VERSION, type WarningHandlerWithDefault, type WatchOptions, type WatcherOptions, build, defineConfig, defineParallelPlugin, rolldown, watch, withFilter };
1638
+ export { InternalModuleFormat as $, BuiltinPlugin as A, SourceMap as At, GetModuleInfo as B, ResolveIdResult as C, PartialNull as Ct, SourceDescription as D, RenderedChunk as Dt, RolldownPluginOption as E, OutputChunk as Et, OutputBundle as F, LogOrStringHandler as Ft, PluginContextMeta as G, DefineParallelPluginResult as H, TreeshakingOptions as I, RollupError as It, ModuleTypeFilter as J, GeneralHookFilter as K, TransformPluginContext as L, RollupLog as Lt, ExistingRawSourceMap as M, SourcemapIgnoreListOption as Mt, SourceMapInput as N, LogLevel as Nt, TransformResult as O, RenderedModule as Ot, RolldownOptionsFunction as P, LogLevelOption as Pt, RolldownFsModule as Q, EmittedAsset as R, RollupLogWithString as Rt, ResolveIdExtraOptions as S, MaybePromise as St, RolldownPlugin as T, OutputAsset as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, GlobalsFunction as _t, InputOption as a, RolldownWatcher as at, PartialResolvedId as b, OutputOptions as bt, OptimizationOptions as c, rolldown as ct, CustomPluginOptions as d, build as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, AddonFunction as ft, ModuleOptions as g, GeneratedCodePreset as gt, LoadResult as h, GeneratedCodeOptions as ht, ExternalOption as i, watch as it, VERSION as j, ModuleInfo as jt, withFilter as k, RolldownOutput as kt, WatcherOptions as l, RolldownBuild as lt, ImportKind as m, ChunkingContext as mt, ConfigExport as n, LoggingFunction as nt, InputOptions as o, RolldownWatcherEvent as ot, HookFilterExtension as p, ChunkFileNamesFunction as pt, HookFilter as q, RolldownOptions as r, WarningHandlerWithDefault as rt, ModuleTypes as s, WatchOptions as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, BuildOptions as ut, ObjectHook as v, MinifyOptions as vt, ResolvedId as w, StringOrRegExp as wt, Plugin as x, PreRenderedAsset as xt, ParallelPluginHooks as y, ModuleFormat as yt, EmittedFile as z };