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