@rolldown/browser 1.0.0-beta.35 → 1.0.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cli.mjs +96 -1069
  2. package/dist/config.d.mts +2 -2
  3. package/dist/config.mjs +4 -4
  4. package/dist/experimental-index.browser.mjs +493 -7
  5. package/dist/experimental-index.d.mts +43 -5
  6. package/dist/experimental-index.mjs +32 -9
  7. package/dist/filter-index.d.mts +2 -2
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/index.browser.mjs +1 -1
  10. package/dist/index.d.mts +3 -3
  11. package/dist/index.mjs +3 -3
  12. package/dist/parallel-plugin-worker.mjs +4 -5
  13. package/dist/parallel-plugin.d.mts +2 -2
  14. package/dist/parse-ast-index.d.mts +1 -1
  15. package/dist/parse-ast-index.mjs +1 -1
  16. package/dist/rolldown-binding.wasi-browser.js +1 -0
  17. package/dist/rolldown-binding.wasi.cjs +1 -0
  18. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  19. package/dist/shared/{binding-9k0egz6L.d.mts → binding-Cjs27cfu.d.mts} +1 -0
  20. package/dist/shared/{define-config-DhrkZ_o7.d.cts → define-config-DzsPS4fI.d.mts} +8 -8
  21. package/dist/shared/{dist-ByKQkexh.mjs → dist-CHTC3-kR.mjs} +1 -1
  22. package/dist/shared/{load-config-BCjD-AGJ.mjs → load-config-efyGD8HY.mjs} +4 -6
  23. package/dist/{cli.cjs → shared/logger-CiCY7ucm.mjs} +34 -817
  24. package/dist/shared/{parse-ast-index-C_CZT4St.mjs → parse-ast-index-C3TkGcEQ.mjs} +1 -1
  25. package/dist/shared/{prompt-C5jz26Zn.mjs → prompt-D2FxOcB5.mjs} +4 -7
  26. package/dist/shared/{src-B0RCtUy7.mjs → src-kVjGhYdF.mjs} +89 -70
  27. package/dist/{src-C8U06Im1.js → src-C2GHZXDs.js} +88 -70
  28. package/package.json +10 -24
  29. package/dist/cli.d.cts +0 -1
  30. package/dist/config.cjs +0 -12
  31. package/dist/config.d.cts +0 -10
  32. package/dist/experimental-index.cjs +0 -176
  33. package/dist/experimental-index.d.cts +0 -99
  34. package/dist/filter-index.cjs +0 -53
  35. package/dist/filter-index.d.cts +0 -4
  36. package/dist/index.cjs +0 -9
  37. package/dist/index.d.cts +0 -3
  38. package/dist/parallel-plugin-worker.cjs +0 -35
  39. package/dist/parallel-plugin-worker.d.cts +0 -1
  40. package/dist/parallel-plugin.cjs +0 -8
  41. package/dist/parallel-plugin.d.cts +0 -14
  42. package/dist/parse-ast-index.cjs +0 -4
  43. package/dist/parse-ast-index.d.cts +0 -8
  44. package/dist/shared/binding-D13M6Llu.d.cts +0 -1425
  45. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  46. package/dist/shared/define-config-DJXaSinS.d.mts +0 -1421
  47. package/dist/shared/dist-CK0hotcm.cjs +0 -240
  48. package/dist/shared/load-config-BJKhRKZL.cjs +0 -130
  49. package/dist/shared/parse-ast-index-J0xVKZRe.cjs +0 -327
  50. package/dist/shared/prompt-Q05EYrFb.cjs +0 -858
  51. package/dist/shared/src-Bd4BGX4v.cjs +0 -4788
