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