rolldown 0.10.0 → 0.10.1

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const rolldown = require('./shared/rolldown.63afb352.cjs');
3
+ const rolldown = require('./shared/rolldown.ee864e8d.cjs');
4
4
  require('fs');
5
5
  require('node:path');
6
6
 
package/dist/index.d.cts CHANGED
@@ -37,8 +37,8 @@ interface RolldownOutput {
37
37
  }
38
38
 
39
39
  // utils
40
- type NullValue = null | undefined | void
41
- type MaybePromise<T> = T | Promise<T>
40
+ type NullValue$1 = null | undefined | void
41
+ type MaybePromise$1<T> = T | Promise<T>
42
42
 
43
43
  type PartialNull<T> = {
44
44
  [P in keyof T]: T[P] | null
@@ -244,7 +244,7 @@ type LoggingFunctionWithPosition = (
244
244
  pos?: number | { column: number; line: number },
245
245
  ) => void
246
246
 
247
- interface PluginContext extends MinimalPluginContext {
247
+ interface PluginContext$1 extends MinimalPluginContext {
248
248
  addWatchFile: (id: string) => void
249
249
  cache: PluginCache
250
250
  debug: LoggingFunction
@@ -301,10 +301,10 @@ interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
301
301
  resolvedBy?: string
302
302
  }
303
303
 
304
- type ResolveIdResult = string | NullValue | false | PartialResolvedId
304
+ type ResolveIdResult = string | NullValue$1 | false | PartialResolvedId
305
305
 
306
306
  type ResolveIdHook = (
307
- this: PluginContext,
307
+ this: PluginContext$1,
308
308
  source: string,
309
309
  importer: string | undefined,
310
310
  options: {
@@ -315,7 +315,7 @@ type ResolveIdHook = (
315
315
  ) => ResolveIdResult
316
316
 
317
317
  type ShouldTransformCachedModuleHook = (
318
- this: PluginContext,
318
+ this: PluginContext$1,
319
319
  options: {
320
320
  ast: AcornNode
321
321
  code: string
@@ -325,7 +325,7 @@ type ShouldTransformCachedModuleHook = (
325
325
  resolvedSources: ResolvedIdMap
326
326
  syntheticNamedExports: boolean | string
327
327
  },
328
- ) => boolean | NullValue
328
+ ) => boolean | NullValue$1
329
329
 
330
330
  type IsExternal = (
331
331
  source: string,
@@ -335,11 +335,11 @@ type IsExternal = (
335
335
 
336
336
  type HasModuleSideEffects = (id: string, external: boolean) => boolean
337
337
 
338
- type LoadResult = SourceDescription | string | NullValue
338
+ type LoadResult = SourceDescription | string | NullValue$1
339
339
 
340
- type LoadHook = (this: PluginContext, id: string) => LoadResult
340
+ type LoadHook = (this: PluginContext$1, id: string) => LoadResult
341
341
 
342
- interface TransformPluginContext extends PluginContext {
342
+ interface TransformPluginContext extends PluginContext$1 {
343
343
  debug: LoggingFunctionWithPosition
344
344
  error: (
345
345
  error: RollupError | string,
@@ -350,7 +350,7 @@ interface TransformPluginContext extends PluginContext {
350
350
  warn: LoggingFunctionWithPosition
351
351
  }
352
352
 
353
- type TransformResult = string | NullValue | Partial<SourceDescription>
353
+ type TransformResult = string | NullValue$1 | Partial<SourceDescription>
354
354
 
355
355
  type TransformHook = (
356
356
  this: TransformPluginContext,
@@ -358,31 +358,31 @@ type TransformHook = (
358
358
  id: string,
359
359
  ) => TransformResult
360
360
 
361
- type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void
361
+ type ModuleParsedHook = (this: PluginContext$1, info: ModuleInfo) => void
362
362
 
363
363
  type RenderChunkHook = (
364
- this: PluginContext,
364
+ this: PluginContext$1,
365
365
  code: string,
366
- chunk: RenderedChunk,
366
+ chunk: RenderedChunk$1,
367
367
  options: NormalizedOutputOptions,
368
- meta: { chunks: Record<string, RenderedChunk> },
369
- ) => { code: string; map?: SourceMapInput } | string | NullValue
368
+ meta: { chunks: Record<string, RenderedChunk$1> },
369
+ ) => { code: string; map?: SourceMapInput } | string | NullValue$1
370
370
 
371
371
  type ResolveDynamicImportHook = (
372
- this: PluginContext,
372
+ this: PluginContext$1,
373
373
  specifier: string | AcornNode,
374
374
  importer: string,
375
375
  options: { assertions: Record<string, string> },
376
376
  ) => ResolveIdResult
377
377
 
378
378
  type ResolveImportMetaHook = (
379
- this: PluginContext,
379
+ this: PluginContext$1,
380
380
  property: string | null,
381
381
  options: { chunkId: string; format: InternalModuleFormat; moduleId: string },
382
- ) => string | NullValue
382
+ ) => string | NullValue$1
383
383
 
384
384
  type ResolveFileUrlHook = (
385
- this: PluginContext,
385
+ this: PluginContext$1,
386
386
  options: {
387
387
  chunkId: string
388
388
  fileName: string
@@ -391,17 +391,17 @@ type ResolveFileUrlHook = (
391
391
  referenceId: string
392
392
  relativePath: string
393
393
  },
394
- ) => string | NullValue
394
+ ) => string | NullValue$1
395
395
 
396
396
  type AddonHookFunction = (
397
- this: PluginContext,
398
- chunk: RenderedChunk,
397
+ this: PluginContext$1,
398
+ chunk: RenderedChunk$1,
399
399
  ) => string | Promise<string>
400
400
  type AddonHook = string | AddonHookFunction
401
401
 
402
402
  type ChangeEvent = 'create' | 'update' | 'delete'
403
403
  type WatchChangeHook = (
404
- this: PluginContext,
404
+ this: PluginContext$1,
405
405
  id: string,
406
406
  change: { event: ChangeEvent },
407
407
  ) => void
@@ -411,13 +411,13 @@ interface OutputBundle {
411
411
  }
412
412
 
413
413
  interface FunctionPluginHooks {
414
- augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void
415
- buildEnd: (this: PluginContext, error?: Error) => void
416
- buildStart: (this: PluginContext, options: NormalizedInputOptions) => void
417
- closeBundle: (this: PluginContext) => void
418
- closeWatcher: (this: PluginContext) => void
414
+ augmentChunkHash: (this: PluginContext$1, chunk: RenderedChunk$1) => string | void
415
+ buildEnd: (this: PluginContext$1, error?: Error) => void
416
+ buildStart: (this: PluginContext$1, options: NormalizedInputOptions) => void
417
+ closeBundle: (this: PluginContext$1) => void
418
+ closeWatcher: (this: PluginContext$1) => void
419
419
  generateBundle: (
420
- this: PluginContext,
420
+ this: PluginContext$1,
421
421
  options: NormalizedOutputOptions,
422
422
  bundle: OutputBundle,
423
423
  isWrite: boolean,
@@ -428,28 +428,28 @@ interface FunctionPluginHooks {
428
428
  this: MinimalPluginContext,
429
429
  level: LogLevel,
430
430
  log: RollupLog,
431
- ) => boolean | NullValue
431
+ ) => boolean | NullValue$1
432
432
  options: (
433
433
  this: MinimalPluginContext,
434
434
  options: InputOptions$1,
435
- ) => InputOptions$1 | NullValue
435
+ ) => InputOptions$1 | NullValue$1
436
436
  outputOptions: (
437
- this: PluginContext,
437
+ this: PluginContext$1,
438
438
  options: OutputOptions$1,
439
- ) => OutputOptions$1 | NullValue
439
+ ) => OutputOptions$1 | NullValue$1
440
440
  renderChunk: RenderChunkHook
441
441
  renderDynamicImport: (
442
- this: PluginContext,
442
+ this: PluginContext$1,
443
443
  options: {
444
444
  customResolution: string | null
445
445
  format: InternalModuleFormat
446
446
  moduleId: string
447
447
  targetModuleId: string | null
448
448
  },
449
- ) => { left: string; right: string } | NullValue
450
- renderError: (this: PluginContext, error?: Error) => void
449
+ ) => { left: string; right: string } | NullValue$1
450
+ renderError: (this: PluginContext$1, error?: Error) => void
451
451
  renderStart: (
452
- this: PluginContext,
452
+ this: PluginContext$1,
453
453
  outputOptions: NormalizedOutputOptions,
454
454
  inputOptions: NormalizedInputOptions,
455
455
  ) => void
@@ -461,7 +461,7 @@ interface FunctionPluginHooks {
461
461
  transform: TransformHook
462
462
  watchChange: WatchChangeHook
463
463
  writeBundle: (
464
- this: PluginContext,
464
+ this: PluginContext$1,
465
465
  options: NormalizedOutputOptions,
466
466
  bundle: OutputBundle,
467
467
  ) => void
@@ -547,7 +547,7 @@ interface OutputPlugin
547
547
  version?: string
548
548
  }
549
549
 
550
- interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
550
+ interface Plugin$1<A = any> extends OutputPlugin, Partial<PluginHooks> {
551
551
  // for inter-plugin communication
552
552
  api?: A
553
553
  }
@@ -577,7 +577,7 @@ interface ManualChunkMeta {
577
577
  type GetManualChunk = (
578
578
  id: string,
579
579
  meta: ManualChunkMeta,
580
- ) => string | NullValue
580
+ ) => string | NullValue$1
581
581
 
582
582
  type ExternalOption =
583
583
  | (string | RegExp)[]
@@ -587,7 +587,7 @@ type ExternalOption =
587
587
  source: string,
588
588
  importer: string | undefined,
589
589
  isResolved: boolean,
590
- ) => boolean | NullValue)
590
+ ) => boolean | NullValue$1)
591
591
 
592
592
  type GlobalsOption =
593
593
  | { [name: string]: string }
@@ -634,8 +634,8 @@ type SourcemapIgnoreListOption = (
634
634
  sourcemapPath: string,
635
635
  ) => boolean
636
636
 
637
- type InputPluginOption = MaybePromise<
638
- Plugin | NullValue | false | InputPluginOption[]
637
+ type InputPluginOption = MaybePromise$1<
638
+ Plugin$1 | NullValue$1 | false | InputPluginOption[]
639
639
  >
640
640
 
641
641
  interface InputOptions$1 {
@@ -659,7 +659,7 @@ interface InputOptions$1 {
659
659
  /** @deprecated Use the "maxParallelFileOps" option instead. */
660
660
  maxParallelFileReads?: number
661
661
  moduleContext?:
662
- | ((id: string) => string | NullValue)
662
+ | ((id: string) => string | NullValue$1)
663
663
  | { [id: string]: string }
664
664
  onLog?: LogHandlerWithDefault
665
665
  onwarn?: WarningHandlerWithDefault
@@ -697,7 +697,7 @@ interface NormalizedInputOptions {
697
697
  onLog: LogHandler
698
698
  onwarn: (warning: RollupLog) => void
699
699
  perf: boolean
700
- plugins: Plugin[]
700
+ plugins: Plugin$1[]
701
701
  preserveEntrySignatures: PreserveEntrySignaturesOption
702
702
  /** @deprecated Use the "preserveModules" output option instead. */
703
703
  preserveModules: boolean | undefined
@@ -780,10 +780,10 @@ type NormalizedAmdOptions = (
780
780
  forceJsExtensionForImports: boolean
781
781
  }
782
782
 
783
- type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>
783
+ type AddonFunction = (chunk: RenderedChunk$1) => string | Promise<string>
784
784
 
785
- type OutputPluginOption = MaybePromise<
786
- OutputPlugin | NullValue | false | OutputPluginOption[]
785
+ type OutputPluginOption = MaybePromise$1<
786
+ OutputPlugin | NullValue$1 | false | OutputPluginOption[]
787
787
  >
788
788
 
789
789
  interface OutputOptions$1 {
@@ -938,7 +938,7 @@ interface PreRenderedChunk {
938
938
  type: 'chunk'
939
939
  }
940
940
 
941
- interface RenderedChunk extends PreRenderedChunk {
941
+ interface RenderedChunk$1 extends PreRenderedChunk {
942
942
  dynamicImports: string[]
943
943
  fileName: string
944
944
  implicitlyLoadedBefore: string[]
@@ -952,7 +952,7 @@ interface RenderedChunk extends PreRenderedChunk {
952
952
  referencedFiles: string[]
953
953
  }
954
954
 
955
- interface OutputChunk extends RenderedChunk {
955
+ interface OutputChunk extends RenderedChunk$1 {
956
956
  code: string
957
957
  map: SourceMap | null
958
958
  sourcemapFileName: string | null
@@ -1006,6 +1006,50 @@ interface AcornNode {
1006
1006
  type: string
1007
1007
  }
1008
1008
 
1009
+ declare class BindingOutputAsset {
1010
+ get fileName(): string
1011
+ get source(): string
1012
+ }
1013
+
1014
+ declare class BindingOutputChunk {
1015
+ get isEntry(): boolean
1016
+ get isDynamicEntry(): boolean
1017
+ get facadeModuleId(): string | null
1018
+ get moduleIds(): Array<string>
1019
+ get exports(): Array<string>
1020
+ get fileName(): string
1021
+ get modules(): Record<string, BindingRenderedModule>
1022
+ get code(): string
1023
+ get map(): string | null
1024
+ get sourcemapFileName(): string | null
1025
+ }
1026
+
1027
+ declare class BindingOutputs {
1028
+ get chunks(): Array<BindingOutputChunk>
1029
+ get assets(): Array<BindingOutputAsset>
1030
+ }
1031
+
1032
+ declare class BindingPluginContext {
1033
+ resolve(
1034
+ specifier: string,
1035
+ importer: string | undefined | null,
1036
+ extraOptions: BindingPluginContextResolveOptions,
1037
+ ): void
1038
+ }
1039
+
1040
+ interface BindingHookResolveIdExtraOptions {
1041
+ isEntry: boolean
1042
+ kind: string
1043
+ }
1044
+
1045
+ interface BindingPluginContextResolveOptions {
1046
+ importKind: string
1047
+ }
1048
+
1049
+ interface BindingRenderedModule {
1050
+ code?: string
1051
+ }
1052
+
1009
1053
  interface BindingResolveOptions {
1010
1054
  alias?: Record<string, Array<string>>
1011
1055
  aliasFields?: Array<Array<string>>
@@ -1018,22 +1062,71 @@ interface BindingResolveOptions {
1018
1062
  symlinks?: boolean
1019
1063
  }
1020
1064
 
1021
- type RolldownPlugin = Plugin;
1065
+ interface RenderedChunk {
1066
+ isEntry: boolean
1067
+ isDynamicEntry: boolean
1068
+ facadeModuleId?: string
1069
+ moduleIds: Array<string>
1070
+ exports: Array<string>
1071
+ fileName: string
1072
+ modules: Record<string, BindingRenderedModule>
1073
+ }
1074
+
1075
+ interface AnyFn {
1076
+ (...args: any[]): any;
1077
+ }
1078
+ interface AnyObj {
1079
+ }
1080
+ type NullValue<T = void> = T | undefined | null | void;
1081
+
1082
+ type MaybePromise<T> = T | Promise<T>;
1083
+ type PluginContext = BindingPluginContext;
1084
+ type FormalHook<Handler extends AnyFn, HookOptions extends AnyObj = AnyObj> = {
1085
+ handler: Handler;
1086
+ } & HookOptions;
1087
+ type Hook<Handler extends AnyFn, HookOptions extends AnyObj = AnyObj> = FormalHook<Handler, HookOptions> | Handler;
1088
+ interface Plugin {
1089
+ name?: string;
1090
+ buildStart?: Hook<(this: PluginContext, options: RolldownNormalizedInputOptions) => MaybePromise<NullValue>>;
1091
+ resolveId?: Hook<(this: null, source: string, importer: string | undefined, extraOptions: BindingHookResolveIdExtraOptions) => MaybePromise<string | NullValue | false | {
1092
+ id: string;
1093
+ external?: boolean;
1094
+ }>>;
1095
+ load?: Hook<(this: null, id: string) => MaybePromise<NullValue | string | {
1096
+ code: string;
1097
+ map?: string | null;
1098
+ }>>;
1099
+ transform?: Hook<(this: null, code: string, id: string) => MaybePromise<NullValue | string | {
1100
+ code: string;
1101
+ map?: string | null;
1102
+ }>>;
1103
+ renderChunk?: Hook<(this: null, code: string, chunk: RenderedChunk) => MaybePromise<NullValue | string>>;
1104
+ buildEnd?: Hook<(this: null, err?: string) => MaybePromise<NullValue>>;
1105
+ generateBundle?: Hook<(bundle: BindingOutputs, isWrite: boolean) => MaybePromise<NullValue>>;
1106
+ writeBundle?: Hook<(bundle: BindingOutputs) => MaybePromise<NullValue>>;
1107
+ }
1108
+
1022
1109
  interface InputOptions {
1023
1110
  input?: InputOptions$1['input'];
1024
- plugins?: RolldownPlugin[];
1111
+ plugins?: Plugin[];
1025
1112
  external?: InputOptions$1['external'];
1026
1113
  resolve?: RolldownResolveOptions;
1114
+ cwd?: string;
1027
1115
  }
1028
1116
  type RolldownResolveOptions = Omit<BindingResolveOptions, 'alias'> & {
1029
1117
  alias?: Record<string, string>;
1030
1118
  };
1119
+ type RolldownNormalizedInputOptions = NormalizedInputOptions & {
1120
+ resolve?: BindingResolveOptions;
1121
+ };
1031
1122
 
1032
1123
  interface OutputOptions {
1033
1124
  dir?: OutputOptions$1['dir'];
1034
1125
  format?: 'es';
1035
1126
  exports?: OutputOptions$1['exports'];
1036
1127
  sourcemap?: OutputOptions$1['sourcemap'];
1128
+ banner?: OutputOptions$1['banner'];
1129
+ footer?: OutputOptions$1['footer'];
1037
1130
  }
1038
1131
 
1039
1132
  interface RolldownOptions extends InputOptions {
@@ -1059,4 +1152,4 @@ declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
1059
1152
  */
1060
1153
  declare const experimental_scan: (input: InputOptions) => Promise<void>;
1061
1154
 
1062
- export { type InputOptions, type OutputOptions, type RolldownPlugin as Plugin, type RolldownOptions, type RolldownOutput, type RolldownOptions as RollupOptions, type RolldownOutput as RollupOutput, defineConfig, experimental_scan, rolldown };
1155
+ export { type InputOptions, type OutputOptions, type Plugin, type RolldownOptions, type RolldownOutput, type RolldownOutputChunk, type RolldownOptions as RollupOptions, type RolldownOutput as RollupOutput, defineConfig, experimental_scan, rolldown };