rollup 2.77.3 → 2.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rollup.d.ts CHANGED
@@ -244,7 +244,7 @@ export type ResolveIdHook = (
244
244
  source: string,
245
245
  importer: string | undefined,
246
246
  options: { custom?: CustomPluginOptions; isEntry: boolean }
247
- ) => Promise<ResolveIdResult> | ResolveIdResult;
247
+ ) => ResolveIdResult;
248
248
 
249
249
  export type ShouldTransformCachedModuleHook = (
250
250
  this: PluginContext,
@@ -257,7 +257,7 @@ export type ShouldTransformCachedModuleHook = (
257
257
  resolvedSources: ResolvedIdMap;
258
258
  syntheticNamedExports: boolean | string;
259
259
  }
260
- ) => Promise<boolean> | boolean;
260
+ ) => boolean;
261
261
 
262
262
  export type IsExternal = (
263
263
  source: string,
@@ -269,9 +269,9 @@ export type IsPureModule = (id: string) => boolean | null | void;
269
269
 
270
270
  export type HasModuleSideEffects = (id: string, external: boolean) => boolean;
271
271
 
272
- type LoadResult = SourceDescription | string | null | void;
272
+ export type LoadResult = SourceDescription | string | null | void;
273
273
 
274
- export type LoadHook = (this: PluginContext, id: string) => Promise<LoadResult> | LoadResult;
274
+ export type LoadHook = (this: PluginContext, id: string) => LoadResult;
275
275
 
276
276
  export interface TransformPluginContext extends PluginContext {
277
277
  getCombinedSourcemap: () => SourceMap;
@@ -283,27 +283,22 @@ export type TransformHook = (
283
283
  this: TransformPluginContext,
284
284
  code: string,
285
285
  id: string
286
- ) => Promise<TransformResult> | TransformResult;
286
+ ) => TransformResult;
287
287
 
288
- export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => Promise<void> | void;
288
+ export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void;
289
289
 
290
290
  export type RenderChunkHook = (
291
291
  this: PluginContext,
292
292
  code: string,
293
293
  chunk: RenderedChunk,
294
294
  options: NormalizedOutputOptions
295
- ) =>
296
- | Promise<{ code: string; map?: SourceMapInput } | null>
297
- | { code: string; map?: SourceMapInput }
298
- | string
299
- | null
300
- | undefined;
295
+ ) => { code: string; map?: SourceMapInput } | string | null | undefined;
301
296
 
302
297
  export type ResolveDynamicImportHook = (
303
298
  this: PluginContext,
304
299
  specifier: string | AcornNode,
305
300
  importer: string
306
- ) => Promise<ResolveIdResult> | ResolveIdResult;
301
+ ) => ResolveIdResult;
307
302
 
308
303
  export type ResolveImportMetaHook = (
309
304
  this: PluginContext,
@@ -344,7 +339,7 @@ export type WatchChangeHook = (
344
339
  this: PluginContext,
345
340
  id: string,
346
341
  change: { event: ChangeEvent }
347
- ) => Promise<void> | void;
342
+ ) => void;
348
343
 