@@ -1,1421 +0,0 @@
1
- import { BindingBuiltinPluginName, BindingBundlerImpl, BindingHmrUpdate, BindingHookResolveIdExtraArgs, BindingRenderedChunk, BindingTransformHookExtraArgs, BindingWatcherEvent, MinifyOptions as MinifyOptions$1, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding-9k0egz6L.mjs";
2
- import { Program } from "@oxc-project/types";
3
- import { TopLevelFilterExpression } from "@rolldown/pluginutils";
4
-
5
- //#region src/log/logging.d.ts
6
- type LogLevel = "info" | "debug" | "warn";
7
- type LogLevelOption = LogLevel | "silent";
8
- type LogLevelWithError = LogLevel | "error";
9
- interface RollupLog {
10
- binding?: string;
11
- cause?: unknown;
12
- code?: string;
13
- exporter?: string;
14
- frame?: string;
15
- hook?: string;
16
- id?: string;
17
- ids?: string[];
18
- loc?: {
19
- column: number;
20
- file?: string;
21
- line: number;
22
- };
23
- message: string;
24
- meta?: any;
25
- names?: string[];
26
- plugin?: string;
27
- pluginCode?: unknown;
28
- pos?: number;
29
- reexporter?: string;
30
- stack?: string;
31
- url?: string;
32
- }
33
- type RollupLogWithString = RollupLog | string;
34
- interface RollupError extends RollupLog {
35
- name?: string;
36
- stack?: string;
37
- watchFiles?: string[];
38
- }
39
- type LogOrStringHandler = (level: LogLevelWithError, log: RollupLogWithString) => void;
40
- //#endregion
41
- //#region src/types/misc.d.ts
42
- type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
43
- type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
44
- //#endregion
45
- //#region src/types/module-info.d.ts
46
- interface ModuleInfo extends ModuleOptions {
47
- /**
48
- * Unsupported at rolldown
49
- */
50
- ast: any;
51
- code: string | null;
52
- id: string;
53
- importers: string[];
54
- dynamicImporters: string[];
55
- importedIds: string[];
56
- dynamicallyImportedIds: string[];
57
- exports: string[];
58
- isEntry: boolean;
59
- }
60
- //#endregion
61
- //#region src/utils/asset-source.d.ts
62
- type AssetSource = string | Uint8Array;
63
- //#endregion
64
- //#region src/types/rolldown-output.d.ts
65
- interface OutputAsset {
66
- type: "asset";
67
- fileName: string;
68
- /** @deprecated Use "originalFileNames" instead. */
69
- originalFileName: string | null;
70
- originalFileNames: string[];
71
- source: AssetSource;
72
- /** @deprecated Use "names" instead. */
73
- name: string | undefined;
74
- names: string[];
75
- }
76
- interface SourceMap {
77
- file: string;
78
- mappings: string;
79
- names: string[];
80
- sources: string[];
81
- sourcesContent: string[];
82
- version: number;
83
- debugId?: string;
84
- x_google_ignoreList?: number[];
85
- toString(): string;
86
- toUrl(): string;
87
- }
88
- interface RenderedModule {
89
- readonly code: string | null;
90
- renderedLength: number;
91
- renderedExports: string[];
92
- }
93
- interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
94
- type: "chunk";
95
- modules: {
96
- [id: string]: RenderedModule;
97
- };
98
- name: string;
99
- isEntry: boolean;
100
- isDynamicEntry: boolean;
101
- facadeModuleId: string | null;
102
- moduleIds: Array<string>;
103
- exports: Array<string>;
104
- fileName: string;
105
- imports: Array<string>;
106
- dynamicImports: Array<string>;
107
- }
108
- interface OutputChunk {
109
- type: "chunk";
110
- code: string;
111
- name: string;
112
- isEntry: boolean;
113
- exports: string[];
114
- fileName: string;
115
- modules: {
116
- [id: string]: RenderedModule;
117
- };
118
- imports: string[];
119
- dynamicImports: string[];
120
- facadeModuleId: string | null;
121
- isDynamicEntry: boolean;
122
- moduleIds: string[];
123
- map: SourceMap | null;
124
- sourcemapFileName: string | null;
125
- preliminaryFileName: string;
126
- }
127
- interface RolldownOutput {
128
- output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
129
- }
130
- //#endregion
131
- //#region src/types/utils.d.ts
132
- type MaybePromise<T> = T | Promise<T>;
133
- type NullValue<T = void> = T | undefined | null | void;
134
- type PartialNull<T> = { [P in keyof T]: T[P] | null };
135
- type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
136
- type MaybeArray<T> = T | T[];
137
- type StringOrRegExp = string | RegExp;
138
- //#endregion
139
- //#region src/options/output-options.d.ts
140
- type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
141
- type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
142
- type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
143
- interface PreRenderedAsset {
144
- type: "asset";
145
- name?: string;
146
- names: string[];
147
- originalFileName?: string;
148
- originalFileNames: string[];
149
- source: string | Uint8Array;
150
- }
151
- type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
152
- type GlobalsFunction = (name: string) => string;
153
- type MinifyOptions = Omit<MinifyOptions$1, "module" | "codegen" | "sourcemap">;
154
- interface ChunkingContext {
155
- getModuleInfo(moduleId: string): ModuleInfo | null;
156
- }
157
- interface OutputOptions {
158
- dir?: string;
159
- file?: string;
160
- exports?: "auto" | "named" | "default" | "none";
161
- hashCharacters?: "base64" | "base36" | "hex";
162
- /**
163
- * Expected format of generated code.
164
- * - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
165
- * - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
166
- * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
167
- * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
168
- *
169
- * @default 'esm'
170
- */
171
- format?: ModuleFormat;
172
- sourcemap?: boolean | "inline" | "hidden";
173
- sourcemapBaseUrl?: string;
174
- sourcemapDebugIds?: boolean;
175
- sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
176
- sourcemapPathTransform?: SourcemapPathTransformOption;
177
- banner?: string | AddonFunction;
178
- footer?: string | AddonFunction;
179
- intro?: string | AddonFunction;
180
- outro?: string | AddonFunction;
181
- extend?: boolean;
182
- esModule?: boolean | "if-default-prop";
183
- assetFileNames?: string | AssetFileNamesFunction;
184
- entryFileNames?: string | ChunkFileNamesFunction;
185
- chunkFileNames?: string | ChunkFileNamesFunction;
186
- cssEntryFileNames?: string | ChunkFileNamesFunction;
187
- cssChunkFileNames?: string | ChunkFileNamesFunction;
188
- sanitizeFileName?: boolean | ((name: string) => string);
189
- /**
190
- * Control code minification.
191
- *
192
- * - `true`: Enable full minification including code compression and dead code elimination
193
- * - `false`: Disable minification (default)
194
- * - `'dce-only'`: Only perform dead code elimination without code compression
195
- * - `MinifyOptions`: Fine-grained control over minification settings
196
- *
197
- * @default false
198
- */
199
- minify?: boolean | "dce-only" | MinifyOptions;
200
- name?: string;
201
- globals?: Record<string, string> | GlobalsFunction;
202
- externalLiveBindings?: boolean;
203
- inlineDynamicImports?: boolean;
204
- /**
205
- * - Type: `((moduleId: string, meta: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue)`
206
- * - Object form is not supported.
207
- *
208
- * :::warning
209
- * - This option is deprecated. Please use `advancedChunks` instead.
210
- * - If `manualChunks` and `advancedChunks` are both specified, `manualChunks` option will be ignored.
211
- * :::
212
- *
213
- * You could use this option for migration purpose. Under the hood,
214
- *
215
- * ```js
216
- * {
217
- * manualChunks: (moduleId, meta) => {
218
- * if (moduleId.includes('node_modules')) {
219
- * return 'vendor';
220
- * }
221
- * return null;
222
- * }
223
- * }
224
- * ```
225
- *
226
- * will be transformed to
227
- *
228
- * ```js
229
- * {
230
- * advancedChunks: {
231
- * groups: [
232
- * {
233
- * name(moduleId) {
234
- * if (moduleId.includes('node_modules')) {
235
- * return 'vendor';
236
- * }
237
- * return null;
238
- * },
239
- * },
240
- * ],
241
- * }
242
- * }
243
- *
244
- * ```
245
- *
246
- * @deprecated Please use `advancedChunks` instead.
247
- */
248
- manualChunks?: (moduleId: string, meta: {
249
- getModuleInfo: (moduleId: string) => ModuleInfo | null;
250
- }) => string | NullValue;
251
- /**
252
- * Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/guide/in-depth/advanced-chunks).
253
- */
254
- advancedChunks?: {
255
- /**
256
- * - Type: `boolean`
257
- * - Default: `true`
258
- *
259
- * By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
260
- *
261
- * If you want to disable this behavior, it's recommended to both set
262
- * - `preserveEntrySignatures: false`
263
- * - `strictExecutionOrder: true`
264
- *
265
- * to avoid generating invalid chunks.
266
- */
267
- includeDependenciesRecursively?: boolean;
268
- /**
269
- * - Type: `number`
270
- *
271
- * Global fallback of [`{group}.minSize`](#advancedchunks-groups-minsize), if it's not specified in the group.
272
- */
273
- minSize?: number;
274
- /**
275
- * - Type: `number`
276
- *
277
- * Global fallback of [`{group}.maxSize`](#advancedchunks-groups-maxsize), if it's not specified in the group.
278
- */
279
- maxSize?: number;
280
- /**
281
- * - Type: `number`
282
- *
283
- * Global fallback of [`{group}.maxModuleSize`](#advancedchunks-groups-maxmodulesize), if it's not specified in the group.
284
- */
285
- maxModuleSize?: number;
286
- /**
287
- * - Type: `number`
288
- *
289
- * Global fallback of [`{group}.minModuleSize`](#advancedchunks-groups-minmodulesize), if it's not specified in the group.
290
- */
291
- minModuleSize?: number;
292
- /**
293
- * - Type: `number`
294
- *
295
- * Global fallback of [`{group}.minShareCount`](#advancedchunks-groups-minsharecount), if it's not specified in the group.
296
- */
297
- minShareCount?: number;
298
- /**
299
- * Groups to be used for advanced chunking.
300
- */
301
- groups?: {
302
- /**
303
- * - Type: `string | ((moduleId: string, ctx: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue)`
304
- *
305
- * Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
306
- *
307
- * For example,
308
- *
309
- * ```js
310
- * import { defineConfig } from 'rolldown';
311
- *
312
- * export default defineConfig({
313
- * advancedChunks: {
314
- * groups: [
315
- * {
316
- * name: 'libs',
317
- * test: /node_modules/,
318
- * },
319
- * ],
320
- * },
321
- * });
322
- * ```
323
- * will create a chunk named `libs-[hash].js` in the end.
324
- *
325
- * It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
326
- *
327
- * # Dynamic `name()`
328
- *
329
- * 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.
330
- *
331
- * Notice, each returned new name will be treated as a separate group.
332
- *
333
- * For example,
334
- *
335
- * ```js
336
- * import { defineConfig } from 'rolldown';
337
- *
338
- * export default defineConfig({
339
- * advancedChunks: {
340
- * groups: [
341
- * {
342
- * name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
343
- * minSize: 100 * 1024,
344
- * },
345
- * ],
346
- * },
347
- * });
348
- * ```
349
- *
350
- * :::warning
351
- * Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
352
- * :::
353
- */
354
- name: string | ((moduleId: string, ctx: ChunkingContext) => string | NullValue);
355
- /**
356
- * - Type: `string | RegExp | ((id: string) => boolean | undefined | void);`
357
- *
358
- * Controls which modules are captured in this group.
359
- *
360
- * - If `test` is a string, the module whose id contains the string will be captured.
361
- * - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
362
- * - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
363
- * - If `test` is empty, any module will be considered as matched.
364
- *
365
- * :::warning
366
- * When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
367
- * - ✅ Recommended: `/node_modules[\\/]react/`
368
- * - ❌ Not recommended: `/node_modules/react/`
369
- * :::
370
- */
371
- test?: StringOrRegExp | ((id: string) => boolean | undefined | void);
372
- /**
373
- * - Type: `number`
374
- * - Default: `0`
375
- *
376
- * 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.
377
- *
378
- * If two groups have the same priority, the group whose index is smaller will be chosen.
379
- *
380
- * For example,
381
- *
382
- * ```js
383
- * import { defineConfig } from 'rolldown';
384
- *
385
- * export default defineConfig({
386
- * advancedChunks: {
387
- * groups: [
388
- * {
389
- * name: 'react',
390
- * test: /node_modules[\\/]react/,
391
- * priority: 1,
392
- * },
393
- * {
394
- * name: 'other-libs',
395
- * test: /node_modules/,
396
- * priority: 2,
397
- * },
398
- * ],
399
- * });
400
- * ```
401
- *
402
- * 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.
403
- */
404
- priority?: number;
405
- /**
406
- * - Type: `number`
407
- * - Default: `0`
408
- *
409
- * 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.
410
- */
411
- minSize?: number;
412
- /**
413
- * - Type: `number`
414
- * - Default: `1`
415
- *
416
- * Controls if a module should be captured based on how many entry chunks reference it.
417
- */
418
- minShareCount?: number;
419
- /**
420
- * - Type: `number`
421
- * - Default: `Infinity`
422
- *
423
- * 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.
424
- */
425
- maxSize?: number;
426
- /**
427
- * - Type: `number`
428
- * - Default: `Infinity`
429
- *
430
- * Controls a module could only be captured if its size in bytes is smaller or equal than this value.
431
- */
432
- maxModuleSize?: number;
433
- /**
434
- * - Type: `number`
435
- * - Default: `0`
436
- *
437
- * Controls a module could only be captured if its size in bytes is larger or equal than this value.
438
- */
439
- minModuleSize?: number;
440
- }[];
441
- };
442
- /**
443
- * Control comments in the output.
444
- *
445
- * - `none`: no comments
446
- * - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
447
- */
448
- legalComments?: "none" | "inline";
449
- plugins?: RolldownOutputPluginOption;
450
- polyfillRequire?: boolean;
451
- hoistTransitiveImports?: false;
452
- preserveModules?: boolean;
453
- virtualDirname?: string;
454
- preserveModulesRoot?: string;
455
- topLevelVar?: boolean;
456
- /**
457
- * - Type: `boolean`
458
- * - Default: `false`
459
- *
460
- * Whether to minify internal exports.
461
- */
462
- minifyInternalExports?: boolean;
463
- }
464
- //#endregion
465
- //#region src/api/build.d.ts
466
- interface BuildOptions extends InputOptions {
467
- /**
468
- * Write the output to the file system
469
- *
470
- * @default true
471
- */
472
- write?: boolean;
473
- output?: OutputOptions;
474
- }
475
- declare function build(options: BuildOptions): Promise<RolldownOutput>;
476
- /**
477
- * Build multiple outputs __sequentially__.
478
- */
479
- declare function build(options: BuildOptions[]): Promise<RolldownOutput[]>;
480
- //#endregion
481
- //#region src/api/rolldown/rolldown-build.d.ts
482
- declare class RolldownBuild {
483
- #private;
484
- constructor(inputOptions: InputOptions);
485
- get closed(): boolean;
486
- generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
487
- write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
488
- close(): Promise<void>;
489
- [Symbol.asyncDispose](): Promise<void>;
490
- generateHmrPatch(changedFiles: string[]): Promise<BindingHmrUpdate[]>;
491
- hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
492
- get watchFiles(): Promise<string[]>;
493
- }
494
- //#endregion
495
- //#region src/api/rolldown/index.d.ts
496
- declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
497
- //#endregion
498
- //#region src/options/watch-options.d.ts
499
- interface WatchOptions extends InputOptions {
500
- output?: OutputOptions | OutputOptions[];
501
- }
502
- //#endregion
503
- //#region src/api/watch/watch-emitter.d.ts
504
- type WatcherEvent = "close" | "event" | "restart" | "change";
505
- type ChangeEvent$1 = "create" | "update" | "delete";
506
- type RolldownWatchBuild = BindingBundlerImpl;
507
- type RolldownWatcherEvent = {
508
- code: "START";
509
- } | {
510
- code: "BUNDLE_START";
511
- } | {
512
- code: "BUNDLE_END";
513
- duration: number;
514
- output: readonly string[];
515
- result: RolldownWatchBuild;
516
- } | {
517
- code: "END";
518
- } | {
519
- code: "ERROR";
520
- error: Error;
521
- result: RolldownWatchBuild;
522
- };
523
- declare class WatcherEmitter {
524
- listeners: Map<WatcherEvent, Array<(...parameters: any[]) => MaybePromise<void>>>;
525
- timer: any;
526
- constructor();
527
- on(event: "change", listener: (id: string, change: {
528
- event: ChangeEvent$1;
529
- }) => MaybePromise<void>): this;
530
- on(event: "event", listener: (data: RolldownWatcherEvent) => MaybePromise<void>): this;
531
- on(event: "restart" | "close", listener: () => MaybePromise<void>): this;
532
- off(event: WatcherEvent, listener: (...parameters: any[]) => MaybePromise<void>): this;
533
- clear(event: WatcherEvent): void;
534
- onEvent(event: BindingWatcherEvent): Promise<void>;
535
- close(): Promise<void>;
536
- }
537
- type RolldownWatcher = WatcherEmitter;
538
- //#endregion
539
- //#region src/api/watch/index.d.ts
540
- declare const watch: (input: WatchOptions | WatchOptions[]) => RolldownWatcher;
541
- //#endregion
542
- //#region src/log/log-handler.d.ts
543
- type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
544
- type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
545
- column: number;
546
- line: number;
547
- }) => void;
548
- type WarningHandlerWithDefault = (warning: RollupLog, defaultHandler: LoggingFunction) => void;
549
- //#endregion
550
- //#region src/options/normalized-input-options.d.ts
551
- interface NormalizedInputOptions {
552
- input: string[] | Record<string, string>;
553
- cwd: string | undefined;
554
- platform: InputOptions["platform"];
555
- shimMissingExports: boolean;
556
- context: string;
557
- }
558
- //#endregion
559
- //#region src/options/normalized-output-options.d.ts
560
- type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
561
- interface NormalizedOutputOptions {
562
- name: string | undefined;
563
- file: string | undefined;
564
- dir: string | undefined;
565
- entryFileNames: string | ChunkFileNamesFunction;
566
- chunkFileNames: string | ChunkFileNamesFunction;
567
- assetFileNames: string | AssetFileNamesFunction;
568
- format: InternalModuleFormat;
569
- exports: NonNullable<OutputOptions["exports"]>;
570
- sourcemap: boolean | "inline" | "hidden";
571
- sourcemapBaseUrl: string | undefined;
572
- cssEntryFileNames: string | ChunkFileNamesFunction;
573
- cssChunkFileNames: string | ChunkFileNamesFunction;
574
- inlineDynamicImports: boolean;
575
- externalLiveBindings: boolean;
576
- banner: AddonFunction;
577
- footer: AddonFunction;
578
- intro: AddonFunction;
579
- outro: AddonFunction;
580
- esModule: boolean | "if-default-prop";
581
- extend: boolean;
582
- globals: Record<string, string> | GlobalsFunction;
583
- hashCharacters: "base64" | "base36" | "hex";
584
- sourcemapDebugIds: boolean;
585
- sourcemapIgnoreList: SourcemapIgnoreListOption;
586
- sourcemapPathTransform: SourcemapPathTransformOption | undefined;
587
- minify: false | MinifyOptions | "dce-only";
588
- legalComments: "none" | "inline";
589
- polyfillRequire: boolean;
590
- plugins: RolldownPlugin[];
591
- preserveModules: boolean;
592
- virtualDirname: string;
593
- preserveModulesRoot?: string;
594
- topLevelVar?: boolean;
595
- minifyInternalExports?: boolean;
596
- }
597
- //#endregion
598
- //#region src/plugin/fs.d.ts
599
- interface RolldownFsModule {
600
- appendFile(path: string, data: string | Uint8Array, options?: {
601
- encoding?: BufferEncoding | null;
602
- mode?: string | number;
603
- flag?: string | number;
604
- }): Promise<void>;
605
- copyFile(source: string, destination: string, mode?: string | number): Promise<void>;
606
- mkdir(path: string, options?: {
607
- recursive?: boolean;
608
- mode?: string | number;
609
- }): Promise<void>;
610
- mkdtemp(prefix: string): Promise<string>;
611
- readdir(path: string, options?: {
612
- withFileTypes?: false;
613
- }): Promise<string[]>;
614
- readdir(path: string, options?: {
615
- withFileTypes: true;
616
- }): Promise<RolldownDirectoryEntry[]>;
617
- readFile(path: string, options?: {
618
- encoding?: null;
619
- flag?: string | number;
620
- signal?: AbortSignal;
621
- }): Promise<Uint8Array>;
622
- readFile(path: string, options?: {
623
- encoding: BufferEncoding;
624
- flag?: string | number;
625
- signal?: AbortSignal;
626
- }): Promise<string>;
627
- realpath(path: string): Promise<string>;
628
- rename(oldPath: string, newPath: string): Promise<void>;
629
- rmdir(path: string, options?: {
630
- recursive?: boolean;
631
- }): Promise<void>;
632
- stat(path: string): Promise<RolldownFileStats>;
633
- lstat(path: string): Promise<RolldownFileStats>;
634
- unlink(path: string): Promise<void>;
635
- writeFile(path: string, data: string | Uint8Array, options?: {
636
- encoding?: BufferEncoding | null;
637
- mode?: string | number;
638
- flag?: string | number;
639
- }): Promise<void>;
640
- }
641
- type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
642
- interface RolldownDirectoryEntry {
643
- isFile(): boolean;
644
- isDirectory(): boolean;
645
- isSymbolicLink(): boolean;
646
- name: string;
647
- }
648
- interface RolldownFileStats {
649
- isFile(): boolean;
650
- isDirectory(): boolean;
651
- isSymbolicLink(): boolean;
652
- size: number;
653
- mtime: Date;
654
- ctime: Date;
655
- atime: Date;
656
- birthtime: Date;
657
- }
658
- //#endregion
659
- //#region src/plugin/hook-filter.d.ts
660
- type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
661
- include?: MaybeArray<Value>;
662
- exclude?: MaybeArray<Value>;
663
- };
664
- interface FormalModuleTypeFilter {
665
- include?: ModuleType[];
666
- }
667
- type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
668
- interface HookFilter {
669
- /**
670
- * This filter is used to do a pre-test to determine whether the hook should be called.
671
- *
672
- * @example
673
- * Include all `id`s that contain `node_modules` in the path.
674
- * ```js
675
- * { id: '**'+'/node_modules/**' }
676
- * ```
677
- * @example
678
- * Include all `id`s that contain `node_modules` or `src` in the path.
679
- * ```js
680
- * { id: ['**'+'/node_modules/**', '**'+'/src/**'] }
681
- * ```
682
- * @example
683
- * Include all `id`s that start with `http`
684
- * ```js
685
- * { id: /^http/ }
686
- * ```
687
- * @example
688
- * Exclude all `id`s that contain `node_modules` in the path.
689
- * ```js
690
- * { id: { exclude: '**'+'/node_modules/**' } }
691
- * ```
692
- * @example
693
- * Formal pattern to define includes and excludes.
694
- * ```
695
- * { id : {
696
- * include: ['**'+'/foo/**', /bar/],
697
- * exclude: ['**'+'/baz/**', /qux/]
698
- * }}
699
- * ```
700
- */
701
- id?: GeneralHookFilter;
702
- moduleType?: ModuleTypeFilter;
703
- code?: GeneralHookFilter;
704
- }
705
- type TUnionWithTopLevelFilterExpressionArray<T> = T | TopLevelFilterExpression[];
706
- //#endregion
707
- //#region src/plugin/minimal-plugin-context.d.ts
708
- interface PluginContextMeta {
709
- rollupVersion: string;
710
- rolldownVersion: string;
711
- watchMode: boolean;
712
- }
713
- interface MinimalPluginContext {
714
- readonly pluginName: string;
715
- error: (e: RollupError | string) => never;
716
- info: LoggingFunction;
717
- warn: LoggingFunction;
718
- debug: LoggingFunction;
719
- meta: PluginContextMeta;
720
- }
721
- //#endregion
722
- //#region src/plugin/parallel-plugin.d.ts
723
- type ParallelPlugin = {
724
- /** @internal */
725
- _parallel: {
726
- fileUrl: string;
727
- options: unknown;
728
- };
729
- };
730
- type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
731
- declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
732
- //#endregion
733
- //#region src/plugin/plugin-context.d.ts
734
- interface EmittedAsset {
735
- type: "asset";
736
- name?: string;
737
- fileName?: string;
738
- originalFileName?: string;
739
- source: AssetSource;
740
- }
741
- interface EmittedChunk {
742
- type: "chunk";
743
- name?: string;
744
- fileName?: string;
745
- preserveSignature?: "strict" | "allow-extension" | "exports-only" | false;
746
- id: string;
747
- importer?: string;
748
- }
749
- type EmittedFile = EmittedAsset | EmittedChunk;
750
- interface PluginContextResolveOptions {
751
- isEntry?: boolean;
752
- skipSelf?: boolean;
753
- custom?: CustomPluginOptions;
754
- }
755
- type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
756
- interface PluginContext extends MinimalPluginContext {
757
- fs: RolldownFsModule;
758
- emitFile(file: EmittedFile): string;
759
- getFileName(referenceId: string): string;
760
- getModuleIds(): IterableIterator<string>;
761
- getModuleInfo: GetModuleInfo;
762
- addWatchFile(id: string): void;
763
- load(options: {
764
- id: string;
765
- resolveDependencies?: boolean;
766
- } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
767
- parse(input: string, options?: ParserOptions | undefined | null): Program;
768
- resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
769
- }
770
- //#endregion
771
- //#region src/plugin/transform-plugin-context.d.ts
772
- interface TransformPluginContext extends PluginContext {
773
- debug: LoggingFunctionWithPosition;
774
- info: LoggingFunctionWithPosition;
775
- warn: LoggingFunctionWithPosition;
776
- error(e: RollupError | string, pos?: number | {
777
- column: number;
778
- line: number;
779
- }): never;
780
- getCombinedSourcemap(): SourceMap;
781
- }
782
- //#endregion
783
- //#region src/types/module-side-effects.d.ts
784
- interface ModuleSideEffectsRule {
785
- test?: RegExp;
786
- external?: boolean;
787
- sideEffects: boolean;
788
- }
789
- type ModuleSideEffectsOption = boolean | readonly string[] | ModuleSideEffectsRule[] | ((id: string, external: boolean) => boolean | undefined) | "no-external";
790
- type TreeshakingOptions = {
791
- moduleSideEffects?: ModuleSideEffectsOption;
792
- annotations?: boolean;
793
- manualPureFunctions?: readonly string[];
794
- unknownGlobalSideEffects?: boolean;
795
- commonjs?: boolean;
796
- propertyReadSideEffects?: false | "always";
797
- propertyWriteSideEffects?: false | "always";
798
- };
799
- //#endregion
800
- //#region src/types/output-bundle.d.ts
801
- interface OutputBundle {
802
- [fileName: string]: OutputAsset | OutputChunk;
803
- }
804
- //#endregion
805
- //#region src/types/sourcemap.d.ts
806
- interface ExistingRawSourceMap {
807
- file?: string | null;
808
- mappings: string;
809
- names?: string[];
810
- sources?: (string | null)[];
811
- sourcesContent?: (string | null)[];
812
- sourceRoot?: string;
813
- version?: number;
814
- x_google_ignoreList?: number[];
815
- }
816
- type SourceMapInput = ExistingRawSourceMap | string | null;
817
- //#endregion
818
- //#region src/index.d.ts
819
- declare const VERSION: string;
820
- //#endregion
821
- //#region src/builtin-plugin/utils.d.ts
822
- declare const BuiltinClassSymbol: symbol;
823
- declare class BuiltinPlugin {
824
- name: BindingBuiltinPluginName;
825
- _options?: unknown;
826
- constructor(name: BindingBuiltinPluginName, _options?: unknown);
827
- }
828
- interface BuiltinPlugin {
829
- [BuiltinClassSymbol]: boolean;
830
- }
831
- //#endregion
832
- //#region src/constants/plugin.d.ts
833
- declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
834
- declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
835
- declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ...typeof ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, "footer", "banner", "intro", "outro"];
836
- /**
837
- * Names of all defined hooks. It's like
838
- * ```ts
839
- * type DefinedHookNames = {
840
- * options: 'options',
841
- * buildStart: 'buildStart',
842
- * ...
843
- * }
844
- * ```
845
- */
846
- type DefinedHookNames = { readonly [K in typeof ENUMERATED_PLUGIN_HOOK_NAMES[number]]: K };
847
- /**
848
- * Names of all defined hooks. It's like
849
- * ```js
850
- * const DEFINED_HOOK_NAMES ={
851
- * options: 'options',
852
- * buildStart: 'buildStart',
853
- * ...
854
- * }
855
- * ```
856
- */
857
- declare const DEFINED_HOOK_NAMES: DefinedHookNames;
858
- //#endregion
859
- //#region src/plugin/with-filter.d.ts
860
- type OverrideFilterObject = {
861
- transform?: HookFilterExtension<"transform">["filter"];
862
- resolveId?: HookFilterExtension<"resolveId">["filter"];
863
- load?: HookFilterExtension<"load">["filter"];
864
- pluginNamePattern?: StringOrRegExp[];
865
- };
866
- declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption: T, filterObject: OverrideFilterObject | OverrideFilterObject[]): T;
867
- //#endregion
868
- //#region src/plugin/index.d.ts
869
- type ModuleSideEffects = boolean | "no-treeshake" | null;
870
- type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
871
- type ImportKind = BindingHookResolveIdExtraArgs["kind"];
872
- interface CustomPluginOptions {
873
- [plugin: string]: any;
874
- }
875
- interface ModuleOptions {
876
- moduleSideEffects: ModuleSideEffects;
877
- meta: CustomPluginOptions;
878
- invalidate?: boolean;
879
- packageJsonPath?: string;
880
- }
881
- interface ResolvedId extends ModuleOptions {
882
- external: boolean | "absolute";
883
- id: string;
884
- }
885
- interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
886
- external?: boolean | "absolute" | "relative";
887
- id: string;
888
- }
889
- interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
890
- code: string;
891
- map?: SourceMapInput;
892
- moduleType?: ModuleType;
893
- }
894
- interface ResolveIdExtraOptions {
895
- custom?: CustomPluginOptions;
896
- isEntry: boolean;
897
- kind: BindingHookResolveIdExtraArgs["kind"];
898
- }
899
- type ResolveIdResult = string | NullValue | false | PartialResolvedId;
900
- type LoadResult = NullValue | string | SourceDescription;
901
- type TransformResult = NullValue | string | Partial<SourceDescription>;
902
- type RenderedChunkMeta = {
903
- chunks: Record<string, RenderedChunk>;
904
- };
905
- interface FunctionPluginHooks {
906
- [DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
907
- [DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
908
- [DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
909
- [DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
910
- [DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
911
- /**
912
- * @deprecated
913
- * This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
914
- */
915
- [DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
916
- [DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
917
- [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
918
- moduleType: ModuleType;
919
- }) => TransformResult;
920
- [DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
921
- [DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
922
- [DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
923
- [DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | {
924
- code: string;
925
- map?: SourceMapInput;
926
- };
927
- [DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
928
- [DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
929
- [DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
930
- [DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
931
- [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
932
- [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
933
- event: ChangeEvent;
934
- }) => void;
935
- [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
936
- }
937
- type ChangeEvent = "create" | "update" | "delete";
938
- type PluginOrder = "pre" | "post" | null;
939
- type ObjectHookMeta = {
940
- order?: PluginOrder;
941
- };
942
- type ObjectHook<T, O = {}> = T | ({
943
- handler: T;
944
- } & ObjectHookMeta & O);
945
- type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
946
- type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
947
- type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
948
- type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
949
- type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
950
- type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
951
- type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
952
- type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
953
- filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
954
- } : K extends "load" ? {
955
- filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
956
- } : K extends "resolveId" ? {
957
- filter?: TUnionWithTopLevelFilterExpressionArray<{
958
- id?: GeneralHookFilter<RegExp>;
959
- }>;
960
- } : K extends "renderChunk" ? {
961
- filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
962
- } : {};
963
- type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
964
- /**
965
- * @deprecated
966
- * this is only for rollup Plugin type compatibility.
967
- * hooks always work as `sequential: true`.
968
- */
969
- sequential?: boolean;
970
- } : {})> };
971
- type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
972
- type AddonHook = string | AddonHookFunction;
973
- interface OutputPlugin extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
974
- name: string;
975
- }
976
- interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
977
- api?: A;
978
- }
979
- type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
980
- type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | {
981
- name: string;
982
- } | false | RolldownPluginOption[]>;
983
- type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
984
- type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | {
985
- name: string;
986
- } | false | RolldownOutputPluginOption[]>;
987
- //#endregion
988
- //#region src/options/generated/checks-options.d.ts
989
- interface ChecksOptions {
990
- /**
991
- * Whether to emit warning when detecting circular dependency
992
- * @default false
993
- */
994
- circularDependency?: boolean;
995
- /**
996
- * Whether to emit warning when detecting eval
997
- * @default true
998
- */
999
- eval?: boolean;
1000
- /**
1001
- * Whether to emit warning when detecting missing global name
1002
- * @default true
1003
- */
1004
- missingGlobalName?: boolean;
1005
- /**
1006
- * Whether to emit warning when detecting missing name option for iife export
1007
- * @default true
1008
- */
1009
- missingNameOptionForIifeExport?: boolean;
1010
- /**
1011
- * Whether to emit warning when detecting mixed export
1012
- * @default true
1013
- */
1014
- mixedExport?: boolean;
1015
- /**
1016
- * Whether to emit warning when detecting unresolved entry
1017
- * @default true
1018
- */
1019
- unresolvedEntry?: boolean;
1020
- /**
1021
- * Whether to emit warning when detecting unresolved import
1022
- * @default true
1023
- */
1024
- unresolvedImport?: boolean;
1025
- /**
1026
- * Whether to emit warning when detecting filename conflict
1027
- * @default true
1028
- */
1029
- filenameConflict?: boolean;
1030
- /**
1031
- * Whether to emit warning when detecting common js variable in esm
1032
- * @default true
1033
- */
1034
- commonJsVariableInEsm?: boolean;
1035
- /**
1036
- * Whether to emit warning when detecting import is undefined
1037
- * @default true
1038
- */
1039
- importIsUndefined?: boolean;
1040
- /**
1041
- * Whether to emit warning when detecting empty import meta
1042
- * @default true
1043
- */
1044
- emptyImportMeta?: boolean;
1045
- /**
1046
- * Whether to emit warning when detecting configuration field conflict
1047
- * @default true
1048
- */
1049
- configurationFieldConflict?: boolean;
1050
- /**
1051
- * Whether to emit warning when detecting prefer builtin feature
1052
- * @default true
1053
- */
1054
- preferBuiltinFeature?: boolean;
1055
- }
1056
- //#endregion
1057
- //#region src/options/input-options.d.ts
1058
- type InputOption = string | string[] | Record<string, string>;
1059
- type OxcTransformOption = Omit<TransformOptions, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject">;
1060
- type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
1061
- type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
1062
- interface WatcherOptions {
1063
- skipWrite?: boolean;
1064
- buildDelay?: number;
1065
- notify?: {
1066
- pollInterval?: number;
1067
- compareContents?: boolean;
1068
- };
1069
- include?: StringOrRegExp | StringOrRegExp[];
1070
- exclude?: StringOrRegExp | StringOrRegExp[];
1071
- onInvalidate?: (id: string) => void;
1072
- clearScreen?: boolean;
1073
- }
1074
- type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
1075
- type HmrOptions = boolean | {
1076
- host?: string;
1077
- port?: number;
1078
- implement?: string;
1079
- new?: boolean;
1080
- };
1081
- type OptimizationOptions = {
1082
- /**
1083
- * Inline imported constant values during bundling instead of preserving variable references.
1084
- *
1085
- * When enabled, constant values from imported modules will be inlined at their usage sites,
1086
- * potentially reducing bundle size and improving runtime performance by eliminating variable lookups.
1087
- * **options**:
1088
- * - `true`: equivalent to `{ mode: 'all', pass: 1 }`, enabling constant inlining for all eligible constants with a single pass.
1089
- * - `false`: Disable constant inlining
1090
- * - `{ mode: 'smart' | 'all', pass?: number }`:
1091
- * - `mode: 'smart'`: Only inline constants in specific scenarios where it is likely to reduce bundle size and improve performance.
1092
- * Smart mode inlines constants in these specific scenarios:
1093
- * 1. `if (test) {} else {}` - condition expressions in if statements
1094
- * 2. `test ? a : b` - condition expressions in ternary operators
1095
- * 3. `test1 || test2` - logical OR expressions
1096
- * 4. `test1 && test2` - logical AND expressions
1097
- * 5. `test1 ?? test2` - nullish coalescing expressions
1098
- * - `mode: 'all'`: Inline all imported constants wherever they are used.
1099
- * - `pass`: Number of passes to perform for inlining constants.
1100
- *
1101
- * **example**
1102
- * ```js
1103
- * // Input files:
1104
- * // constants.js
1105
- * export const API_URL = 'https://api.example.com';
1106
- *
1107
- * // main.js
1108
- * import { API_URL } from './constants.js';
1109
- * console.log(API_URL);
1110
- *
1111
- * // With inlineConst: true, the bundled output becomes:
1112
- * console.log('https://api.example.com');
1113
- *
1114
- * // Instead of:
1115
- * const API_URL = 'https://api.example.com';
1116
- * console.log(API_URL);
1117
- * ```
1118
- *
1119
- * @default false
1120
- */
1121
- inlineConst?: boolean | {
1122
- mode?: "all" | "smart";
1123
- pass?: number;
1124
- };
1125
- };
1126
- type AttachDebugOptions = "none" | "simple" | "full";
1127
- type ChunkModulesOrder = "exec-order" | "module-id";
1128
- interface RollupJsxOptions {
1129
- mode?: "classic" | "automatic" | "preserve";
1130
- factory?: string;
1131
- fragment?: string;
1132
- importSource?: string;
1133
- jsxImportSource?: string;
1134
- }
1135
- interface InputOptions {
1136
- input?: InputOption;
1137
- plugins?: RolldownPluginOption;
1138
- external?: ExternalOption;
1139
- resolve?: {
1140
- /**
1141
- * > [!WARNING]
1142
- * > `resolve.alias` will not call `resolveId` hooks of other plugin.
1143
- * > If you want to call `resolveId` hooks of other plugin, use `aliasPlugin` from `rolldown/experimental` instead.
1144
- * > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
1145
- */
1146
- alias?: Record<string, string[] | string>;
1147
- aliasFields?: string[][];
1148
- conditionNames?: string[];
1149
- /**
1150
- * Map of extensions to alternative extensions.
1151
- *
1152
- * With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
1153
- * You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
1154
- */
1155
- extensionAlias?: Record<string, string[]>;
1156
- exportsFields?: string[][];
1157
- extensions?: string[];
1158
- mainFields?: string[];
1159
- mainFiles?: string[];
1160
- modules?: string[];
1161
- symlinks?: boolean;
1162
- /**
1163
- * @deprecated Use the top-level `tsconfig` option instead.
1164
- */
1165
- tsconfigFilename?: string;
1166
- };
1167
- cwd?: string;
1168
- /**
1169
- * Expected platform where the code run.
1170
- *
1171
- * When the platform is set to neutral:
1172
- * - When bundling is enabled the default output format is set to esm, which uses the export syntax introduced with ECMAScript 2015 (i.e. ES6). You can change the output format if this default is not appropriate.
1173
- * - The main fields setting is empty by default. If you want to use npm-style packages, you will likely have to configure this to be something else such as main for the standard main field used by node.
1174
- * - The conditions setting does not automatically include any platform-specific values.
1175
- *
1176
- * @default
1177
- * - 'node' if the format is 'cjs'
1178
- * - 'browser' for other formats
1179
- */
1180
- platform?: "node" | "browser" | "neutral";
1181
- shimMissingExports?: boolean;
1182
- treeshake?: boolean | TreeshakingOptions;
1183
- logLevel?: LogLevelOption;
1184
- onLog?: (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
1185
- onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
1186
- moduleTypes?: ModuleTypes;
1187
- experimental?: {
1188
- strictExecutionOrder?: boolean;
1189
- disableLiveBindings?: boolean;
1190
- viteMode?: boolean;
1191
- resolveNewUrlToAsset?: boolean;
1192
- hmr?: HmrOptions;
1193
- /**
1194
- * Control which order should use when rendering modules in chunk
1195
- *
1196
- * - Type: `'exec-order' | 'module-id'
1197
- * - Default: `'exec-order'`
1198
- *
1199
- * - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
1200
- * - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
1201
- * > [!NOTE]
1202
- * > 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).
1203
- */
1204
- chunkModulesOrder?: ChunkModulesOrder;
1205
- /**
1206
- * Attach debug information to the output bundle.
1207
- *
1208
- * - Type: `'none' | 'simple' | 'full'`
1209
- * - Default: `'simple'`
1210
- *
1211
- * - `none`: No debug information is attached.
1212
- * - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
1213
- * - `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.
1214
- *
1215
- * > [!WARNING]
1216
- * > You shouldn't use `full` in the production build.
1217
- */
1218
- attachDebugInfo?: AttachDebugOptions;
1219
- /**
1220
- * Enables automatic generation of a chunk import map asset during build.
1221
- *
1222
- * This map only includes chunks with hashed filenames, where keys are derived from the facade module
1223
- * name or primary chunk name. It produces stable and unique hash-based filenames, effectively preventing
1224
- * cascading cache invalidation caused by content hashes and maximizing browser cache reuse.
1225
- *
1226
- * The output defaults to `importmap.json` unless overridden via `fileName`. A base URL prefix
1227
- * (default `"/"`) can be applied to all paths. The resulting JSON is a valid import map and can be
1228
- * directly injected into HTML via `<script type="importmap">`.
1229
- *
1230
- * Example configuration snippet:
1231
- *
1232
- * ```js
1233
- * {
1234
- * experimental: {
1235
- * chunkImportMap: {
1236
- * baseUrl: '/',
1237
- * fileName: 'importmap.json'
1238
- * }
1239
- * },
1240
- * plugins: [
1241
- * {
1242
- * name: 'inject-import-map',
1243
- * generateBundle(_, bundle) {
1244
- * const chunkImportMap = bundle['importmap.json'];
1245
- * if (chunkImportMap?.type === 'asset') {
1246
- * const htmlPath = path.resolve('index.html');
1247
- * let html = fs.readFileSync(htmlPath, 'utf-8');
1248
- *
1249
- * html = html.replace(
1250
- * /<script\s+type="importmap"[^>]*>[\s\S]*?<\/script>/i,
1251
- * `<script type="importmap">${chunkImportMap.source}<\/script>`
1252
- * );
1253
- *
1254
- * fs.writeFileSync(htmlPath, html);
1255
- * delete bundle['importmap.json'];
1256
- * }
1257
- * }
1258
- * }
1259
- * ]
1260
- * }
1261
- * ```
1262
- *
1263
- * > [!NOTE]
1264
- * > 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)
1265
- */
1266
- chunkImportMap?: boolean | {
1267
- baseUrl?: string;
1268
- fileName?: string;
1269
- };
1270
- onDemandWrapping?: boolean;
1271
- /**
1272
- * Required to be used with `watch` mode.
1273
- */
1274
- incrementalBuild?: boolean;
1275
- transformHiresSourcemap?: boolean | "boundary";
1276
- };
1277
- /**
1278
- * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
1279
- *
1280
- * # Examples
1281
- *
1282
- * - Replace the global variable `IS_PROD` with `true`
1283
- *
1284
- * ```js rolldown.config.js
1285
- * export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
1286
- * ```
1287
- *
1288
- * Result:
1289
- *
1290
- * ```js
1291
- * // Input
1292
- * if (IS_PROD) {
1293
- * console.log('Production mode')
1294
- * }
1295
- *
1296
- * // After bundling
1297
- * if (true) {
1298
- * console.log('Production mode')
1299
- * }
1300
- * ```
1301
- *
1302
- * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
1303
- *
1304
- * ```js rolldown.config.js
1305
- * export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
1306
- * ```
1307
- *
1308
- * Result:
1309
- *
1310
- * ```js
1311
- * // Input
1312
- * if (process.env.NODE_ENV === 'production') {
1313
- * console.log('Production mode')
1314
- * }
1315
- *
1316
- * // After bundling
1317
- * if ('production' === 'production') {
1318
- * console.log('Production mode')
1319
- * }
1320
- *
1321
- * ```
1322
- */
1323
- define?: Record<string, string>;
1324
- /**
1325
- * Inject import statements on demand.
1326
- *
1327
- * ## Supported patterns
1328
- * ```js
1329
- * {
1330
- * // import { Promise } from 'es6-promise'
1331
- * Promise: ['es6-promise', 'Promise'],
1332
- *
1333
- * // import { Promise as P } from 'es6-promise'
1334
- * P: ['es6-promise', 'Promise'],
1335
- *
1336
- * // import $ from 'jquery'
1337
- * $: 'jquery',
1338
- *
1339
- * // import * as fs from 'node:fs'
1340
- * fs: ['node:fs', '*'],
1341
- *
1342
- * // Inject shims for property access pattern
1343
- * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
1344
- * }
1345
- * ```
1346
- */
1347
- inject?: Record<string, string | [string, string]>;
1348
- profilerNames?: boolean;
1349
- /**
1350
- * @deprecated Use {@link OxcTransformOption.jsx} instead.
1351
- *
1352
- * This top-level `jsx` option will be removed in a future release.
1353
- * It is only kept for backward compatibility and will be mapped internally to `transform.jsx`.
1354
- *
1355
- * - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
1356
- * - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
1357
- * - `"react"` enables the `classic` JSX transformer.
1358
- * - `"react-jsx"` enables the `automatic` JSX transformer.
1359
- *
1360
- * @default runtime = "automatic"
1361
- */
1362
- jsx?: false | "react" | "react-jsx" | "preserve" | RollupJsxOptions;
1363
- /**
1364
- * Configure how the code is transformed. This process happens after the `transform` hook.
1365
- *
1366
- * To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
1367
- *
1368
- * ```js
1369
- * export default defineConfig({
1370
- * transform: {
1371
- * decorator: {
1372
- * legacy: true,
1373
- * },
1374
- * },
1375
- * })
1376
- * ```
1377
- *
1378
- * For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
1379
- */
1380
- transform?: OxcTransformOption;
1381
- watch?: WatcherOptions | false;
1382
- dropLabels?: string[];
1383
- keepNames?: boolean;
1384
- checks?: ChecksOptions;
1385
- makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
1386
- debug?: {
1387
- sessionId?: string;
1388
- };
1389
- preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
1390
- optimization?: OptimizationOptions;
1391
- context?: string;
1392
- /**
1393
- * Allows you to specify where to find the TypeScript configuration file.
1394
- *
1395
- * You may provide:
1396
- * - a relative path to the configuration file. It will be resolved relative to cwd.
1397
- * - an absolute path to the configuration file.
1398
- *
1399
- * When a tsconfig path is specified, the module resolver will respect `compilerOptions.paths` from the specified `tsconfig.json`,
1400
- * and the tsconfig options will be merged with the top-level `transform` options, with the `transform` options taking precedence.
1401
- */
1402
- tsconfig?: string;
1403
- }
1404
- //#endregion
1405
- //#region src/types/rolldown-options.d.ts
1406
- interface RolldownOptions extends InputOptions {
1407
- output?: OutputOptions | OutputOptions[];
1408
- }
1409
- //#endregion
1410
- //#region src/types/config-export.d.ts
1411
- /**
1412
- * Type for `default export` of `rolldown.config.js` file.
1413
- */
1414
- type ConfigExport = RolldownOptions | RolldownOptions[];
1415
- //#endregion
1416
- //#region src/utils/define-config.d.ts
1417
- declare function defineConfig(config: RolldownOptions): RolldownOptions;
1418
- declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
1419
- declare function defineConfig(config: ConfigExport): ConfigExport;
1420
- //#endregion
1421
- 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 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 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 };