UNPKG

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