349
344
  /**
350
345
  * use this type for plugin annotation
@@ -371,32 +366,21 @@ export interface OutputBundleWithPlaceholders {
371
366
  [fileName: string]: OutputAsset | OutputChunk | FilePlaceholder;
372
367
  }
373
368
 
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) => Promise<void> | void;
379
- load: LoadHook;
380
- moduleParsed: ModuleParsedHook;
381
- options: (
382
- this: MinimalPluginContext,
383
- options: InputOptions
384
- ) => Promise<InputOptions | null | void> | InputOptions | null | void;
385
- resolveDynamicImport: ResolveDynamicImportHook;
386
- resolveId: ResolveIdHook;
387
- shouldTransformCachedModule: ShouldTransformCachedModuleHook;
388
- transform: TransformHook;
389
- watchChange: WatchChangeHook;
390
- }
391
-
392
- interface OutputPluginHooks {
369
+ export interface FunctionPluginHooks {
393
370
  augmentChunkHash: (this: PluginContext, chunk: PreRenderedChunk) => string | void;
371
+ buildEnd: (this: PluginContext, err?: Error) => void;
372
+ buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
373
+ closeBundle: (this: PluginContext) => void;
374
+ closeWatcher: (this: PluginContext) => void;
394
375
  generateBundle: (
395
376
  this: PluginContext,
396
377
  options: NormalizedOutputOptions,
397
378
  bundle: OutputBundle,
398
379
  isWrite: boolean
399
- ) => void | Promise<void>;
380
+ ) => void;
381
+ load: LoadHook;
382
+ moduleParsed: ModuleParsedHook;
383
+ options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | null | void;
400
384
  outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | null | void;
401
385
  renderChunk: RenderChunkHook;
402
386
  renderDynamicImport: (
@@ -408,45 +392,52 @@ interface OutputPluginHooks {
408
392
  targetModuleId: string | null;
409
393
  }
410
394
  ) => { left: string; right: string } | null | void;
411
- renderError: (this: PluginContext, err?: Error) => Promise<void> | void;
395
+ renderError: (this: PluginContext, err?: Error) => void;
412
396
  renderStart: (
413
397
  this: PluginContext,
414
398
  outputOptions: NormalizedOutputOptions,
415
399
  inputOptions: NormalizedInputOptions
416
- ) => Promise<void> | void;
400
+ ) => void;
417
401
  /** @deprecated Use `resolveFileUrl` instead */
418
402
  resolveAssetUrl: ResolveAssetUrlHook;
403
+ resolveDynamicImport: ResolveDynamicImportHook;
419
404
  resolveFileUrl: ResolveFileUrlHook;
405
+ resolveId: ResolveIdHook;
420
406
  resolveImportMeta: ResolveImportMetaHook;
407
+ shouldTransformCachedModule: ShouldTransformCachedModuleHook;
408
+ transform: TransformHook;
409
+ watchChange: WatchChangeHook;
421
410
  writeBundle: (
422
411
  this: PluginContext,
423
412
  options: NormalizedOutputOptions,
424
413
  bundle: OutputBundle
425
- ) => void | Promise<void>;
414
+ ) => void;
426
415
  }
427
416
 
428
- export type AsyncPluginHooks =
429
- | 'options'
430
- | 'buildEnd'
431
- | 'buildStart'
417
+ export type OutputPluginHooks =
418
+ | 'augmentChunkHash'
432
419
  | 'generateBundle'
433
- | 'load'
434
- | 'moduleParsed'
420
+ | 'outputOptions'
435
421
  | 'renderChunk'
422
+ | 'renderDynamicImport'
436
423
  | 'renderError'
437
424
  | 'renderStart'
438
- | 'resolveDynamicImport'
439
- | 'resolveId'
440
- | 'shouldTransformCachedModule'
441
- | 'transform'
442
- | 'writeBundle'
443
- | 'closeBundle'
444
- | 'closeWatcher'
445
- | 'watchChange';
425
+ | 'resolveAssetUrl'
426
+ | 'resolveFileUrl'
427
+ | 'resolveImportMeta'
428
+ | 'writeBundle';
429
+
430
+ export type InputPluginHooks = Exclude<keyof FunctionPluginHooks, OutputPluginHooks>;
446
431
 
447
- export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro';
432
+ export type SyncPluginHooks =
433
+ | 'augmentChunkHash'
434
+ | 'outputOptions'
435
+ | 'renderDynamicImport'
436
+ | 'resolveAssetUrl'
437
+ | 'resolveFileUrl'
438
+ | 'resolveImportMeta';
448
439
 
449
- export type SyncPluginHooks = Exclude<keyof PluginHooks, AsyncPluginHooks>;
440
+ export type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
450
441
 
451
442
  export type FirstPluginHooks =
452
443
  | 'load'
