rolldown 0.15.1-commit.4e41a08 → 0.15.1-commit.f85bcfa

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.
Files changed (34) hide show
  1. package/dist/cjs/cli.cjs +1 -1
  2. package/dist/cjs/experimental-index.cjs +1 -1
  3. package/dist/cjs/index.cjs +1 -1
  4. package/dist/cjs/parallel-plugin-worker.cjs +1 -1
  5. package/dist/esm/cli.mjs +1 -1
  6. package/dist/esm/experimental-index.mjs +1 -1
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/esm/parallel-plugin-worker.mjs +1 -1
  9. package/dist/shared/{src-Dw217EaC.cjs → src-DCe3tD4H.cjs} +12 -5
  10. package/dist/shared/{src-Do1JlyLc.mjs → src-DX2q-tRy.mjs} +12 -5
  11. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  12. package/dist/types/index.d.ts +3 -4
  13. package/dist/types/log/logHandler.d.ts +1 -1
  14. package/dist/types/log/logger.d.ts +1 -1
  15. package/dist/types/log/logs.d.ts +2 -1
  16. package/dist/types/options/normalized-input-options.d.ts +1 -1
  17. package/dist/types/options/normalized-output-options.d.ts +1 -1
  18. package/dist/types/options/output-options.d.ts +3 -3
  19. package/dist/types/plugin/bindingify-plugin.d.ts +1 -1
  20. package/dist/types/plugin/index.d.ts +6 -6
  21. package/dist/types/plugin/minimal-plugin-context.d.ts +1 -1
  22. package/dist/types/plugin/plugin-context.d.ts +1 -1
  23. package/dist/types/plugin/transform-plugin-context.d.ts +1 -1
  24. package/dist/types/types/misc.d.ts +40 -0
  25. package/dist/types/types/output-bundle.d.ts +2 -2
  26. package/dist/types/types/rolldown-output.d.ts +8 -11
  27. package/dist/types/utils/bindingify-input-options.d.ts +1 -1
  28. package/dist/types/utils/create-bundler-option.d.ts +1 -1
  29. package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
  30. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -4
  31. package/dist/types/utils/transform-rendered-module.d.ts +2 -2
  32. package/package.json +15 -15
  33. package/dist/types/rollup-types.d.ts +0 -1
  34. package/dist/types/rollup.d.ts +0 -1118
