rollup.d.ts 23 KB

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