@@ -466,37 +457,38 @@ export type SequentialPluginHooks =
466
457
  | 'renderChunk'
467
458
  | 'transform';
468
459
 
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
- | 'closeWatcher'
482
- | 'watchChange';
460
+ export type ParallelPluginHooks = Exclude<
461
+ keyof FunctionPluginHooks | AddonHooks,
462
+ FirstPluginHooks | SequentialPluginHooks
463
+ >;
483
464
 
484
- interface OutputPluginValueHooks {
485
- banner: AddonHook;
486
- cacheKey: string;
487
- footer: AddonHook;
488
- intro: AddonHook;
489
- outro: AddonHook;
490
- }
465
+ export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
491
466
 
492
- export interface Plugin extends Partial<PluginHooks>, Partial<OutputPluginValueHooks> {
493
- // for inter-plugin communication
494
- api?: any;
467
+ type MakeAsync<Fn> = Fn extends (this: infer This, ...args: infer Args) => infer Return
468
+ ? (this: This, ...args: Args) => Return | Promise<Return>
469
+ : never;
470
+
471
+ // eslint-disable-next-line @typescript-eslint/ban-types
472
+ type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
473
+
474
+ export type PluginHooks = {
475
+ [K in keyof FunctionPluginHooks]: ObjectHook<
476
+ K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
477
+ // eslint-disable-next-line @typescript-eslint/ban-types
478
+ K extends ParallelPluginHooks ? { sequential?: boolean } : {}
479
+ >;
480
+ };
481
+
482
+ export interface OutputPlugin
483
+ extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>,
484
+ Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
485
+ cacheKey?: string;
495
486
  name: string;
496
487
  }
497
488
 
498
- export interface OutputPlugin extends Partial<OutputPluginHooks>, Partial<OutputPluginValueHooks> {
499
- name: string;
489
+ export interface Plugin extends OutputPlugin, Partial<PluginHooks> {
490
+ // for inter-plugin communication
491
+ api?: any;
500
492
  }
501
493
 
502
494
  type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
@@ -639,6 +631,7 @@ export type AmdOptions = (
639
631
  }
640
632
  ) & {
641
633
  define?: string;
634
+ forceJsExtensionForImports?: boolean;
642
635
  };
643
636
 
644
637
  export type NormalizedAmdOptions = (
@@ -652,6 +645,7 @@ export type NormalizedAmdOptions = (
652
645
  }
653
646
  ) & {
654
647
  define: string;
648
+ forceJsExtensionForImports: boolean;
655
649
  };
656
650
 
657
651
  export interface OutputOptions {
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.77.3
4
- Thu, 11 Aug 2022 05:48:58 GMT - commit 1165d46685ef3c70617b2f150ab245ff5de5e783
3
+ Rollup.js v2.79.0
4
+ Wed, 31 Aug 2022 04:52:13 GMT - commit 8477f8ff1fe80086556021542b22942ad27a0a69
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.77.3
4
- Thu, 11 Aug 2022 05:48:58 GMT - commit 1165d46685ef3c70617b2f150ab245ff5de5e783
3
+ Rollup.js v2.79.0
4
+ Wed, 31 Aug 2022 04:52:13 GMT - commit 8477f8ff1fe80086556021542b22942ad27a0a69
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.77.3
4
- Thu, 11 Aug 2022 05:48:58 GMT - commit 1165d46685ef3c70617b2f150ab245ff5de5e783
3
+ Rollup.js v2.79.0
4
+ Wed, 31 Aug 2022 04:52:13 GMT - commit 8477f8ff1fe80086556021542b22942ad27a0a69
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.77.3
4
- Thu, 11 Aug 2022 05:48:58 GMT - commit 1165d46685ef3c70617b2f150ab245ff5de5e783
3
+ Rollup.js v2.79.0
4
+ Wed, 31 Aug 2022 04:52:13 GMT - commit 8477f8ff1fe80086556021542b22942ad27a0a69
5
5
 
6
6
  https://github.com/rollup/rollup
7
7