UNPKG

27.2 kBTypeScriptView Raw
1export const VERSION: string;
2
3export interface RollupError extends RollupLogProps {
4 parserError?: Error;
5 stack?: string;
6 watchFiles?: string[];
7}
8
9export interface RollupWarning extends RollupLogProps {
10 chunkName?: string;
11 cycle?: string[];
12 exportName?: string;
13 exporter?: string;
14 guess?: string;
15 importer?: string;
16 missing?: string;
17 modules?: string[];
18 names?: string[];
19 reexporter?: string;
20 source?: string;
21 sources?: string[];
22}
23
24export interface RollupLogProps {
25 code?: string;
26 frame?: string;
27 hook?: string;
28 id?: string;
29 loc?: {
30 column: number;
31 file?: string;
32 line: number;
33 };
34 message: string;
35 name?: string;
36 plugin?: string;
37 pluginCode?: string;
38 pos?: number;
39 url?: string;
40}
41
42export type SourceMapSegment =
43 | [number]
44 | [number, number, number, number]
45 | [number, number, number, number, number];
46
47export interface ExistingDecodedSourceMap {
48 file?: string;
49 mappings: SourceMapSegment[][];
50 names: string[];
51 sourceRoot?: string;
52 sources: string[];
53 sourcesContent?: string[];
54 version: number;
55}
56
57export interface ExistingRawSourceMap {
58 file?: string;
59 mappings: string;
60 names: string[];
61 sourceRoot?: string;
62 sources: string[];
63 sourcesContent?: string[];
64 version: number;
65}
66
67export type DecodedSourceMapOrMissing =
68 | {
69 mappings?: never;
70 missing: true;
71 plugin: string;
72 }
73 | ExistingDecodedSourceMap;
74
75export interface SourceMap {
76 file: string;
77 mappings: string;
78 names: string[];
79 sources: string[];
80 sourcesContent: string[];
81 version: number;
82 toString(): string;
83 toUrl(): string;
84}
85
86export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
87
88type PartialNull<T> = {
89 [P in keyof T]: T[P] | null;
90};
91
92interface ModuleOptions {
93 meta: CustomPluginOptions;
94 moduleSideEffects: boolean | 'no-treeshake';
95 syntheticNamedExports: boolean | string;
96}
97
98export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
99 ast?: AcornNode;
100 code: string;
101 map?: SourceMapInput;
102}
103
104export interface TransformModuleJSON {
105 ast?: AcornNode;
106 code: string;
107 // note if plugins use new this.cache to opt-out auto transform cache
108 customTransformCache: boolean;
109 originalCode: string;
110 originalSourcemap: ExistingDecodedSourceMap | null;
111 sourcemapChain: DecodedSourceMapOrMissing[];
112 transformDependencies: string[];
113}
114
115export interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
116 ast: AcornNode;
117 dependencies: string[];
118 id: string;
119 resolvedIds: ResolvedIdMap;
120 transformFiles: EmittedFile[] | undefined;
121}
122
123export interface PluginCache {
124 delete(id: string): boolean;
125 get<T = any>(id: string): T;
126 has(id: string): boolean;
127 set<T = any>(id: string, value: T): void;
128}
129
130export interface MinimalPluginContext {
131 meta: PluginContextMeta;
132}
133
134export interface EmittedAsset {
135 fileName?: string;
136 name?: string;
137 source?: string | Uint8Array;
138 type: 'asset';
139}
140
141export interface EmittedChunk {
142 fileName?: string;
143 id: string;
144 implicitlyLoadedAfterOneOf?: string[];
145 importer?: string;
146 name?: string;
147 preserveSignature?: PreserveEntrySignaturesOption;
148 type: 'chunk';
149}
150
151export type EmittedFile = EmittedAsset | EmittedChunk;
152
153export type EmitAsset = (name: string, source?: string | Uint8Array) => string;
154
155export type EmitChunk = (id: string, options?: { name?: string }) => string;
156
157export type EmitFile = (emittedFile: EmittedFile) => string;
158
159interface ModuleInfo extends ModuleOptions {
160 ast: AcornNode | null;
161 code: string | null;
162 dynamicImporters: readonly string[];
163 dynamicallyImportedIdResolutions: readonly ResolvedId[];
164 dynamicallyImportedIds: readonly string[];
165 hasDefaultExport: boolean | null;
166 /** @deprecated Use `moduleSideEffects` instead */
167 hasModuleSideEffects: boolean | 'no-treeshake';
168 id: string;
169 implicitlyLoadedAfterOneOf: readonly string[];
170 implicitlyLoadedBefore: readonly string[];
171 importedIdResolutions: readonly ResolvedId[];
172 importedIds: readonly string[];
173 importers: readonly string[];
174 isEntry: boolean;
175 isExternal: boolean;
176 isIncluded: boolean | null;
177}
178
179export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
180
181export interface CustomPluginOptions {
182 [plugin: string]: any;
183}
184
185export interface PluginContext extends MinimalPluginContext {
186 addWatchFile: (id: string) => void;
187 cache: PluginCache;
188 /** @deprecated Use `this.emitFile` instead */
189 emitAsset: EmitAsset;
190 /** @deprecated Use `this.emitFile` instead */
191 emitChunk: EmitChunk;
192 emitFile: EmitFile;
193 error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
194 /** @deprecated Use `this.getFileName` instead */
195 getAssetFileName: (assetReferenceId: string) => string;
196 /** @deprecated Use `this.getFileName` instead */
197 getChunkFileName: (chunkReferenceId: string) => string;
198 getFileName: (fileReferenceId: string) => string;
199 getModuleIds: () => IterableIterator<string>;
200 getModuleInfo: GetModuleInfo;
201 getWatchFiles: () => string[];
202 /** @deprecated Use `this.resolve` instead */
203 isExternal: IsExternal;
204 load: (
205 options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
206 ) => Promise<ModuleInfo>;
207 /** @deprecated Use `this.getModuleIds` instead */
208 moduleIds: IterableIterator<string>;
209 parse: (input: string, options?: any) => AcornNode;
210 resolve: (
211 source: string,
212 importer?: string,
213 options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
214 ) => Promise<ResolvedId | null>;
215 /** @deprecated Use `this.resolve` instead */
216 resolveId: (source: string, importer?: string) => Promise<string | null>;
217 setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
218 warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
219}
220
221export interface PluginContextMeta {
222 rollupVersion: string;
223 watchMode: boolean;
224}
225
226export interface ResolvedId extends ModuleOptions {
227 external: boolean | 'absolute';
228 id: string;
229}
230
231export interface ResolvedIdMap {
232 [key: string]: ResolvedId;
233}
234
235interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
236 external?: boolean | 'absolute' | 'relative';
237 id: string;
238}
239
240export type ResolveIdResult = string | false | null | void | PartialResolvedId;
241
242export type ResolveIdHook = (
243 this: PluginContext,
244 source: string,
245 importer: string | undefined,
246 options: { custom?: CustomPluginOptions; isEntry: boolean }
247) => Promise<ResolveIdResult> | ResolveIdResult;
248
249export type ShouldTransformCachedModuleHook = (
250 this: PluginContext,
251 options: {
252 ast: AcornNode;
253 code: string;
254 id: string;
255 meta: CustomPluginOptions;
256 moduleSideEffects: boolean | 'no-treeshake';
257 resolvedSources: ResolvedIdMap;
258 syntheticNamedExports: boolean | string;
259 }
260) => Promise<boolean> | boolean;
261
262export type IsExternal = (
263 source: string,
264 importer: string | undefined,
265 isResolved: boolean
266) => boolean;
267
268export type IsPureModule = (id: string) => boolean | null | void;
269
270export type HasModuleSideEffects = (id: string, external: boolean) => boolean;
271
272type LoadResult = SourceDescription | string | null | void;
273
274export type LoadHook = (this: PluginContext, id: string) => Promise<LoadResult> | LoadResult;
275
276export interface TransformPluginContext extends PluginContext {
277 getCombinedSourcemap: () => SourceMap;
278}
279
280export type TransformResult = string | null | void | Partial<SourceDescription>;
281
282export type TransformHook = (
283 this: TransformPluginContext,
284 code: string,
285 id: string
286) => Promise<TransformResult> | TransformResult;
287
288export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => Promise<void> | void;
289
290export type RenderChunkHook = (
291 this: PluginContext,
292 code: string,
293 chunk: RenderedChunk,
294 options: NormalizedOutputOptions
295) =>
296 | Promise<{ code: string; map?: SourceMapInput } | null>
297 | { code: string; map?: SourceMapInput }
298 | string
299 | null
300 | undefined;
301
302export type ResolveDynamicImportHook = (
303 this: PluginContext,
304 specifier: string | AcornNode,
305 importer: string
306) => Promise<ResolveIdResult> | ResolveIdResult;
307
308export type ResolveImportMetaHook = (
309 this: PluginContext,
310 prop: string | null,
311 options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
312) => string | null | void;
313
314export type ResolveAssetUrlHook = (
315 this: PluginContext,
316 options: {
317 assetFileName: string;
318 chunkId: string;
319 format: InternalModuleFormat;
320 moduleId: string;
321 relativeAssetPath: string;
322 }
323) => string | null | void;
324
325export type ResolveFileUrlHook = (
326 this: PluginContext,
327 options: {
328 assetReferenceId: string | null;
329 chunkId: string;
330 chunkReferenceId: string | null;
331 fileName: string;
332 format: InternalModuleFormat;
333 moduleId: string;
334 referenceId: string;
335 relativePath: string;
336 }
337) => string | null | void;
338
339export type AddonHookFunction = (this: PluginContext) => string | Promise<string>;
340export type AddonHook = string | AddonHookFunction;
341
342export type ChangeEvent = 'create' | 'update' | 'delete';
343export type WatchChangeHook = (
344 this: PluginContext,
345 id: string,
346 change: { event: ChangeEvent }
347) => Promise<void> | void;
348
349/**
350 * use this type for plugin annotation
351 * @example
352 * ```ts
353 * interface Options {
354 * ...
355 * }
356 * const myPlugin: PluginImpl<Options> = (options = {}) => { ... }
357 * ```
358 */
359// eslint-disable-next-line @typescript-eslint/ban-types
360export type PluginImpl<O extends object = object> = (options?: O) => Plugin;
361
362export interface OutputBundle {
363 [fileName: string]: OutputAsset | OutputChunk;
364}
365
366export interface FilePlaceholder {
367 type: 'placeholder';
368}
369
370export interface OutputBundleWithPlaceholders {
371 [fileName: string]: OutputAsset | OutputChunk | FilePlaceholder;
372}
373
374export interface PluginHooks extends OutputPluginHooks {
375 buildEnd: (this: PluginContext, err?: Error) => Promise<void> | void;
376 buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise<void> | void;
377 closeBundle: (this: PluginContext) => Promise<void> | void;
378 closeWatcher: (this: PluginContext) => Promise<void> | void;
379 load: LoadHook;
380 moduleParsed: ModuleParsedHook;
381 options: (
382 this: MinimalPluginContext,
383 options: InputOptions
384 ) => Promise<InputOptions | null | void> | InputOptions | null | void;
385 resolveDynamicImport: ResolveDynamicImportHook;
386 resolveId: ResolveIdHook;
387 shouldTransformCachedModule: ShouldTransformCachedModuleHook;
388 transform: TransformHook;
389 watchChange: WatchChangeHook;
390}
391
392interface OutputPluginHooks {
393 augmentChunkHash: (this: PluginContext, chunk: PreRenderedChunk) => string | void;
394 generateBundle: (
395 this: PluginContext,
396 options: NormalizedOutputOptions,
397 bundle: OutputBundle,
398 isWrite: boolean
399 ) => void | Promise<void>;
400 outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | null | void;
401 renderChunk: RenderChunkHook;
402 renderDynamicImport: (
403 this: PluginContext,
404 options: {
405 customResolution: string | null;
406 format: InternalModuleFormat;
407 moduleId: string;
408 targetModuleId: string | null;
409 }
410 ) => { left: string; right: string } | null | void;
411 renderError: (this: PluginContext, err?: Error) => Promise<void> | void;
412 renderStart: (
413 this: PluginContext,
414 outputOptions: NormalizedOutputOptions,
415 inputOptions: NormalizedInputOptions
416 ) => Promise<void> | void;
417 /** @deprecated Use `resolveFileUrl` instead */
418 resolveAssetUrl: ResolveAssetUrlHook;
419 resolveFileUrl: ResolveFileUrlHook;
420 resolveImportMeta: ResolveImportMetaHook;
421 writeBundle: (
422 this: PluginContext,
423 options: NormalizedOutputOptions,
424 bundle: OutputBundle
425 ) => void | Promise<void>;
426}
427
428export type AsyncPluginHooks =
429 | 'options'
430 | 'buildEnd'
431 | 'buildStart'
432 | 'generateBundle'
433 | 'load'
434 | 'moduleParsed'
435 | 'renderChunk'
436 | 'renderError'
437 | 'renderStart'
438 | 'resolveDynamicImport'
439 | 'resolveId'
440 | 'shouldTransformCachedModule'
441 | 'transform'
442 | 'writeBundle'
443 | 'closeBundle'
444 | 'closeWatcher'
445 | 'watchChange';
446
447export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro';
448
449export type SyncPluginHooks = Exclude<keyof PluginHooks, AsyncPluginHooks>;
450
451export type FirstPluginHooks =
452 | 'load'
453 | 'renderDynamicImport'
454 | 'resolveAssetUrl'
455 | 'resolveDynamicImport'
456 | 'resolveFileUrl'
457 | 'resolveId'
458 | 'resolveImportMeta'
459 | 'shouldTransformCachedModule';
460
461export type SequentialPluginHooks =
462 | 'augmentChunkHash'
463 | 'generateBundle'
464 | 'options'
465 | 'outputOptions'
466 | 'renderChunk'
467 | 'transform';
468
469export type ParallelPluginHooks =
470 | 'banner'
471 | 'buildEnd'
472 | 'buildStart'
473 | 'footer'
474 | 'intro'
475 | 'moduleParsed'
476 | 'outro'
477 | 'renderError'
478 | 'renderStart'
479 | 'writeBundle'
480 | 'closeBundle'
481 | 'closeWatcher'
482 | 'watchChange';
483
484interface OutputPluginValueHooks {
485 banner: AddonHook;
486 cacheKey: string;
487 footer: AddonHook;
488 intro: AddonHook;
489 outro: AddonHook;
490}
491
492export interface Plugin extends Partial<PluginHooks>, Partial<OutputPluginValueHooks> {
493 // for inter-plugin communication
494 api?: any;
495 name: string;
496}
497
498export interface OutputPlugin extends Partial<OutputPluginHooks>, Partial<OutputPluginValueHooks> {
499 name: string;
500}
501
502type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
503
504export interface NormalizedTreeshakingOptions {
505 annotations: boolean;
506 correctVarValueBeforeDeclaration: boolean;
507 moduleSideEffects: HasModuleSideEffects;
508 propertyReadSideEffects: boolean | 'always';
509 tryCatchDeoptimization: boolean;
510 unknownGlobalSideEffects: boolean;
511}
512
513export interface TreeshakingOptions
514 extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
515 moduleSideEffects?: ModuleSideEffectsOption;
516 preset?: TreeshakingPreset;
517 /** @deprecated Use `moduleSideEffects` instead */
518 pureExternalModules?: PureModulesOption;
519}
520
521interface GetManualChunkApi {
522 getModuleIds: () => IterableIterator<string>;
523 getModuleInfo: GetModuleInfo;
524}
525export type GetManualChunk = (id: string, api: GetManualChunkApi) => string | null | void;
526
527export type ExternalOption =
528 | (string | RegExp)[]
529 | string
530 | RegExp
531 | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | void);
532export type PureModulesOption = boolean | string[] | IsPureModule;
533export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
534export type InputOption = string | string[] | { [entryAlias: string]: string };
535export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
536export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
537export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
538export type SourcemapPathTransformOption = (
539 relativeSourcePath: string,
540 sourcemapPath: string
541) => string;
542
543export interface InputOptions {
544 acorn?: Record<string, unknown>;
545 acornInjectPlugins?: (() => unknown)[] | (() => unknown);
546 cache?: false | RollupCache;
547 context?: string;
548 experimentalCacheExpiry?: number;
549 external?: ExternalOption;
550 /** @deprecated Use the "inlineDynamicImports" output option instead. */
551 inlineDynamicImports?: boolean;
552 input?: InputOption;
553 makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
554 /** @deprecated Use the "manualChunks" output option instead. */
555 manualChunks?: ManualChunksOption;
556 maxParallelFileOps?: number;
557 /** @deprecated Use the "maxParallelFileOps" option instead. */
558 maxParallelFileReads?: number;
559 moduleContext?: ((id: string) => string | null | void) | { [id: string]: string };
560 onwarn?: WarningHandlerWithDefault;
561 perf?: boolean;
562 plugins?: (Plugin | null | false | undefined)[];
563 preserveEntrySignatures?: PreserveEntrySignaturesOption;
564 /** @deprecated Use the "preserveModules" output option instead. */
565 preserveModules?: boolean;
566 preserveSymlinks?: boolean;
567 shimMissingExports?: boolean;
568 strictDeprecations?: boolean;
569 treeshake?: boolean | TreeshakingPreset | TreeshakingOptions;
570 watch?: WatcherOptions | false;
571}
572
573export interface NormalizedInputOptions {
574 acorn: Record<string, unknown>;
575 acornInjectPlugins: (() => unknown)[];
576 cache: false | undefined | RollupCache;
577 context: string;
578 experimentalCacheExpiry: number;
579 external: IsExternal;
580 /** @deprecated Use the "inlineDynamicImports" output option instead. */
581 inlineDynamicImports: boolean | undefined;
582 input: string[] | { [entryAlias: string]: string };
583 makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
584 /** @deprecated Use the "manualChunks" output option instead. */
585 manualChunks: ManualChunksOption | undefined;
586 maxParallelFileOps: number;
587 /** @deprecated Use the "maxParallelFileOps" option instead. */
588 maxParallelFileReads: number;
589 moduleContext: (id: string) => string;
590 onwarn: WarningHandler;
591 perf: boolean;
592 plugins: Plugin[];
593 preserveEntrySignatures: PreserveEntrySignaturesOption;
594 /** @deprecated Use the "preserveModules" output option instead. */
595 preserveModules: boolean | undefined;
596 preserveSymlinks: boolean;
597 shimMissingExports: boolean;
598 strictDeprecations: boolean;
599 treeshake: false | NormalizedTreeshakingOptions;
600}
601
602export type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
603
604export type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
605
606type GeneratedCodePreset = 'es5' | 'es2015';
607
608interface NormalizedGeneratedCodeOptions {
609 arrowFunctions: boolean;
610 constBindings: boolean;
611 objectShorthand: boolean;
612 reservedNamesAsProps: boolean;
613 symbols: boolean;
614}
615
616interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
617 preset?: GeneratedCodePreset;
618}
619
620export type OptionsPaths = Record<string, string> | ((id: string) => string);
621
622export type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly';
623
624export type GetInterop = (id: string | null) => InteropType;
625
626export type AmdOptions = (
627 | {
628 autoId?: false;
629 id: string;
630 }
631 | {
632 autoId: true;
633 basePath?: string;
634 id?: undefined;
635 }
636 | {
637 autoId?: false;
638 id?: undefined;
639 }
640) & {
641 define?: string;
642};
643
644export type NormalizedAmdOptions = (
645 | {
646 autoId: false;
647 id?: string;
648 }
649 | {
650 autoId: true;
651 basePath: string;
652 }
653) & {
654 define: string;
655};
656
657export interface OutputOptions {
658 amd?: AmdOptions;
659 assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
660 banner?: string | (() => string | Promise<string>);
661 chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
662 compact?: boolean;
663 // only required for bundle.write
664 dir?: string;
665 /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
666 dynamicImportFunction?: string;
667 entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
668 esModule?: boolean;
669 exports?: 'default' | 'named' | 'none' | 'auto';
670 extend?: boolean;
671 externalLiveBindings?: boolean;
672 // only required for bundle.write
673 file?: string;
674 footer?: string | (() => string | Promise<string>);
675 format?: ModuleFormat;
676 freeze?: boolean;
677 generatedCode?: GeneratedCodePreset | GeneratedCodeOptions;
678 globals?: GlobalsOption;
679 hoistTransitiveImports?: boolean;
680 indent?: string | boolean;
681 inlineDynamicImports?: boolean;
682 interop?: InteropType | GetInterop;
683 intro?: string | (() => string | Promise<string>);
684 manualChunks?: ManualChunksOption;
685 minifyInternalExports?: boolean;
686 name?: string;
687 /** @deprecated Use "generatedCode.symbols" instead. */
688 namespaceToStringTag?: boolean;
689 noConflict?: boolean;
690 outro?: string | (() => string | Promise<string>);
691 paths?: OptionsPaths;
692 plugins?: (OutputPlugin | null | false | undefined)[];
693 /** @deprecated Use "generatedCode.constBindings" instead. */
694 preferConst?: boolean;
695 preserveModules?: boolean;
696 preserveModulesRoot?: string;
697 sanitizeFileName?: boolean | ((fileName: string) => string);
698 sourcemap?: boolean | 'inline' | 'hidden';
699 sourcemapBaseUrl?: string;
700 sourcemapExcludeSources?: boolean;
701 sourcemapFile?: string;
702 sourcemapPathTransform?: SourcemapPathTransformOption;
703 strict?: boolean;
704 systemNullSetters?: boolean;
705 validate?: boolean;
706}
707
708export interface NormalizedOutputOptions {
709 amd: NormalizedAmdOptions;
710 assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
711 banner: () => string | Promise<string>;
712 chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
713 compact: boolean;
714 dir: string | undefined;
715 /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
716 dynamicImportFunction: string | undefined;
717 entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
718 esModule: boolean;
719 exports: 'default' | 'named' | 'none' | 'auto';
720 extend: boolean;
721 externalLiveBindings: boolean;
722 file: string | undefined;
723 footer: () => string | Promise<string>;
724 format: InternalModuleFormat;
725 freeze: boolean;
726 generatedCode: NormalizedGeneratedCodeOptions;
727 globals: GlobalsOption;
728 hoistTransitiveImports: boolean;
729 indent: true | string;
730 inlineDynamicImports: boolean;
731 interop: GetInterop;
732 intro: () => string | Promise<string>;
733 manualChunks: ManualChunksOption;
734 minifyInternalExports: boolean;
735 name: string | undefined;
736 namespaceToStringTag: boolean;
737 noConflict: boolean;
738 outro: () => string | Promise<string>;
739 paths: OptionsPaths;
740 plugins: OutputPlugin[];
741 /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
742 preferConst: boolean;
743 preserveModules: boolean;
744 preserveModulesRoot: string | undefined;
745 sanitizeFileName: (fileName: string) => string;
746 sourcemap: boolean | 'inline' | 'hidden';
747 sourcemapBaseUrl: string | undefined;
748 sourcemapExcludeSources: boolean;
749 sourcemapFile: string | undefined;
750 sourcemapPathTransform: SourcemapPathTransformOption | undefined;
751 strict: boolean;
752 systemNullSetters: boolean;
753 validate: boolean;
754}
755
756export type WarningHandlerWithDefault = (
757 warning: RollupWarning,
758 defaultHandler: WarningHandler
759) => void;
760export type WarningHandler = (warning: RollupWarning) => void;
761
762export interface SerializedTimings {
763 [label: string]: [number, number, number];
764}
765
766export interface PreRenderedAsset {
767 name: string | undefined;
768 source: string | Uint8Array;
769 type: 'asset';
770}
771
772export interface OutputAsset extends PreRenderedAsset {
773 fileName: string;
774 /** @deprecated Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead */
775 isAsset: true;
776}
777
778export interface RenderedModule {
779 code: string | null;
780 originalLength: number;
781 removedExports: string[];
782 renderedExports: string[];
783 renderedLength: number;
784}
785
786export interface PreRenderedChunk {
787 exports: string[];
788 facadeModuleId: string | null;
789 isDynamicEntry: boolean;
790 isEntry: boolean;
791 isImplicitEntry: boolean;
792 modules: {
793 [id: string]: RenderedModule;
794 };
795 name: string;
796 type: 'chunk';
797}
798
799export interface RenderedChunk extends PreRenderedChunk {
800 code?: string;
801 dynamicImports: string[];
802 fileName: string;
803 implicitlyLoadedBefore: string[];
804 importedBindings: {
805 [imported: string]: string[];
806 };
807 imports: string[];
808 map?: SourceMap;
809 referencedFiles: string[];
810}
811
812export interface OutputChunk extends RenderedChunk {
813 code: string;
814}
815
816export interface SerializablePluginCache {
817 [key: string]: [number, any];
818}
819
820export interface RollupCache {
821 modules: ModuleJSON[];
822 plugins?: Record<string, SerializablePluginCache>;
823}
824
825export interface RollupOutput {
826 output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
827}
828
829export interface RollupBuild {
830 cache: RollupCache | undefined;
831 close: () => Promise<void>;
832 closed: boolean;
833 generate: (outputOptions: OutputOptions) => Promise<RollupOutput>;
834 getTimings?: () => SerializedTimings;
835 watchFiles: string[];
836 write: (options: OutputOptions) => Promise<RollupOutput>;
837}
838
839export interface RollupOptions extends InputOptions {
840 // This is included for compatibility with config files but ignored by rollup.rollup
841 output?: OutputOptions | OutputOptions[];
842}
843
844export interface MergedRollupOptions extends InputOptions {
845 output: OutputOptions[];
846}
847
848export function rollup(options: RollupOptions): Promise<RollupBuild>;
849
850export interface ChokidarOptions {
851 alwaysStat?: boolean;
852 atomic?: boolean | number;
853 awaitWriteFinish?:
854 | {
855 pollInterval?: number;
856 stabilityThreshold?: number;
857 }
858 | boolean;
859 binaryInterval?: number;
860 cwd?: string;
861 depth?: number;
862 disableGlobbing?: boolean;
863 followSymlinks?: boolean;
864 ignoreInitial?: boolean;
865 ignorePermissionErrors?: boolean;
866 ignored?: any;
867 interval?: number;
868 persistent?: boolean;
869 useFsEvents?: boolean;
870 usePolling?: boolean;
871}
872
873export type RollupWatchHooks = 'onError' | 'onStart' | 'onBundleStart' | 'onBundleEnd' | 'onEnd';
874
875export interface WatcherOptions {
876 buildDelay?: number;
877 chokidar?: ChokidarOptions;
878 clearScreen?: boolean;
879 exclude?: string | RegExp | (string | RegExp)[];
880 include?: string | RegExp | (string | RegExp)[];
881 skipWrite?: boolean;
882}
883
884export interface RollupWatchOptions extends InputOptions {
885 output?: OutputOptions | OutputOptions[];
886 watch?: WatcherOptions | false;
887}
888
889interface TypedEventEmitter<T extends { [event: string]: (...args: any) => any }> {
890 addListener<K extends keyof T>(event: K, listener: T[K]): this;
891 emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
892 eventNames(): Array<keyof T>;
893 getMaxListeners(): number;
894 listenerCount(type: keyof T): number;
895 listeners<K extends keyof T>(event: K): Array<T[K]>;
896 off<K extends keyof T>(event: K, listener: T[K]): this;
897 on<K extends keyof T>(event: K, listener: T[K]): this;
898 once<K extends keyof T>(event: K, listener: T[K]): this;
899 prependListener<K extends keyof T>(event: K, listener: T[K]): this;
900 prependOnceListener<K extends keyof T>(event: K, listener: T[K]): this;
901 rawListeners<K extends keyof T>(event: K): Array<T[K]>;
902 removeAllListeners<K extends keyof T>(event?: K): this;
903 removeListener<K extends keyof T>(event: K, listener: T[K]): this;
904 setMaxListeners(n: number): this;
905}
906
907export interface RollupAwaitingEmitter<T extends { [event: string]: (...args: any) => any }>
908 extends TypedEventEmitter<T> {
909 close(): Promise<void>;
910 emitAndAwait<K extends keyof T>(event: K, ...args: Parameters<T[K]>): Promise<ReturnType<T[K]>[]>;
911 /**
912 * Registers an event listener that will be awaited before Rollup continues
913 * for events emitted via emitAndAwait. All listeners will be awaited in
914 * parallel while rejections are tracked via Promise.all.
915 * Listeners are removed automatically when removeAwaited is called, which
916 * happens automatically after each run.
917 */
918 onCurrentAwaited<K extends keyof T>(
919 event: K,
920 listener: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
921 ): this;
922 removeAwaited(): this;
923}
924
925export type RollupWatcherEvent =
926 | { code: 'START' }
927 | { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
928 | {
929 code: 'BUNDLE_END';
930 duration: number;
931 input?: InputOption;
932 output: readonly string[];
933 result: RollupBuild;
934 }
935 | { code: 'END' }
936 | { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
937
938export type RollupWatcher = RollupAwaitingEmitter<{
939 change: (id: string, change: { event: ChangeEvent }) => void;
940 close: () => void;
941 event: (event: RollupWatcherEvent) => void;
942 restart: () => void;
943}>;
944
945export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher;
946
947interface AcornNode {
948 end: number;
949 start: number;
950 type: string;
951}
952
953export function defineConfig(options: RollupOptions): RollupOptions;
954export function defineConfig(options: RollupOptions[]): RollupOptions[];