@rollup/browser 3.24.1 → 3.25.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.
@@ -32,6 +32,7 @@ export interface RollupLog {
32
32
  line: number;
33
33
  };
34
34
  message: string;
35
+ meta?: any;
35
36
  names?: string[];
36
37
  plugin?: string;
37
38
  pluginCode?: string;
@@ -41,6 +42,9 @@ export interface RollupLog {
41
42
  url?: string;
42
43
  }
43
44
 
45
+ export type LogLevel = 'warn' | 'info' | 'debug';
46
+ export type LogLevelOption = LogLevel | 'silent';
47
+
44
48
  export type SourceMapSegment =
45
49
  | [number]
46
50
  | [number, number, number, number]
@@ -128,8 +132,14 @@ export interface PluginCache {
128
132
  set<T = any>(id: string, value: T): void;
129
133
  }
130
134
 
135
+ export type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
136
+
131
137
  export interface MinimalPluginContext {
138
+ debug: LoggingFunction;
139
+ error: (error: RollupError | string) => never;
140
+ info: LoggingFunction;
132
141
  meta: PluginContextMeta;
142
+ warn: LoggingFunction;
133
143
  }
134
144
 
135
145
  export interface EmittedAsset {
@@ -190,15 +200,22 @@ export interface CustomPluginOptions {
190
200
  [plugin: string]: any;
191
201
  }
192
202
 
203
+ type LoggingFunctionWithPosition = (
204
+ log: RollupLog | string | (() => RollupLog | string),
205
+ pos?: number | { column: number; line: number }
206
+ ) => void;
207
+
193
208
  export interface PluginContext extends MinimalPluginContext {
194
209
  addWatchFile: (id: string) => void;
195
210
  cache: PluginCache;
211
+ debug: LoggingFunction;
196
212
  emitFile: EmitFile;
197
- error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
213
+ error: (error: RollupError | string) => never;
198
214
  getFileName: (fileReferenceId: string) => string;
199
215
  getModuleIds: () => IterableIterator<string>;
200
216
  getModuleInfo: GetModuleInfo;
201
217
  getWatchFiles: () => string[];
218
+ info: LoggingFunction;
202
219
  load: (
203
220
  options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
204
221
  ) => Promise<ModuleInfo>;
@@ -216,7 +233,7 @@ export interface PluginContext extends MinimalPluginContext {
216
233
  }
217
234
  ) => Promise<ResolvedId | null>;
218
235
  setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
219
- warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
236
+ warn: LoggingFunction;
220
237
  }
221
238
 
222
239
  export interface PluginContextMeta {
@@ -279,7 +296,11 @@ export type LoadResult = SourceDescription | string | NullValue;
279
296
  export type LoadHook = (this: PluginContext, id: string) => LoadResult;
280
297
 
281
298
  export interface TransformPluginContext extends PluginContext {
299
+ debug: LoggingFunctionWithPosition;
300
+ error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
282
301
  getCombinedSourcemap: () => SourceMap;
302
+ info: LoggingFunctionWithPosition;
303
+ warn: LoggingFunctionWithPosition;
283
304
  }
284
305
 
285
306
  export type TransformResult = string | NullValue | Partial<SourceDescription>;
@@ -369,6 +390,7 @@ export interface FunctionPluginHooks {
369
390
  ) => void;
370
391
  load: LoadHook;
371
392
  moduleParsed: ModuleParsedHook;
393
+ onLog: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => boolean | NullValue;
372
394
  options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue;
373
395
  outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue;
374
396
  renderChunk: RenderChunkHook;
@@ -417,6 +439,7 @@ export type InputPluginHooks = Exclude<keyof FunctionPluginHooks, OutputPluginHo
417
439
 
418
440
  export type SyncPluginHooks =
419
441
  | 'augmentChunkHash'
442
+ | 'onLog'
420
443
  | 'outputOptions'
421
444
  | 'renderDynamicImport'
422
445
  | 'resolveFileUrl'
@@ -436,6 +459,7 @@ export type FirstPluginHooks =
436
459
  export type SequentialPluginHooks =
437
460
  | 'augmentChunkHash'
438
461
  | 'generateBundle'
462
+ | 'onLog'
439
463
  | 'options'
440
464
  | 'outputOptions'
441
465
  | 'renderChunk'
@@ -508,16 +532,32 @@ export type ExternalOption =
508
532
  | string
509
533
  | RegExp
510
534
  | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue);
