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