@@ -1,1118 +0,0 @@
1
- // utils
2
- type NullValue = null | undefined | void
3
- type MaybeArray<T> = T | T[]
4
- type MaybePromise<T> = T | Promise<T>
5
-
6
- type PartialNull<T> = {
7
- [P in keyof T]: T[P] | null
8
- }
9
-
10
- export interface RollupError extends RollupLog {
11
- name?: string
12
- stack?: string
13
- watchFiles?: string[]
14
- }
15
-
16
- export type RollupWarning = RollupLog
17
-
18
- export interface RollupLog {
19
- binding?: string
20
- cause?: unknown
21
- code?: string
22
- exporter?: string
23
- frame?: string
24
- hook?: string
25
- id?: string
26
- ids?: string[]
27
- loc?: {
28
- column: number
29
- file?: string
30
- line: number
31
- }
32
- message: string
33
- meta?: any
34
- names?: string[]
35
- plugin?: string
36
- pluginCode?: unknown
37
- pos?: number
38
- reexporter?: string
39
- stack?: string
40
- url?: string
41
- }
42
-
43
- export type LogLevel = 'warn' | 'info' | 'debug'
44
- export type LogLevelOption = LogLevel | 'silent'
45
-
46
- export type SourceMapSegment =
47
- | [number]
48
- | [number, number, number, number]
49
- | [number, number, number, number, number]
50
-
51
- export interface ExistingDecodedSourceMap {
52
- file?: string
53
- readonly mappings: SourceMapSegment[][]
54
- names: string[]
55
- sourceRoot?: string
56
- sources: string[]
57
- sourcesContent?: (string | null)[]
58
- version: number
59
- x_google_ignoreList?: number[]
60
- }
61
-
62
- export interface ExistingRawSourceMap {
63
- file?: string
64
- mappings: string
65
- names: string[]
66
- sourceRoot?: string
67
- sources: string[]
68
- sourcesContent?: (string | null)[]
69
- version: number
70
- x_google_ignoreList?: number[]
71
- }
72
-
73
- export type DecodedSourceMapOrMissing =
74
- | {
75
- missing: true
76
- plugin: string
77
- }
78
- | (ExistingDecodedSourceMap & { missing?: false })
79
-
80
- export interface SourceMap {
81
- file: string
82
- mappings: string
83
- names: string[]
84
- sources: string[]
85
- sourcesContent: (string | null)[]
86
- version: number
87
- toString(): string
88
- toUrl(): string
89
- }
90
-
91
- export type SourceMapInput =
92
- | ExistingRawSourceMap
93
- | string
94
- | null
95
- | { mappings: '' }
96
-
97
- interface ModuleOptions {
98
- assertions: Record<string, string>
99
- meta: CustomPluginOptions
100
- moduleSideEffects: boolean | 'no-treeshake'
101
- syntheticNamedExports: boolean | string
102
- }
103
-
104
- export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
105
- ast?: AcornNode
106
- code: string
107
- map?: SourceMapInput
108
- }
109
-
110
- export interface TransformModuleJSON {
111
- ast?: AcornNode
112
- code: string
113
- // note if plugins use new this.cache to opt-out auto transform cache
114
- customTransformCache: boolean
115
- originalCode: string
116
- originalSourcemap: ExistingDecodedSourceMap | null
117
- sourcemapChain: DecodedSourceMapOrMissing[]
118
- transformDependencies: string[]
119
- }
120
-
121
- export interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
122
- ast: AcornNode
123
- dependencies: string[]
124
- id: string
125
- resolvedIds: ResolvedIdMap
126
- transformFiles: EmittedFile[] | undefined
127
- }
128
-
129
- export interface PluginCache {
130
- delete(id: string): boolean
131
- get<T = any>(id: string): T
132
- has(id: string): boolean
133
- set<T = any>(id: string, value: T): void
134
- }
135
-
136
- export type LoggingFunction = (
137
- log: RollupLog | string | (() => RollupLog | string),
138
- ) => void
139
-
140
- export interface MinimalPluginContext {
141
- debug: LoggingFunction
142
- error: (error: RollupError | string) => never
143
- info: LoggingFunction
144
- meta: PluginContextMeta
145
- warn: LoggingFunction
146
- }
147
-
148
- export interface EmittedAsset {
149
- fileName?: string
150
- name?: string
151
- needsCodeReference?: boolean
152
- source?: string | Uint8Array
153
- type: 'asset'
154
- }
155
-
156
- export interface EmittedChunk {
157
- fileName?: string
158
- id: string
159
- implicitlyLoadedAfterOneOf?: string[]
160
- importer?: string
161
- name?: string
162
- preserveSignature?: PreserveEntrySignaturesOption
163
- type: 'chunk'
164
- }
165
-
166
- export interface EmittedPrebuiltChunk {
167
- code: string
168
- exports?: string[]
169
- fileName: string
170
- map?: SourceMap
171
- sourcemapFileName?: string
172
- type: 'prebuilt-chunk'
173
- }
174
-
175
- export type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk
176
-
177
- export type EmitFile = (emittedFile: EmittedFile) => string
178
-
179
- interface ModuleInfo extends ModuleOptions {
180
- ast: AcornNode | null
181
- code: string | null
182
- dynamicImporters: readonly string[]
183
- dynamicallyImportedIdResolutions: readonly ResolvedId[]
184
- dynamicallyImportedIds: readonly string[]
185
- exportedBindings: Record<string, string[]> | null
186
- exports: string[] | null
187
- hasDefaultExport: boolean | null
188
- /** @deprecated Use `moduleSideEffects` instead */
189
- hasModuleSideEffects: boolean | 'no-treeshake'
190
- id: string
191
- implicitlyLoadedAfterOneOf: readonly string[]
192
- implicitlyLoadedBefore: readonly string[]
193
- importedIdResolutions: readonly ResolvedId[]
194
- importedIds: readonly string[]
195
- importers: readonly string[]
196
- isEntry: boolean
197
- isExternal: boolean
198
- isIncluded: boolean | null
199
- }
200
-
201
- export type GetModuleInfo = (moduleId: string) => ModuleInfo | null
202
-
203
- export interface CustomPluginOptions {
204
- [plugin: string]: any
205
- }
206
-
207
- type LoggingFunctionWithPosition = (
208
- log: RollupLog | string | (() => RollupLog | string),
209
- pos?: number | { column: number; line: number },
210
- ) => void
211
-
212
- export interface PluginContext extends MinimalPluginContext {
213
- addWatchFile: (id: string) => void
214
- cache: PluginCache
215
- debug: LoggingFunction
216
- emitFile: EmitFile
217
- error: (error: RollupError | string) => never
218
- getFileName: (fileReferenceId: string) => string
219
- getModuleIds: () => IterableIterator<string>
220
- getModuleInfo: GetModuleInfo
221
- getWatchFiles: () => string[]
222
- info: LoggingFunction
223
- load: (
224
- options: { id: string; resolveDependencies?: boolean } & Partial<
225
- PartialNull<ModuleOptions>
226
- >,
227
- ) => Promise<ModuleInfo>
228
- /** @deprecated Use `this.getModuleIds` instead */
229
- moduleIds: IterableIterator<string>
230
- parse: (input: string, options?: any) => AcornNode
231
- resolve: (
232
- source: string,
233
- importer?: string,
234
- options?: {
235
- assertions?: Record<string, string>
236
- custom?: CustomPluginOptions
237
- isEntry?: boolean
238
- skipSelf?: boolean
239
- },
240
- ) => Promise<ResolvedId | null>
241
- setAssetSource: (
242
- assetReferenceId: string,
243
- source: string | Uint8Array,
244
- ) => void
245
- warn: LoggingFunction
246
- }
247
-
248
- export interface PluginContextMeta {
249
- rollupVersion: string
250
- watchMode: boolean
251
- }
252
-
253
- export interface ResolvedId extends ModuleOptions {
254
- external: boolean | 'absolute'
255
- id: string
256
- resolvedBy: string
257
- }
258
-
259
- export interface ResolvedIdMap {
260
- [key: string]: ResolvedId
261
- }
262
-
263
- interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
264
- external?: boolean | 'absolute' | 'relative'
265
- id: string
266
- resolvedBy?: string
267
- }
268
-
269
- export type ResolveIdResult = string | NullValue | false | PartialResolvedId
270
-
271
- export type ResolveIdResultWithoutNullValue = string | false | PartialResolvedId
272
-
273
- export type ResolveIdHook = (
274
- this: PluginContext,
275
- source: string,
276
- importer: string | undefined,
277
- options: {
278
- assertions: Record<string, string>
279
- custom?: CustomPluginOptions
280
- isEntry: boolean
281
- },
282
- ) => ResolveIdResult
283
-
284
- export type ShouldTransformCachedModuleHook = (
285
- this: PluginContext,
286
- options: {
287
- ast: AcornNode
288
- code: string
289
- id: string
290
- meta: CustomPluginOptions
291
- moduleSideEffects: boolean | 'no-treeshake'
292
- resolvedSources: ResolvedIdMap
293
- syntheticNamedExports: boolean | string
294
- },
295
- ) => boolean | NullValue
296
-
297
- export type IsExternal = (
298
- source: string,
299
- importer: string | undefined,
300
- isResolved: boolean,
301
- ) => boolean
302
-
303
- export type IsPureModule = (id: string) => boolean | NullValue
304
-
305
- export type HasModuleSideEffects = (id: string, external: boolean) => boolean
306
-
307
- export type LoadResult = SourceDescription | string | NullValue
308
-
309
- export type LoadHook = (this: PluginContext, id: string) => LoadResult
310
-
311
- export interface TransformPluginContext extends PluginContext {
312
- debug: LoggingFunctionWithPosition
313
- error: (
314
- error: RollupError | string,
315
- pos?: number | { column: number; line: number },
316
- ) => never
317
- getCombinedSourcemap: () => SourceMap
318
- info: LoggingFunctionWithPosition
319
- warn: LoggingFunctionWithPosition
320
- }
321
-
322
- export type TransformResult = string | NullValue | Partial<SourceDescription>
323
-
324
- export type TransformHook = (
325
- this: TransformPluginContext,
326
- code: string,
327
- id: string,
328
- ) => TransformResult
329
-
330
- export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void
331
-
332
- export type RenderChunkHook = (
333
- this: PluginContext,
334
- code: string,
335
- chunk: RenderedChunk,
336
- options: NormalizedOutputOptions,
337
- meta: { chunks: Record<string, RenderedChunk> },
338
- ) => { code: string; map?: SourceMapInput } | string | NullValue
339
-
340
- export type ResolveDynamicImportHook = (
341
- this: PluginContext,
342
- specifier: string | AcornNode,
343
- importer: string,
344
- options: { assertions: Record<string, string> },
345
- ) => ResolveIdResult
346
-
347
- export type ResolveImportMetaHook = (
348
- this: PluginContext,
349
- property: string | null,
350
- options: { chunkId: string; format: InternalModuleFormat; moduleId: string },
351
- ) => string | NullValue
352
-
353
- export type ResolveFileUrlHook = (
354
- this: PluginContext,
355
- options: {
356
- chunkId: string
357
- fileName: string
358
- format: InternalModuleFormat
359
- moduleId: string
360
- referenceId: string
361
- relativePath: string
362
- },
363
- ) => string | NullValue
364
-
365
- export type AddonHookFunction = (
366
- this: PluginContext,
367
- chunk: RenderedChunk,
368
- ) => string | Promise<string>
369
- export type AddonHook = string | AddonHookFunction
370
-
371
- export type ChangeEvent = 'create' | 'update' | 'delete'
372
- export type WatchChangeHook = (
373
- this: PluginContext,
374
- id: string,
375
- change: { event: ChangeEvent },
376
- ) => void
377
-
378
- /**
379
- * use this type for plugin annotation
380
- * @example
381
- * ```ts
382
- * interface Options {
383
- * ...
384
- * }
385
- * const myPlugin: PluginImpl<Options> = (options = {}) => { ... }
386
- * ```
387
- */
388
- // eslint-disable-next-line @typescript-eslint/ban-types
389
- export type PluginImpl<O extends object = object, A = any> = (
390
- options?: O,
391
- ) => Plugin<A>
392
-
393
- export interface OutputBundle {
394
- [fileName: string]: OutputAsset | OutputChunk
395
- }
396
-
397
- export interface FunctionPluginHooks {
398
- augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void
399
- buildEnd: (this: PluginContext, error?: Error) => void
400
- buildStart: (this: PluginContext, options: NormalizedInputOptions) => void
401
- closeBundle: (this: PluginContext) => void
402
- closeWatcher: (this: PluginContext) => void
403
- generateBundle: (
404
- this: PluginContext,
405
- options: NormalizedOutputOptions,
406
- bundle: OutputBundle,
407
- isWrite: boolean,
408
- ) => void
409
- load: LoadHook
410
- moduleParsed: ModuleParsedHook
411
- onLog: (
412
- this: MinimalPluginContext,
413
- level: LogLevel,
414
- log: RollupLog,
415
- ) => boolean | NullValue
416
- options: (
417
- this: MinimalPluginContext,
418
- options: InputOptions,
419
- ) => InputOptions | NullValue
420
- outputOptions: (
421
- this: PluginContext,
422
- options: OutputOptions,
423
- ) => OutputOptions | NullValue
424
- renderChunk: RenderChunkHook
425
- renderDynamicImport: (
426
- this: PluginContext,
427
- options: {
428
- customResolution: string | null
429
- format: InternalModuleFormat
430
- moduleId: string
431
- targetModuleId: string | null
432
- },
433
- ) => { left: string; right: string } | NullValue
434
- renderError: (this: PluginContext, error?: Error) => void
435
- renderStart: (
436
- this: PluginContext,
437
- outputOptions: NormalizedOutputOptions,
438
- inputOptions: NormalizedInputOptions,
439
- ) => void
440
- resolveDynamicImport: ResolveDynamicImportHook
441
- resolveFileUrl: ResolveFileUrlHook
442
- resolveId: ResolveIdHook
443
- resolveImportMeta: ResolveImportMetaHook
444
- shouldTransformCachedModule: ShouldTransformCachedModuleHook
445
- transform: TransformHook
446
- watchChange: WatchChangeHook
447
- writeBundle: (
448
- this: PluginContext,
449
- options: NormalizedOutputOptions,
450
- bundle: OutputBundle,
451
- ) => void
452
- }
453
-
454
- export type OutputPluginHooks =
455
- | 'augmentChunkHash'
456
- | 'generateBundle'
457
- | 'outputOptions'
458
- | 'renderChunk'
459
- | 'renderDynamicImport'
460
- | 'renderError'
461
- | 'renderStart'
462
- | 'resolveFileUrl'
463
- | 'resolveImportMeta'
464
- | 'writeBundle'
465
-
466
- export type InputPluginHooks = Exclude<
467
- keyof FunctionPluginHooks,
468
- OutputPluginHooks
469
- >
470
-
471
- export type SyncPluginHooks =
472
- | 'augmentChunkHash'
473
- | 'onLog'
474
- | 'outputOptions'
475
- | 'renderDynamicImport'
476
- | 'resolveFileUrl'
477
- | 'resolveImportMeta'
478
-
479
- export type AsyncPluginHooks = Exclude<
480
- keyof FunctionPluginHooks,
481
- SyncPluginHooks
482
- >
483
-
484
- export type FirstPluginHooks =
485
- | 'load'
486
- | 'renderDynamicImport'
487
- | 'resolveDynamicImport'
488
- | 'resolveFileUrl'
489
- | 'resolveId'
490
- | 'resolveImportMeta'
491
- | 'shouldTransformCachedModule'
492
-
493
- export type SequentialPluginHooks =
494
- | 'augmentChunkHash'
495
- | 'generateBundle'
496
- | 'onLog'
497
- | 'options'
498
- | 'outputOptions'
499
- | 'renderChunk'
500
- | 'transform'
501
-
502
- export type ParallelPluginHooks = Exclude<
503
- keyof FunctionPluginHooks | AddonHooks,
504
- FirstPluginHooks | SequentialPluginHooks
505
- >
506
-
507
- export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro'
508
-
509
- type MakeAsync<Function_> = Function_ extends (
510
- this: infer This,
511
- ...parameters: infer Arguments
512
- ) => infer Return
513
- ? (this: This, ...parameters: Arguments) => Return | Promise<Return>
514
- : never
515
-
516
- // eslint-disable-next-line @typescript-eslint/ban-types
517
- type ObjectHook<T, O = {}> =
518
- | T
519
- | ({ handler: T; order?: 'pre' | 'post' | null } & O)
520
-
521
- export type PluginHooks = {
522
- [K in keyof FunctionPluginHooks]: ObjectHook<
523
- K extends AsyncPluginHooks
524
- ? MakeAsync<FunctionPluginHooks[K]>
525
- : FunctionPluginHooks[K],
526
- // eslint-disable-next-line @typescript-eslint/ban-types
527
- K extends ParallelPluginHooks ? { sequential?: boolean } : {}
528
- >
529
- }
530
-
531
- export interface OutputPlugin
532
- extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>,
533
- Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
534
- cacheKey?: string
535
- name: string
536
- version?: string
537
- }
538
-
539
- export interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
540
- // for inter-plugin communication
541
- api?: A
542
- }
543
-
544
- export type TreeshakingPreset = 'smallest' | 'safest' | 'recommended'
545
-
546
- export interface NormalizedTreeshakingOptions {
547
- annotations: boolean
548
- correctVarValueBeforeDeclaration: boolean
549
- manualPureFunctions: readonly string[]
550
- moduleSideEffects: HasModuleSideEffects
551
- propertyReadSideEffects: boolean | 'always'
552
- tryCatchDeoptimization: boolean
553
- unknownGlobalSideEffects: boolean
554
- }
555
-
556
- export interface TreeshakingOptions
557
- extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
558
- moduleSideEffects?: ModuleSideEffectsOption
559
- preset?: TreeshakingPreset
560
- }
561
-
562
- interface ManualChunkMeta {
563
- getModuleIds: () => IterableIterator<string>
564
- getModuleInfo: GetModuleInfo
565
- }
566
- export type GetManualChunk = (
567
- id: string,
568
- meta: ManualChunkMeta,
569
- ) => string | NullValue
570
-
571
- export type ExternalOption =
572
- | (string | RegExp)[]
573
- | string
574
- | RegExp
575
- | ((
576
- source: string,
577
- importer: string | undefined,
578
- isResolved: boolean,
579
- ) => boolean | NullValue)
580
-
581
- export type GlobalsOption =
582
- | { [name: string]: string }
583
- | ((name: string) => string)
584
-
585
- export type InputOption = string | string[] | { [entryAlias: string]: string }
586
-
587
- export type ManualChunksOption =
588
- | { [chunkAlias: string]: string[] }
589
- | GetManualChunk
590
-
591
- export type LogHandlerWithDefault = (
592
- level: LogLevel,
593
- log: RollupLog,
594
- defaultHandler: LogOrStringHandler,
595
- ) => void
596
-
597
- export type LogOrStringHandler = (
598
- level: LogLevel | 'error',
599
- log: RollupLog | string,
600
- ) => void
601
-
602
- export type LogHandler = (level: LogLevel, log: RollupLog) => void
603
-
604
- export type ModuleSideEffectsOption =
605
- | boolean
606
- | 'no-external'
607
- | string[]
608
- | HasModuleSideEffects
609
-
610
- export type PreserveEntrySignaturesOption =
611
- | false
612
- | 'strict'
613
- | 'allow-extension'
614
- | 'exports-only'
615
-
616
- export type SourcemapPathTransformOption = (
617
- relativeSourcePath: string,
618
- sourcemapPath: string,
619
- ) => string
620
-
621
- export type SourcemapIgnoreListOption = (
622
- relativeSourcePath: string,
623
- sourcemapPath: string,
624
- ) => boolean
625
-
626
- export type InputPluginOption = MaybePromise<
627
- Plugin | NullValue | false | InputPluginOption[]
628
- >
629
-
630
- export interface InputOptions {
631
- acorn?: Record<string, unknown>
632
- acornInjectPlugins?:
633
- | ((...arguments_: any[]) => unknown)[]
634
- | ((...arguments_: any[]) => unknown)
635
- cache?: boolean | RollupCache
636
- context?: string
637
- experimentalCacheExpiry?: number
638
- experimentalLogSideEffects?: boolean
639
- external?: ExternalOption
640
- /** @deprecated Use the "inlineDynamicImports" output option instead. */
641
- inlineDynamicImports?: boolean
642
- input?: InputOption
643
- logLevel?: LogLevelOption
644
- makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource'
645
- /** @deprecated Use the "manualChunks" output option instead. */
646
- manualChunks?: ManualChunksOption
647
- maxParallelFileOps?: number
648
- /** @deprecated Use the "maxParallelFileOps" option instead. */
649
- maxParallelFileReads?: number
650
- moduleContext?:
651
- | ((id: string) => string | NullValue)
652
- | { [id: string]: string }
653
- onLog?: LogHandlerWithDefault
654
- onwarn?: WarningHandlerWithDefault
655
- perf?: boolean
656
- plugins?: InputPluginOption
657
- preserveEntrySignatures?: PreserveEntrySignaturesOption
658
- /** @deprecated Use the "preserveModules" output option instead. */
659
- preserveModules?: boolean
660
- preserveSymlinks?: boolean
661
- shimMissingExports?: boolean
662
- strictDeprecations?: boolean
663
- treeshake?: boolean | TreeshakingPreset | TreeshakingOptions
664
- watch?: WatcherOptions | false
665
- }
666
-
667
- export interface InputOptionsWithPlugins extends InputOptions {
668
- plugins: Plugin[]
669
- }
670
-
671
- export interface NormalizedInputOptions {
672
- acorn: Record<string, unknown>
673
- acornInjectPlugins: (() => unknown)[]
674
- cache: false | undefined | RollupCache
675
- context: string
676
- experimentalCacheExpiry: number
677
- experimentalLogSideEffects: boolean
678
- external: IsExternal
679
- /** @deprecated Use the "inlineDynamicImports" output option instead. */
680
- inlineDynamicImports: boolean | undefined
681
- input: string[] | { [entryAlias: string]: string }
682
- logLevel: LogLevelOption
683
- makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource'
684
- /** @deprecated Use the "manualChunks" output option instead. */
685
- manualChunks: ManualChunksOption | undefined
686
- maxParallelFileOps: number
687
- /** @deprecated Use the "maxParallelFileOps" option instead. */
688
- maxParallelFileReads: number
689
- moduleContext: (id: string) => string
690
- onLog: LogHandler
691
- onwarn: (warning: RollupLog) => void
692
- perf: boolean
693
- plugins: Plugin[]
694
- preserveEntrySignatures: PreserveEntrySignaturesOption
695
- /** @deprecated Use the "preserveModules" output option instead. */
696
- preserveModules: boolean | undefined
697
- preserveSymlinks: boolean
698
- shimMissingExports: boolean
699
- strictDeprecations: boolean
700
- treeshake: false | NormalizedTreeshakingOptions
701
- }
702
-
703
- export type InternalModuleFormat =
704
- | 'amd'
705
- | 'cjs'
706
- | 'es'
707
- | 'iife'
708
- | 'system'
709
- | 'umd'
710
-
711
- export type ModuleFormat =
712
- | InternalModuleFormat
713
- | 'commonjs'
714
- | 'esm'
715
- | 'module'
716
- | 'systemjs'
717
-
718
- type GeneratedCodePreset = 'es5' | 'es2015'
719
-
720
- interface NormalizedGeneratedCodeOptions {
721
- arrowFunctions: boolean
722
- constBindings: boolean
723
- objectShorthand: boolean
724
- reservedNamesAsProps: boolean
725
- symbols: boolean
726
- }
727
-
728
- interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
729
- preset?: GeneratedCodePreset
730
- }
731
-
732
- export type OptionsPaths = Record<string, string> | ((id: string) => string)
733
-
734
- export type InteropType =
735
- | 'compat'
736
- | 'auto'
737
- | 'esModule'
738
- | 'default'
739
- | 'defaultOnly'
740
-
741
- export type GetInterop = (id: string | null) => InteropType
742
-
743
- export type AmdOptions = (
744
- | {
745
- autoId?: false
746
- id: string
747
- }
748
- | {
749
- autoId: true
750
- basePath?: string
751
- id?: undefined
752
- }
753
- | {
754
- autoId?: false
755
- id?: undefined
756
- }
757
- ) & {
758
- define?: string
759
- forceJsExtensionForImports?: boolean
760
- }
761
-
762
- export type NormalizedAmdOptions = (
763
- | {
764
- autoId: false
765
- id?: string
766
- }
767
- | {
768
- autoId: true
769
- basePath: string
770
- }
771
- ) & {
772
- define: string
773
- forceJsExtensionForImports: boolean
774
- }
775
-
776
- type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>
777
-
778
- type OutputPluginOption = MaybePromise<
779
- OutputPlugin | NullValue | false | OutputPluginOption[]
780
- >
781
-
782
- export interface OutputOptions {
783
- amd?: AmdOptions
784
- assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string)
785
- banner?: string | AddonFunction
786
- chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string)
787
- compact?: boolean
788
- // only required for bundle.write
789
- dir?: string
790
- /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
791
- dynamicImportFunction?: string
792
- dynamicImportInCjs?: boolean
793
- entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string)
794
- esModule?: boolean | 'if-default-prop'
795
- /** @deprecated This option is no longer needed and ignored. */
796
- experimentalDeepDynamicChunkOptimization?: boolean
797
- experimentalMinChunkSize?: number
798
- exports?: 'default' | 'named' | 'none' | 'auto'
799
- extend?: boolean
800
- externalImportAssertions?: boolean
801
- externalLiveBindings?: boolean
802
- // only required for bundle.write
803
- file?: string
804
- footer?: string | AddonFunction
805
- format?: ModuleFormat
806
- freeze?: boolean
807
- generatedCode?: GeneratedCodePreset | GeneratedCodeOptions
808
- globals?: GlobalsOption
809
- hoistTransitiveImports?: boolean
810
- indent?: string | boolean
811
- inlineDynamicImports?: boolean
812
- interop?: InteropType | GetInterop
813
- intro?: string | AddonFunction
814
- manualChunks?: ManualChunksOption
815
- minifyInternalExports?: boolean
816
- name?: string
817
- /** @deprecated Use "generatedCode.symbols" instead. */
818
- namespaceToStringTag?: boolean
819
- noConflict?: boolean
820
- outro?: string | AddonFunction
821
- paths?: OptionsPaths
822
- plugins?: OutputPluginOption
823
- /** @deprecated Use "generatedCode.constBindings" instead. */
824
- preferConst?: boolean
825
- preserveModules?: boolean
826
- preserveModulesRoot?: string
827
- sanitizeFileName?: boolean | ((fileName: string) => string)
828
- sourcemap?: boolean | 'inline' | 'hidden'
829
- sourcemapBaseUrl?: string
830
- sourcemapExcludeSources?: boolean
831
- sourcemapFile?: string
832
- sourcemapFileNames?: string | ((chunkInfo: PreRenderedChunk) => string)
833
- sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption
834
- sourcemapPathTransform?: SourcemapPathTransformOption
835
- strict?: boolean
836
- systemNullSetters?: boolean
837
- validate?: boolean
838
- }
839
-
840
- export interface NormalizedOutputOptions {
841
- amd: NormalizedAmdOptions
842
- assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string)
843
- banner: AddonFunction
844
- chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string)
845
- compact: boolean
846
- dir: string | undefined
847
- /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
848
- dynamicImportFunction: string | undefined
849
- dynamicImportInCjs: boolean
850
- entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string)
851
- esModule: boolean | 'if-default-prop'
852
- /** @deprecated This option is no longer needed and ignored. */
853
- experimentalDeepDynamicChunkOptimization: boolean
854
- experimentalMinChunkSize: number
855
- exports: 'default' | 'named' | 'none' | 'auto'
856
- extend: boolean
857
- externalImportAssertions: boolean
858
- externalLiveBindings: boolean
859
- file: string | undefined
860
- footer: AddonFunction
861
- format: InternalModuleFormat
862
- freeze: boolean
863
- generatedCode: NormalizedGeneratedCodeOptions
864
- globals: GlobalsOption
865
- hoistTransitiveImports: boolean
866
- indent: true | string
867
- inlineDynamicImports: boolean
868
- interop: GetInterop
869
- intro: AddonFunction
870
- manualChunks: ManualChunksOption
871
- minifyInternalExports: boolean
872
- name: string | undefined
873
- /** @deprecated Use "generatedCode.symbols" instead. */
874
- namespaceToStringTag: boolean
875
- noConflict: boolean
876
- outro: AddonFunction
877
- paths: OptionsPaths
878
- plugins: OutputPlugin[]
879
- /** @deprecated Use "generatedCode.constBindings" instead. */
880
- preferConst: boolean
881
- preserveModules: boolean
882
- preserveModulesRoot: string | undefined
883
- sanitizeFileName: (fileName: string) => string
884
- sourcemap: boolean | 'inline' | 'hidden'
885
- sourcemapBaseUrl: string | undefined
886
- sourcemapExcludeSources: boolean
887
- sourcemapFile: string | undefined
888
- sourcemapFileNames:
889
- | string
890
- | ((chunkInfo: PreRenderedChunk) => string)
891
- | undefined
892
- sourcemapIgnoreList: SourcemapIgnoreListOption
893
- sourcemapPathTransform: SourcemapPathTransformOption | undefined
894
- strict: boolean
895
- systemNullSetters: boolean
896
- validate: boolean
897
- }
898
-
899
- export type WarningHandlerWithDefault = (
900
- warning: RollupLog,
901
- defaultHandler: LoggingFunction,
902
- ) => void
903
-
904
- export interface SerializedTimings {
905
- [label: string]: [number, number, number]
906
- }
907
-
908
- export interface PreRenderedAsset {
909
- /** @deprecated Use "names" instead. */
910
- name: string | undefined
911
- names: string[]
912
- /** @deprecated Use "originalFileNames" instead. */
913
- originalFileName: string | null
914
- originalFileNames: string[]
915
- source: string | Uint8Array
916
- type: 'asset'
917
- }
918
-
919
- export interface OutputAsset extends PreRenderedAsset {
920
- fileName: string
921
- needsCodeReference: boolean
922
- }
923
-
924
- export interface RenderedModule {
925
- readonly code: string | null
926
- originalLength: number
927
- removedExports: string[]
928
- renderedExports: string[]
929
- renderedLength: number
930
- }
931
-
932
- export interface PreRenderedChunk {
933
- exports: string[]
934
- facadeModuleId: string | null
935
- isDynamicEntry: boolean
936
- isEntry: boolean
937
- isImplicitEntry: boolean
938
- moduleIds: string[]
939
- name: string
940
- type: 'chunk'
941
- }
942
-
943
- export interface RenderedChunk extends PreRenderedChunk {
944
- dynamicImports: string[]
945
- fileName: string
946
- implicitlyLoadedBefore: string[]
947
- importedBindings: {
948
- [imported: string]: string[]
949
- }
950
- imports: string[]
951
- modules: {
952
- [id: string]: RenderedModule
953
- }
954
- referencedFiles: string[]
955
- }
956
-
957
- export interface OutputChunk extends RenderedChunk {
958
- code: string
959
- map: SourceMap | null
960
- sourcemapFileName: string | null
961
- preliminaryFileName: string
962
- }
963
-
964
- export interface SerializablePluginCache {
965
- [key: string]: [number, any]
966
- }
967
-
968
- export interface RollupCache {
969
- modules: ModuleJSON[]
970
- plugins?: Record<string, SerializablePluginCache>
971
- }
972
-
973
- export interface RollupOutput {
974
- output: [OutputChunk, ...(OutputChunk | OutputAsset)[]]
975
- }
976
-
977
- export interface RollupBuild {
978
- cache: RollupCache | undefined
979
- close: () => Promise<void>
980
- closed: boolean
981
- generate: (outputOptions: OutputOptions) => Promise<RollupOutput>
982
- getTimings?: () => SerializedTimings
983
- watchFiles: string[]
984
- write: (options: OutputOptions) => Promise<RollupOutput>
985
- }
986
-
987
- export interface RollupOptions extends InputOptions {
988
- // This is included for compatibility with config files but ignored by rollup.rollup
989
- output?: OutputOptions | OutputOptions[]
990
- }
991
-
992
- export interface MergedRollupOptions extends InputOptionsWithPlugins {
993
- output: OutputOptions[]
994
- }
995
-
996
- export function rollup(options: RollupOptions): Promise<RollupBuild>
997
-
998
- export interface ChokidarOptions {
999
- alwaysStat?: boolean
1000
- atomic?: boolean | number
1001
- awaitWriteFinish?:
1002
- | {
1003
- pollInterval?: number
1004
- stabilityThreshold?: number
1005
- }
1006
- | boolean
1007
- binaryInterval?: number
1008
- cwd?: string
1009
- depth?: number
1010
- disableGlobbing?: boolean
1011
- followSymlinks?: boolean
1012
- ignoreInitial?: boolean
1013
- ignorePermissionErrors?: boolean
1014
- ignored?: any
1015
- interval?: number
1016
- persistent?: boolean
1017
- useFsEvents?: boolean
1018
- usePolling?: boolean
1019
- }
1020
-
1021
- export type RollupWatchHooks =
1022
- | 'onError'
1023
- | 'onStart'
1024
- | 'onBundleStart'
1025
- | 'onBundleEnd'
1026
- | 'onEnd'
1027
-
1028
- export interface WatcherOptions {
1029
- buildDelay?: number
1030
- chokidar?: ChokidarOptions
1031
- clearScreen?: boolean
1032
- exclude?: string | RegExp | (string | RegExp)[]
1033
- include?: string | RegExp | (string | RegExp)[]
1034
- skipWrite?: boolean
1035
- }
1036
-
1037
- export interface RollupWatchOptions extends InputOptions {
1038
- output?: OutputOptions | OutputOptions[]
1039
- watch?: WatcherOptions | false
1040
- }
1041
-
1042
- export type AwaitedEventListener<
1043
- T extends { [event: string]: (...parameters: any) => any },
1044
- K extends keyof T,
1045
- > = (...parameters: Parameters<T[K]>) => void | Promise<void>
1046
-
1047
- export interface AwaitingEventEmitter<
1048
- T extends { [event: string]: (...parameters: any) => any },
1049
- > {
1050
- close(): Promise<void>
1051
- emit<K extends keyof T>(
1052
- event: K,
1053
- ...parameters: Parameters<T[K]>
1054
- ): Promise<unknown>
1055
- /**
1056
- * Removes an event listener.
1057
- */
1058
- off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this
1059
- /**
1060
- * Registers an event listener that will be awaited before Rollup continues.
1061
- * All listeners will be awaited in parallel while rejections are tracked via
1062
- * Promise.all.
1063
- */
1064
- on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this
1065
- /**
1066
- * Registers an event listener that will be awaited before Rollup continues.
1067
- * All listeners will be awaited in parallel while rejections are tracked via
1068
- * Promise.all.
1069
- * Listeners are removed automatically when removeListenersForCurrentRun is
1070
- * called, which happens automatically after each run.
1071
- */
1072
- onCurrentRun<K extends keyof T>(
1073
- event: K,
1074
- listener: (...parameters: Parameters<T[K]>) => Promise<ReturnType<T[K]>>,
1075
- ): this
1076
- removeAllListeners(): this
1077
- removeListenersForCurrentRun(): this
1078
- }
1079
-
1080
- export type RollupWatcherEvent =
1081
- | { code: 'START' }
1082
- | { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
1083
- | {
1084
- code: 'BUNDLE_END'
1085
- duration: number
1086
- input?: InputOption
1087
- output: readonly string[]
1088
- result: RollupBuild
1089
- }
1090
- | { code: 'END' }
1091
- | { code: 'ERROR'; error: RollupError; result: RollupBuild | null }
1092
-
1093
- export type RollupWatcher = AwaitingEventEmitter<{
1094
- change: (id: string, change: { event: ChangeEvent }) => void
1095
- close: () => void
1096
- event: (event: RollupWatcherEvent) => void
1097
- restart: () => void
1098
- }>
1099
-
1100
- export function watch(
1101
- config: RollupWatchOptions | RollupWatchOptions[],
1102
- ): RollupWatcher
1103
-
1104
- interface AcornNode {
1105
- end: number
1106
- start: number
1107
- type: string
1108
- }
1109
-
1110
- export function defineConfig(options: RollupOptions): RollupOptions
1111
- export function defineConfig(options: RollupOptions[]): RollupOptions[]
1112
- export function defineConfig(
1113
- optionsFunction: RollupOptionsFunction,
1114
- ): RollupOptionsFunction
1115
-
1116
- export type RollupOptionsFunction = (
1117
- commandLineArguments: Record<string, any>,
1118
- ) => MaybePromise<RollupOptions | RollupOptions[]>