511
- export type PureModulesOption = boolean | string[] | IsPureModule;
535
+
512
536
  export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
537
+
513
538
  export type InputOption = string | string[] | { [entryAlias: string]: string };
539
+
514
540
  export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
541
+
542
+ export type LogHandlerWithDefault = (
543
+ level: LogLevel,
544
+ log: RollupLog,
545
+ defaultHandler: LogOrStringHandler
546
+ ) => void;
547
+
548
+ export type LogOrStringHandler = (level: LogLevel | 'error', log: RollupLog | string) => void;
549
+
550
+ export type LogHandler = (level: LogLevel, log: RollupLog) => void;
551
+
515
552
  export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
553
+
516
554
  export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
555
+
517
556
  export type SourcemapPathTransformOption = (
518
557
  relativeSourcePath: string,
519
558
  sourcemapPath: string
520
559
  ) => string;
560
+
521
561
  export type SourcemapIgnoreListOption = (
522
562
  relativeSourcePath: string,
523
563
  sourcemapPath: string
@@ -536,6 +576,7 @@ export interface InputOptions {
536
576
  /** @deprecated Use the "inlineDynamicImports" output option instead. */
537
577
  inlineDynamicImports?: boolean;
538
578
  input?: InputOption;
579
+ logLevel?: LogLevelOption;
539
580
  makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
540
581
  /** @deprecated Use the "manualChunks" output option instead. */
541
582
  manualChunks?: ManualChunksOption;
@@ -543,6 +584,7 @@ export interface InputOptions {
543
584
  /** @deprecated Use the "maxParallelFileOps" option instead. */
544
585
  maxParallelFileReads?: number;
545
586
  moduleContext?: ((id: string) => string | NullValue) | { [id: string]: string };
587
+ onLog?: LogHandlerWithDefault;
546
588
  onwarn?: WarningHandlerWithDefault;
547
589
  perf?: boolean;
548
590
  plugins?: InputPluginOption;
@@ -571,6 +613,7 @@ export interface NormalizedInputOptions {
571
613
  /** @deprecated Use the "inlineDynamicImports" output option instead. */
572
614
  inlineDynamicImports: boolean | undefined;
573
615
  input: string[] | { [entryAlias: string]: string };
616
+ logLevel: LogLevelOption;
574
617
  makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
575
618
  /** @deprecated Use the "manualChunks" output option instead. */
576
619
  manualChunks: ManualChunksOption | undefined;
@@ -578,7 +621,8 @@ export interface NormalizedInputOptions {
578
621
  /** @deprecated Use the "maxParallelFileOps" option instead. */
579
622
  maxParallelFileReads: number;
580
623
  moduleContext: (id: string) => string;
581
- onwarn: WarningHandler;
624
+ onLog: LogHandler;
625
+ onwarn: (warning: RollupLog) => void;
582
626
  perf: boolean;
583
627
  plugins: Plugin[];
584
628
  preserveEntrySignatures: PreserveEntrySignaturesOption;
@@ -764,10 +808,9 @@ export interface NormalizedOutputOptions {
764
808
  }
765
809
 
766
810
  export type WarningHandlerWithDefault = (
767
- warning: RollupWarning,
768
- defaultHandler: WarningHandler
811
+ warning: RollupLog,
812
+ defaultHandler: LoggingFunction
769
813
  ) => void;
770
- export type WarningHandler = (warning: RollupWarning) => void;
771
814
 
772
815
  export interface SerializedTimings {
773
816
  [label: string]: [number, number, number];