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