UNPKG

24.9 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; 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 }
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 TreeshakingOptions {
481 annotations?: boolean;
482 correctVarValueBeforeDeclaration?: boolean;
483 moduleSideEffects?: ModuleSideEffectsOption;
484 preset?: TreeshakingPreset;
485 propertyReadSideEffects?: boolean | 'always';
486 /** @deprecated Use `moduleSideEffects` instead */
487 pureExternalModules?: PureModulesOption;
488 tryCatchDeoptimization?: boolean;
489 unknownGlobalSideEffects?: boolean;
490}
491
492export interface NormalizedTreeshakingOptions {
493 annotations: boolean;
494 correctVarValueBeforeDeclaration: boolean;
495 moduleSideEffects: HasModuleSideEffects;
496 propertyReadSideEffects: boolean | 'always';
497 tryCatchDeoptimization: boolean;
498 unknownGlobalSideEffects: boolean;
499}
500
501interface GetManualChunkApi {
502 getModuleIds: () => IterableIterator<string>;
503 getModuleInfo: GetModuleInfo;
504}
505export type GetManualChunk = (id: string, api: GetManualChunkApi) => string | null | undefined;
506
507export type ExternalOption =
508 | (string | RegExp)[]
509 | string
510 | RegExp
511 | ((
512 source: string,
513 importer: string | undefined,
514 isResolved: boolean
515 ) => boolean | null | undefined);
516export type PureModulesOption = boolean | string[] | IsPureModule;
517export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
518export type InputOption = string | string[] | { [entryAlias: string]: string };
519export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
520export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
521export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
522export type SourcemapPathTransformOption = (
523 relativeSourcePath: string,
524 sourcemapPath: string
525) => string;
526
527export interface InputOptions {
528 acorn?: Record<string, unknown>;
529 acornInjectPlugins?: (() => unknown)[] | (() => unknown);
530 cache?: false | RollupCache;
531 context?: string;
532 experimentalCacheExpiry?: number;
533 external?: ExternalOption;
534 /** @deprecated Use the "inlineDynamicImports" output option instead. */
535 inlineDynamicImports?: boolean;
536 input?: InputOption;
537 makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
538 /** @deprecated Use the "manualChunks" output option instead. */
539 manualChunks?: ManualChunksOption;
540 maxParallelFileReads?: number;
541 moduleContext?: ((id: string) => string | null | undefined) | { [id: string]: string };
542 onwarn?: WarningHandlerWithDefault;
543 perf?: boolean;
544 plugins?: (Plugin | null | false | undefined)[];
545 preserveEntrySignatures?: PreserveEntrySignaturesOption;
546 /** @deprecated Use the "preserveModules" output option instead. */
547 preserveModules?: boolean;
548 preserveSymlinks?: boolean;
549 shimMissingExports?: boolean;
550 strictDeprecations?: boolean;
551 treeshake?: boolean | TreeshakingPreset | TreeshakingOptions;
552 watch?: WatcherOptions | false;
553}
554
555export interface NormalizedInputOptions {
556 acorn: Record<string, unknown>;
557 acornInjectPlugins: (() => unknown)[];
558 cache: false | undefined | RollupCache;
559 context: string;
560 experimentalCacheExpiry: number;
561 external: IsExternal;
562 /** @deprecated Use the "inlineDynamicImports" output option instead. */
563 inlineDynamicImports: boolean | undefined;
564 input: string[] | { [entryAlias: string]: string };
565 makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
566 /** @deprecated Use the "manualChunks" output option instead. */
567 manualChunks: ManualChunksOption | undefined;
568 maxParallelFileReads: number;
569 moduleContext: (id: string) => string;
570 onwarn: WarningHandler;
571 perf: boolean;
572 plugins: Plugin[];
573 preserveEntrySignatures: PreserveEntrySignaturesOption;
574 /** @deprecated Use the "preserveModules" output option instead. */
575 preserveModules: boolean | undefined;
576 preserveSymlinks: boolean;
577 shimMissingExports: boolean;
578 strictDeprecations: boolean;
579 treeshake: false | NormalizedTreeshakingOptions;
580}
581
582export type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
583
584export type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
585
586export type OptionsPaths = Record<string, string> | ((id: string) => string);
587
588export type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly';
589
590export type GetInterop = (id: string | null) => InteropType;
591
592export type AmdOptions = (
593 | {
594 autoId?: false;
595 id: string;
596 }
597 | {
598 autoId: true;
599 basePath?: string;
600 id?: undefined;
601 }
602 | {
603 autoId?: false;
604 id?: undefined;
605 }
606) & {
607 define?: string;
608};
609
610export type NormalizedAmdOptions = (
611 | {
612 autoId: false;
613 id?: string;
614 }
615 | {
616 autoId: true;
617 basePath: string;
618 }
619) & {
620 define: string;
621};
622
623export interface OutputOptions {
624 amd?: AmdOptions;
625 assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
626 banner?: string | (() => string | Promise<string>);
627 chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
628 compact?: boolean;
629 // only required for bundle.write
630 dir?: string;
631 /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
632 dynamicImportFunction?: string;
633 entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
634 esModule?: boolean;
635 exports?: 'default' | 'named' | 'none' | 'auto';
636 extend?: boolean;
637 externalLiveBindings?: boolean;
638 // only required for bundle.write
639 file?: string;
640 footer?: string | (() => string | Promise<string>);
641 format?: ModuleFormat;
642 freeze?: boolean;
643 globals?: GlobalsOption;
644 hoistTransitiveImports?: boolean;
645 indent?: string | boolean;
646 inlineDynamicImports?: boolean;
647 interop?: InteropType | GetInterop;
648 intro?: string | (() => string | Promise<string>);
649 manualChunks?: ManualChunksOption;
650 minifyInternalExports?: boolean;
651 name?: string;
652 namespaceToStringTag?: boolean;
653 noConflict?: boolean;
654 outro?: string | (() => string | Promise<string>);
655 paths?: OptionsPaths;
656 plugins?: (OutputPlugin | null | false | undefined)[];
657 preferConst?: boolean;
658 preserveModules?: boolean;
659 preserveModulesRoot?: string;
660 sanitizeFileName?: boolean | ((fileName: string) => string);
661 sourcemap?: boolean | 'inline' | 'hidden';
662 sourcemapExcludeSources?: boolean;
663 sourcemapFile?: string;
664 sourcemapPathTransform?: SourcemapPathTransformOption;
665 strict?: boolean;
666 systemNullSetters?: boolean;
667 validate?: boolean;
668}
669
670export interface NormalizedOutputOptions {
671 amd: NormalizedAmdOptions;
672 assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
673 banner: () => string | Promise<string>;
674 chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
675 compact: boolean;
676 dir: string | undefined;
677 /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
678 dynamicImportFunction: string | undefined;
679 entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
680 esModule: boolean;
681 exports: 'default' | 'named' | 'none' | 'auto';
682 extend: boolean;
683 externalLiveBindings: boolean;
684 file: string | undefined;
685 footer: () => string | Promise<string>;
686 format: InternalModuleFormat;
687 freeze: boolean;
688 globals: GlobalsOption;
689 hoistTransitiveImports: boolean;
690 indent: true | string;
691 inlineDynamicImports: boolean;
692 interop: GetInterop;
693 intro: () => string | Promise<string>;
694 manualChunks: ManualChunksOption;
695 minifyInternalExports: boolean;
696 name: string | undefined;
697 namespaceToStringTag: boolean;
698 noConflict: boolean;
699 outro: () => string | Promise<string>;
700 paths: OptionsPaths;
701 plugins: OutputPlugin[];
702 preferConst: boolean;
703 preserveModules: boolean;
704 preserveModulesRoot: string | undefined;
705 sanitizeFileName: (fileName: string) => string;
706 sourcemap: boolean | 'inline' | 'hidden';
707 sourcemapExcludeSources: boolean;
708 sourcemapFile: string | undefined;
709 sourcemapPathTransform: SourcemapPathTransformOption | undefined;
710 strict: boolean;
711 systemNullSetters: boolean;
712 validate: boolean;
713}
714
715export type WarningHandlerWithDefault = (
716 warning: RollupWarning,
717 defaultHandler: WarningHandler
718) => void;
719export type WarningHandler = (warning: RollupWarning) => void;
720
721export interface SerializedTimings {
722 [label: string]: [number, number, number];
723}
724
725export interface PreRenderedAsset {
726 name: string | undefined;
727 source: string | Uint8Array;
728 type: 'asset';
729}
730
731export interface OutputAsset extends PreRenderedAsset {
732 fileName: string;
733 /** @deprecated Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead */
734 isAsset: true;
735}
736
737export interface RenderedModule {
738 code: string | null;
739 originalLength: number;
740 removedExports: string[];
741 renderedExports: string[];
742 renderedLength: number;
743}
744
745export interface PreRenderedChunk {
746 exports: string[];
747 facadeModuleId: string | null;
748 isDynamicEntry: boolean;
749 isEntry: boolean;
750 isImplicitEntry: boolean;
751 modules: {
752 [id: string]: RenderedModule;
753 };
754 name: string;
755 type: 'chunk';
756}
757
758export interface RenderedChunk extends PreRenderedChunk {
759 code?: string;
760 dynamicImports: string[];
761 fileName: string;
762 implicitlyLoadedBefore: string[];
763 importedBindings: {
764 [imported: string]: string[];
765 };
766 imports: string[];
767 map?: SourceMap;
768 referencedFiles: string[];
769}
770
771export interface OutputChunk extends RenderedChunk {
772 code: string;
773}
774
775export interface SerializablePluginCache {
776 [key: string]: [number, any];
777}
778
779export interface RollupCache {
780 modules: ModuleJSON[];
781 plugins?: Record<string, SerializablePluginCache>;
782}
783
784export interface RollupOutput {
785 output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
786}
787
788export interface RollupBuild {
789 cache: RollupCache | undefined;
790 close: () => Promise<void>;
791 closed: boolean;
792 generate: (outputOptions: OutputOptions) => Promise<RollupOutput>;
793 getTimings?: () => SerializedTimings;
794 watchFiles: string[];
795 write: (options: OutputOptions) => Promise<RollupOutput>;
796}
797
798export interface RollupOptions extends InputOptions {
799 // This is included for compatibility with config files but ignored by rollup.rollup
800 output?: OutputOptions | OutputOptions[];
801}
802
803export interface MergedRollupOptions extends InputOptions {
804 output: OutputOptions[];
805}
806
807export function rollup(options: RollupOptions): Promise<RollupBuild>;
808
809export interface ChokidarOptions {
810 alwaysStat?: boolean;
811 atomic?: boolean | number;
812 awaitWriteFinish?:
813 | {
814 pollInterval?: number;
815 stabilityThreshold?: number;
816 }
817 | boolean;
818 binaryInterval?: number;
819 cwd?: string;
820 depth?: number;
821 disableGlobbing?: boolean;
822 followSymlinks?: boolean;
823 ignoreInitial?: boolean;
824 ignorePermissionErrors?: boolean;
825 ignored?: any;
826 interval?: number;
827 persistent?: boolean;
828 useFsEvents?: boolean;
829 usePolling?: boolean;
830}
831
832export interface WatcherOptions {
833 buildDelay?: number;
834 chokidar?: ChokidarOptions;
835 clearScreen?: boolean;
836 exclude?: string | RegExp | (string | RegExp)[];
837 include?: string | RegExp | (string | RegExp)[];
838 skipWrite?: boolean;
839}
840
841export interface RollupWatchOptions extends InputOptions {
842 output?: OutputOptions | OutputOptions[];
843 watch?: WatcherOptions | false;
844}
845
846interface TypedEventEmitter<T extends { [event: string]: (...args: any) => any }> {
847 addListener<K extends keyof T>(event: K, listener: T[K]): this;
848 emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
849 eventNames(): Array<keyof T>;
850 getMaxListeners(): number;
851 listenerCount(type: keyof T): number;
852 listeners<K extends keyof T>(event: K): Array<T[K]>;
853 off<K extends keyof T>(event: K, listener: T[K]): this;
854 on<K extends keyof T>(event: K, listener: T[K]): this;
855 once<K extends keyof T>(event: K, listener: T[K]): this;
856 prependListener<K extends keyof T>(event: K, listener: T[K]): this;
857 prependOnceListener<K extends keyof T>(event: K, listener: T[K]): this;
858 rawListeners<K extends keyof T>(event: K): Array<T[K]>;
859 removeAllListeners<K extends keyof T>(event?: K): this;
860 removeListener<K extends keyof T>(event: K, listener: T[K]): this;
861 setMaxListeners(n: number): this;
862}
863
864export type RollupWatcherEvent =
865 | { code: 'START' }
866 | { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
867 | {
868 code: 'BUNDLE_END';
869 duration: number;
870 input?: InputOption;
871 output: readonly string[];
872 result: RollupBuild;
873 }
874 | { code: 'END' }
875 | { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
876
877export interface RollupWatcher
878 extends TypedEventEmitter<{
879 change: (id: string, change: { event: ChangeEvent }) => void;
880 close: () => void;
881 event: (event: RollupWatcherEvent) => void;
882 restart: () => void;
883 }> {
884 close(): void;
885}
886
887export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher;
888
889interface AcornNode {
890 end: number;
891 start: number;
892 type: string;
893}
894
895export function defineConfig(options: RollupOptions): RollupOptions;
896export function defineConfig(options: RollupOptions[]): RollupOptions[];