UNPKG

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