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