@modern-js/module-tools 2.21.1 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/compiled/@rollup/plugin-json/@rollup/pluginutils/types/index.d.ts +8 -2
- package/compiled/@rollup/plugin-json/estree/index.d.ts +677 -548
- package/compiled/@rollup/plugin-json/index.js +1 -1
- package/compiled/@rollup/plugin-json/package.json +1 -1
- package/compiled/@rollup/plugin-json/rollup/dist/rollup.d.ts +167 -150
- package/compiled/@rollup/plugin-json/types/index.d.ts +2 -2
- package/compiled/rollup/249.index.js +103 -0
- package/compiled/rollup/index.js +36 -21
- package/compiled/rollup/package.json +1 -1
- package/compiled/rollup/types/rollup.d.ts +167 -150
- package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +3 -105
- package/compiled/rollup-plugin-dts/index.js +1 -1
- package/compiled/rollup-plugin-dts/package.json +1 -1
- package/compiled/rollup-plugin-dts/rollup/dist/rollup.d.ts +167 -150
- package/dist/build.js +3 -1
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +37 -14
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +6 -2
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +9 -3
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +6 -2
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +3 -1
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +6 -2
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +3 -1
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +3 -1
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/command.js +12 -4
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +6 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +21 -7
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +18 -6
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.js +21 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +30 -10
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +3 -1
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +54 -18
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +9 -3
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +12 -4
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +9 -3
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +18 -6
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +21 -7
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +6 -2
- package/dist/dev.js.map +1 -1
- package/dist/error.js +18 -6
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +6 -2
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +3 -1
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +3 -1
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/locale/en.js +3 -1
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.js +6 -2
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.js +3 -1
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +3 -1
- package/dist/plugins.js.map +1 -1
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/config/index.js.map +1 -1
- package/dist/utils/builder.js +15 -5
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +3 -1
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +15 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +3 -1
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +15 -5
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +15 -5
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +3 -1
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +6 -2
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +3 -1
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +3 -1
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +3 -1
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +21 -7
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +12 -4
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +3 -1
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +16 -16
- package/compiled/@rollup/plugin-json/license +0 -21
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
export const VERSION: string;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// utils
|
|
4
|
+
type NullValue = null | undefined | void;
|
|
5
|
+
type MaybeArray<T> = T | T[];
|
|
6
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
|
|
8
|
+
type PartialNull<T> = {
|
|
9
|
+
[P in keyof T]: T[P] | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface RollupError extends RollupLog {
|
|
13
|
+
name?: string;
|
|
5
14
|
stack?: string;
|
|
6
15
|
watchFiles?: string[];
|
|
7
16
|
}
|
|
8
17
|
|
|
9
|
-
export
|
|
10
|
-
chunkName?: string;
|
|
11
|
-
cycle?: string[];
|
|
12
|
-
exportName?: string;
|
|
13
|
-
exporter?: string;
|
|
14
|
-
guess?: string;
|
|
15
|
-
importer?: string;
|
|
16
|
-
missing?: string;
|
|
17
|
-
modules?: string[];
|
|
18
|
-
names?: string[];
|
|
19
|
-
reexporter?: string;
|
|
20
|
-
source?: string;
|
|
21
|
-
sources?: string[];
|
|
22
|
-
}
|
|
18
|
+
export type RollupWarning = RollupLog;
|
|
23
19
|
|
|
24
|
-
export interface
|
|
20
|
+
export interface RollupLog {
|
|
21
|
+
binding?: string;
|
|
22
|
+
cause?: unknown;
|
|
25
23
|
code?: string;
|
|
24
|
+
exporter?: string;
|
|
26
25
|
frame?: string;
|
|
27
26
|
hook?: string;
|
|
28
27
|
id?: string;
|
|
28
|
+
ids?: string[];
|
|
29
29
|
loc?: {
|
|
30
30
|
column: number;
|
|
31
31
|
file?: string;
|
|
32
32
|
line: number;
|
|
33
33
|
};
|
|
34
34
|
message: string;
|
|
35
|
-
|
|
35
|
+
names?: string[];
|
|
36
36
|
plugin?: string;
|
|
37
37
|
pluginCode?: string;
|
|
38
38
|
pos?: number;
|
|
39
|
+
reexporter?: string;
|
|
40
|
+
stack?: string;
|
|
39
41
|
url?: string;
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -50,8 +52,9 @@ export interface ExistingDecodedSourceMap {
|
|
|
50
52
|
names: string[];
|
|
51
53
|
sourceRoot?: string;
|
|
52
54
|
sources: string[];
|
|
53
|
-
sourcesContent?: string[];
|
|
55
|
+
sourcesContent?: (string | null)[];
|
|
54
56
|
version: number;
|
|
57
|
+
x_google_ignoreList?: number[];
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export interface ExistingRawSourceMap {
|
|
@@ -60,8 +63,9 @@ export interface ExistingRawSourceMap {
|
|
|
60
63
|
names: string[];
|
|
61
64
|
sourceRoot?: string;
|
|
62
65
|
sources: string[];
|
|
63
|
-
sourcesContent?: string[];
|
|
66
|
+
sourcesContent?: (string | null)[];
|
|
64
67
|
version: number;
|
|
68
|
+
x_google_ignoreList?: number[];
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
export type DecodedSourceMapOrMissing =
|
|
@@ -77,7 +81,7 @@ export interface SourceMap {
|
|
|
77
81
|
mappings: string;
|
|
78
82
|
names: string[];
|
|
79
83
|
sources: string[];
|
|
80
|
-
sourcesContent: string[];
|
|
84
|
+
sourcesContent: (string | null)[];
|
|
81
85
|
version: number;
|
|
82
86
|
toString(): string;
|
|
83
87
|
toUrl(): string;
|
|
@@ -85,11 +89,8 @@ export interface SourceMap {
|
|
|
85
89
|
|
|
86
90
|
export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
|
|
87
91
|
|
|
88
|
-
type PartialNull<T> = {
|
|
89
|
-
[P in keyof T]: T[P] | null;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
92
|
interface ModuleOptions {
|
|
93
|
+
assertions: Record<string, string>;
|
|
93
94
|
meta: CustomPluginOptions;
|
|
94
95
|
moduleSideEffects: boolean | 'no-treeshake';
|
|
95
96
|
syntheticNamedExports: boolean | string;
|
|
@@ -134,6 +135,7 @@ export interface MinimalPluginContext {
|
|
|
134
135
|
export interface EmittedAsset {
|
|
135
136
|
fileName?: string;
|
|
136
137
|
name?: string;
|
|
138
|
+
needsCodeReference?: boolean;
|
|
137
139
|
source?: string | Uint8Array;
|
|
138
140
|
type: 'asset';
|
|
139
141
|
}
|
|
@@ -148,11 +150,15 @@ export interface EmittedChunk {
|
|
|
148
150
|
type: 'chunk';
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
export
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
export interface EmittedPrebuiltChunk {
|
|
154
|
+
code: string;
|
|
155
|
+
exports?: string[];
|
|
156
|
+
fileName: string;
|
|
157
|
+
map?: SourceMap;
|
|
158
|
+
type: 'prebuilt-chunk';
|
|
159
|
+
}
|
|
154
160
|
|
|
155
|
-
export type
|
|
161
|
+
export type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
|
|
156
162
|
|
|
157
163
|
export type EmitFile = (emittedFile: EmittedFile) => string;
|
|
158
164
|
|
|
@@ -162,6 +168,8 @@ interface ModuleInfo extends ModuleOptions {
|
|
|
162
168
|
dynamicImporters: readonly string[];
|
|
163
169
|
dynamicallyImportedIdResolutions: readonly ResolvedId[];
|
|
164
170
|
dynamicallyImportedIds: readonly string[];
|
|
171
|
+
exportedBindings: Record<string, string[]> | null;
|
|
172
|
+
exports: string[] | null;
|
|
165
173
|
hasDefaultExport: boolean | null;
|
|
166
174
|
/** @deprecated Use `moduleSideEffects` instead */
|
|
167
175
|
hasModuleSideEffects: boolean | 'no-treeshake';
|
|
@@ -185,22 +193,12 @@ export interface CustomPluginOptions {
|
|
|
185
193
|
export interface PluginContext extends MinimalPluginContext {
|
|
186
194
|
addWatchFile: (id: string) => void;
|
|
187
195
|
cache: PluginCache;
|
|
188
|
-
/** @deprecated Use `this.emitFile` instead */
|
|
189
|
-
emitAsset: EmitAsset;
|
|
190
|
-
/** @deprecated Use `this.emitFile` instead */
|
|
191
|
-
emitChunk: EmitChunk;
|
|
192
196
|
emitFile: EmitFile;
|
|
193
|
-
error: (
|
|
194
|
-
/** @deprecated Use `this.getFileName` instead */
|
|
195
|
-
getAssetFileName: (assetReferenceId: string) => string;
|
|
196
|
-
/** @deprecated Use `this.getFileName` instead */
|
|
197
|
-
getChunkFileName: (chunkReferenceId: string) => string;
|
|
197
|
+
error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
|
|
198
198
|
getFileName: (fileReferenceId: string) => string;
|
|
199
199
|
getModuleIds: () => IterableIterator<string>;
|
|
200
200
|
getModuleInfo: GetModuleInfo;
|
|
201
201
|
getWatchFiles: () => string[];
|
|
202
|
-
/** @deprecated Use `this.resolve` instead */
|
|
203
|
-
isExternal: IsExternal;
|
|
204
202
|
load: (
|
|
205
203
|
options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
|
|
206
204
|
) => Promise<ModuleInfo>;
|
|
@@ -210,10 +208,13 @@ export interface PluginContext extends MinimalPluginContext {
|
|
|
210
208
|
resolve: (
|
|
211
209
|
source: string,
|
|
212
210
|
importer?: string,
|
|
213
|
-
options?: {
|
|
211
|
+
options?: {
|
|
212
|
+
assertions?: Record<string, string>;
|
|
213
|
+
custom?: CustomPluginOptions;
|
|
214
|
+
isEntry?: boolean;
|
|
215
|
+
skipSelf?: boolean;
|
|
216
|
+
}
|
|
214
217
|
) => Promise<ResolvedId | null>;
|
|
215
|
-
/** @deprecated Use `this.resolve` instead */
|
|
216
|
-
resolveId: (source: string, importer?: string) => Promise<string | null>;
|
|
217
218
|
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
|
|
218
219
|
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
|
|
219
220
|
}
|
|
@@ -226,6 +227,7 @@ export interface PluginContextMeta {
|
|
|
226
227
|
export interface ResolvedId extends ModuleOptions {
|
|
227
228
|
external: boolean | 'absolute';
|
|
228
229
|
id: string;
|
|
230
|
+
resolvedBy: string;
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
export interface ResolvedIdMap {
|
|
@@ -235,15 +237,18 @@ export interface ResolvedIdMap {
|
|
|
235
237
|
interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
|
|
236
238
|
external?: boolean | 'absolute' | 'relative';
|
|
237
239
|
id: string;
|
|
240
|
+
resolvedBy?: string;
|
|
238
241
|
}
|
|
239
242
|
|
|
240
|
-
export type ResolveIdResult = string |
|
|
243
|
+
export type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
244
|
+
|
|
245
|
+
export type ResolveIdResultWithoutNullValue = string | false | PartialResolvedId;
|
|
241
246
|
|
|
242
247
|
export type ResolveIdHook = (
|
|
243
248
|
this: PluginContext,
|
|
244
249
|
source: string,
|
|
245
250
|
importer: string | undefined,
|
|
246
|
-
options: { custom?: CustomPluginOptions; isEntry: boolean }
|
|
251
|
+
options: { assertions: Record<string, string>; custom?: CustomPluginOptions; isEntry: boolean }
|
|
247
252
|
) => ResolveIdResult;
|
|
248
253
|
|
|
249
254
|
export type ShouldTransformCachedModuleHook = (
|
|
@@ -257,7 +262,7 @@ export type ShouldTransformCachedModuleHook = (
|
|
|
257
262
|
resolvedSources: ResolvedIdMap;
|
|
258
263
|
syntheticNamedExports: boolean | string;
|
|
259
264
|
}
|
|
260
|
-
) => boolean;
|
|
265
|
+
) => boolean | NullValue;
|
|
261
266
|
|
|
262
267
|
export type IsExternal = (
|
|
263
268
|
source: string,
|
|
@@ -265,11 +270,11 @@ export type IsExternal = (
|
|
|
265
270
|
isResolved: boolean
|
|
266
271
|
) => boolean;
|
|
267
272
|
|
|
268
|
-
export type IsPureModule = (id: string) => boolean |
|
|
273
|
+
export type IsPureModule = (id: string) => boolean | NullValue;
|
|
269
274
|
|
|
270
275
|
export type HasModuleSideEffects = (id: string, external: boolean) => boolean;
|
|
271
276
|
|
|
272
|
-
export type LoadResult = SourceDescription | string |
|
|
277
|
+
export type LoadResult = SourceDescription | string | NullValue;
|
|
273
278
|
|
|
274
279
|
export type LoadHook = (this: PluginContext, id: string) => LoadResult;
|
|
275
280
|
|
|
@@ -277,7 +282,7 @@ export interface TransformPluginContext extends PluginContext {
|
|
|
277
282
|
getCombinedSourcemap: () => SourceMap;
|
|
278
283
|
}
|
|
279
284
|
|
|
280
|
-
export type TransformResult = string |
|
|
285
|
+
export type TransformResult = string | NullValue | Partial<SourceDescription>;
|
|
281
286
|
|
|
282
287
|
export type TransformHook = (
|
|
283
288
|
this: TransformPluginContext,
|
|
@@ -291,47 +296,39 @@ export type RenderChunkHook = (
|
|
|
291
296
|
this: PluginContext,
|
|
292
297
|
code: string,
|
|
293
298
|
chunk: RenderedChunk,
|
|
294
|
-
options: NormalizedOutputOptions
|
|
295
|
-
|
|
299
|
+
options: NormalizedOutputOptions,
|
|
300
|
+
meta: { chunks: Record<string, RenderedChunk> }
|
|
301
|
+
) => { code: string; map?: SourceMapInput } | string | NullValue;
|
|
296
302
|
|
|
297
303
|
export type ResolveDynamicImportHook = (
|
|
298
304
|
this: PluginContext,
|
|
299
305
|
specifier: string | AcornNode,
|
|
300
|
-
importer: string
|
|
306
|
+
importer: string,
|
|
307
|
+
options: { assertions: Record<string, string> }
|
|
301
308
|
) => ResolveIdResult;
|
|
302
309
|
|
|
303
310
|
export type ResolveImportMetaHook = (
|
|
304
311
|
this: PluginContext,
|
|
305
|
-
|
|
312
|
+
property: string | null,
|
|
306
313
|
options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
|
|
307
|
-
) => string |
|
|
308
|
-
|
|
309
|
-
export type ResolveAssetUrlHook = (
|
|
310
|
-
this: PluginContext,
|
|
311
|
-
options: {
|
|
312
|
-
assetFileName: string;
|
|
313
|
-
chunkId: string;
|
|
314
|
-
format: InternalModuleFormat;
|
|
315
|
-
moduleId: string;
|
|
316
|
-
relativeAssetPath: string;
|
|
317
|
-
}
|
|
318
|
-
) => string | null | void;
|
|
314
|
+
) => string | NullValue;
|
|
319
315
|
|
|
320
316
|
export type ResolveFileUrlHook = (
|
|
321
317
|
this: PluginContext,
|
|
322
318
|
options: {
|
|
323
|
-
assetReferenceId: string | null;
|
|
324
319
|
chunkId: string;
|
|
325
|
-
chunkReferenceId: string | null;
|
|
326
320
|
fileName: string;
|
|
327
321
|
format: InternalModuleFormat;
|
|
328
322
|
moduleId: string;
|
|
329
323
|
referenceId: string;
|
|
330
324
|
relativePath: string;
|
|
331
325
|
}
|
|
332
|
-
) => string |
|
|
326
|
+
) => string | NullValue;
|
|
333
327
|
|
|
334
|
-
export type AddonHookFunction = (
|
|
328
|
+
export type AddonHookFunction = (
|
|
329
|
+
this: PluginContext,
|
|
330
|
+
chunk: RenderedChunk
|
|
331
|
+
) => string | Promise<string>;
|
|
335
332
|
export type AddonHook = string | AddonHookFunction;
|
|
336
333
|
|
|
337
334
|
export type ChangeEvent = 'create' | 'update' | 'delete';
|
|
@@ -358,17 +355,9 @@ export interface OutputBundle {
|
|
|
358
355
|
[fileName: string]: OutputAsset | OutputChunk;
|
|
359
356
|
}
|
|
360
357
|
|
|
361
|
-
export interface FilePlaceholder {
|
|
362
|
-
type: 'placeholder';
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export interface OutputBundleWithPlaceholders {
|
|
366
|
-
[fileName: string]: OutputAsset | OutputChunk | FilePlaceholder;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
358
|
export interface FunctionPluginHooks {
|
|
370
|
-
augmentChunkHash: (this: PluginContext, chunk:
|
|
371
|
-
buildEnd: (this: PluginContext,
|
|
359
|
+
augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
|
|
360
|
+
buildEnd: (this: PluginContext, error?: Error) => void;
|
|
372
361
|
buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
|
|
373
362
|
closeBundle: (this: PluginContext) => void;
|
|
374
363
|
closeWatcher: (this: PluginContext) => void;
|
|
@@ -380,8 +369,8 @@ export interface FunctionPluginHooks {
|
|
|
380
369
|
) => void;
|
|
381
370
|
load: LoadHook;
|
|
382
371
|
moduleParsed: ModuleParsedHook;
|
|
383
|
-
options: (this: MinimalPluginContext, options: InputOptions) => InputOptions |
|
|
384
|
-
outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions |
|
|
372
|
+
options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue;
|
|
373
|
+
outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue;
|
|
385
374
|
renderChunk: RenderChunkHook;
|
|
386
375
|
renderDynamicImport: (
|
|
387
376
|
this: PluginContext,
|
|
@@ -391,15 +380,13 @@ export interface FunctionPluginHooks {
|
|
|
391
380
|
moduleId: string;
|
|
392
381
|
targetModuleId: string | null;
|
|
393
382
|
}
|
|
394
|
-
) => { left: string; right: string } |
|
|
395
|
-
renderError: (this: PluginContext,
|
|
383
|
+
) => { left: string; right: string } | NullValue;
|
|
384
|
+
renderError: (this: PluginContext, error?: Error) => void;
|
|
396
385
|
renderStart: (
|
|
397
386
|
this: PluginContext,
|
|
398
387
|
outputOptions: NormalizedOutputOptions,
|
|
399
388
|
inputOptions: NormalizedInputOptions
|
|
400
389
|
) => void;
|
|
401
|
-
/** @deprecated Use `resolveFileUrl` instead */
|
|
402
|
-
resolveAssetUrl: ResolveAssetUrlHook;
|
|
403
390
|
resolveDynamicImport: ResolveDynamicImportHook;
|
|
404
391
|
resolveFileUrl: ResolveFileUrlHook;
|
|
405
392
|
resolveId: ResolveIdHook;
|
|
@@ -422,7 +409,6 @@ export type OutputPluginHooks =
|
|
|
422
409
|
| 'renderDynamicImport'
|
|
423
410
|
| 'renderError'
|
|
424
411
|
| 'renderStart'
|
|
425
|
-
| 'resolveAssetUrl'
|
|
426
412
|
| 'resolveFileUrl'
|
|
427
413
|
| 'resolveImportMeta'
|
|
428
414
|
| 'writeBundle';
|
|
@@ -433,7 +419,6 @@ export type SyncPluginHooks =
|
|
|
433
419
|
| 'augmentChunkHash'
|
|
434
420
|
| 'outputOptions'
|
|
435
421
|
| 'renderDynamicImport'
|
|
436
|
-
| 'resolveAssetUrl'
|
|
437
422
|
| 'resolveFileUrl'
|
|
438
423
|
| 'resolveImportMeta';
|
|
439
424
|
|
|
@@ -442,7 +427,6 @@ export type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHook
|
|
|
442
427
|
export type FirstPluginHooks =
|
|
443
428
|
| 'load'
|
|
444
429
|
| 'renderDynamicImport'
|
|
445
|
-
| 'resolveAssetUrl'
|
|
446
430
|
| 'resolveDynamicImport'
|
|
447
431
|
| 'resolveFileUrl'
|
|
448
432
|
| 'resolveId'
|
|
@@ -464,8 +448,11 @@ export type ParallelPluginHooks = Exclude<
|
|
|
464
448
|
|
|
465
449
|
export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
|
|
466
450
|
|
|
467
|
-
type MakeAsync<
|
|
468
|
-
|
|
451
|
+
type MakeAsync<Function_> = Function_ extends (
|
|
452
|
+
this: infer This,
|
|
453
|
+
...parameters: infer Arguments
|
|
454
|
+
) => infer Return
|
|
455
|
+
? (this: This, ...parameters: Arguments) => Return | Promise<Return>
|
|
469
456
|
: never;
|
|
470
457
|
|
|
471
458
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -484,6 +471,7 @@ export interface OutputPlugin
|
|
|
484
471
|
Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
|
|
485
472
|
cacheKey?: string;
|
|
486
473
|
name: string;
|
|
474
|
+
version?: string;
|
|
487
475
|
}
|
|
488
476
|
|
|
489
477
|
export interface Plugin extends OutputPlugin, Partial<PluginHooks> {
|
|
@@ -496,6 +484,7 @@ type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
|
|
|
496
484
|
export interface NormalizedTreeshakingOptions {
|
|
497
485
|
annotations: boolean;
|
|
498
486
|
correctVarValueBeforeDeclaration: boolean;
|
|
487
|
+
manualPureFunctions: readonly string[];
|
|
499
488
|
moduleSideEffects: HasModuleSideEffects;
|
|
500
489
|
propertyReadSideEffects: boolean | 'always';
|
|
501
490
|
tryCatchDeoptimization: boolean;
|
|
@@ -506,21 +495,19 @@ export interface TreeshakingOptions
|
|
|
506
495
|
extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
|
|
507
496
|
moduleSideEffects?: ModuleSideEffectsOption;
|
|
508
497
|
preset?: TreeshakingPreset;
|
|
509
|
-
/** @deprecated Use `moduleSideEffects` instead */
|
|
510
|
-
pureExternalModules?: PureModulesOption;
|
|
511
498
|
}
|
|
512
499
|
|
|
513
|
-
interface
|
|
500
|
+
interface ManualChunkMeta {
|
|
514
501
|
getModuleIds: () => IterableIterator<string>;
|
|
515
502
|
getModuleInfo: GetModuleInfo;
|
|
516
503
|
}
|
|
517
|
-
export type GetManualChunk = (id: string,
|
|
504
|
+
export type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue;
|
|
518
505
|
|
|
519
506
|
export type ExternalOption =
|
|
520
507
|
| (string | RegExp)[]
|
|
521
508
|
| string
|
|
522
509
|
| RegExp
|
|
523
|
-
| ((source: string, importer: string | undefined, isResolved: boolean) => boolean |
|
|
510
|
+
| ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue);
|
|
524
511
|
export type PureModulesOption = boolean | string[] | IsPureModule;
|
|
525
512
|
export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
|
|
526
513
|
export type InputOption = string | string[] | { [entryAlias: string]: string };
|
|
@@ -531,13 +518,20 @@ export type SourcemapPathTransformOption = (
|
|
|
531
518
|
relativeSourcePath: string,
|
|
532
519
|
sourcemapPath: string
|
|
533
520
|
) => string;
|
|
521
|
+
export type SourcemapIgnoreListOption = (
|
|
522
|
+
relativeSourcePath: string,
|
|
523
|
+
sourcemapPath: string
|
|
524
|
+
) => boolean;
|
|
525
|
+
|
|
526
|
+
export type InputPluginOption = MaybePromise<Plugin | NullValue | false | InputPluginOption[]>;
|
|
534
527
|
|
|
535
528
|
export interface InputOptions {
|
|
536
529
|
acorn?: Record<string, unknown>;
|
|
537
|
-
acornInjectPlugins?: (() => unknown)[] | (() => unknown);
|
|
538
|
-
cache?:
|
|
530
|
+
acornInjectPlugins?: ((...arguments_: any[]) => unknown)[] | ((...arguments_: any[]) => unknown);
|
|
531
|
+
cache?: boolean | RollupCache;
|
|
539
532
|
context?: string;
|
|
540
533
|
experimentalCacheExpiry?: number;
|
|
534
|
+
experimentalLogSideEffects?: boolean;
|
|
541
535
|
external?: ExternalOption;
|
|
542
536
|
/** @deprecated Use the "inlineDynamicImports" output option instead. */
|
|
543
537
|
inlineDynamicImports?: boolean;
|
|
@@ -548,10 +542,10 @@ export interface InputOptions {
|
|
|
548
542
|
maxParallelFileOps?: number;
|
|
549
543
|
/** @deprecated Use the "maxParallelFileOps" option instead. */
|
|
550
544
|
maxParallelFileReads?: number;
|
|
551
|
-
moduleContext?: ((id: string) => string |
|
|
545
|
+
moduleContext?: ((id: string) => string | NullValue) | { [id: string]: string };
|
|
552
546
|
onwarn?: WarningHandlerWithDefault;
|
|
553
547
|
perf?: boolean;
|
|
554
|
-
plugins?:
|
|
548
|
+
plugins?: InputPluginOption;
|
|
555
549
|
preserveEntrySignatures?: PreserveEntrySignaturesOption;
|
|
556
550
|
/** @deprecated Use the "preserveModules" output option instead. */
|
|
557
551
|
preserveModules?: boolean;
|
|
@@ -562,12 +556,17 @@ export interface InputOptions {
|
|
|
562
556
|
watch?: WatcherOptions | false;
|
|
563
557
|
}
|
|
564
558
|
|
|
559
|
+
export interface InputOptionsWithPlugins extends InputOptions {
|
|
560
|
+
plugins: Plugin[];
|
|
561
|
+
}
|
|
562
|
+
|
|
565
563
|
export interface NormalizedInputOptions {
|
|
566
564
|
acorn: Record<string, unknown>;
|
|
567
565
|
acornInjectPlugins: (() => unknown)[];
|
|
568
566
|
cache: false | undefined | RollupCache;
|
|
569
567
|
context: string;
|
|
570
568
|
experimentalCacheExpiry: number;
|
|
569
|
+
experimentalLogSideEffects: boolean;
|
|
571
570
|
external: IsExternal;
|
|
572
571
|
/** @deprecated Use the "inlineDynamicImports" output option instead. */
|
|
573
572
|
inlineDynamicImports: boolean | undefined;
|
|
@@ -611,7 +610,7 @@ interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
|
|
|
611
610
|
|
|
612
611
|
export type OptionsPaths = Record<string, string> | ((id: string) => string);
|
|
613
612
|
|
|
614
|
-
export type InteropType =
|
|
613
|
+
export type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly';
|
|
615
614
|
|
|
616
615
|
export type GetInterop = (id: string | null) => InteropType;
|
|
617
616
|
|
|
@@ -648,24 +647,33 @@ export type NormalizedAmdOptions = (
|
|
|
648
647
|
forceJsExtensionForImports: boolean;
|
|
649
648
|
};
|
|
650
649
|
|
|
650
|
+
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
651
|
+
|
|
652
|
+
type OutputPluginOption = MaybePromise<OutputPlugin | NullValue | false | OutputPluginOption[]>;
|
|
653
|
+
|
|
651
654
|
export interface OutputOptions {
|
|
652
655
|
amd?: AmdOptions;
|
|
653
656
|
assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
|
|
654
|
-
banner?: string |
|
|
657
|
+
banner?: string | AddonFunction;
|
|
655
658
|
chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
656
659
|
compact?: boolean;
|
|
657
660
|
// only required for bundle.write
|
|
658
661
|
dir?: string;
|
|
659
662
|
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
|
|
660
663
|
dynamicImportFunction?: string;
|
|
664
|
+
dynamicImportInCjs?: boolean;
|
|
661
665
|
entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
662
|
-
esModule?: boolean;
|
|
666
|
+
esModule?: boolean | 'if-default-prop';
|
|
667
|
+
/** @deprecated This option is no longer needed and ignored. */
|
|
668
|
+
experimentalDeepDynamicChunkOptimization?: boolean;
|
|
669
|
+
experimentalMinChunkSize?: number;
|
|
663
670
|
exports?: 'default' | 'named' | 'none' | 'auto';
|
|
664
671
|
extend?: boolean;
|
|
672
|
+
externalImportAssertions?: boolean;
|
|
665
673
|
externalLiveBindings?: boolean;
|
|
666
674
|
// only required for bundle.write
|
|
667
675
|
file?: string;
|
|
668
|
-
footer?: string |
|
|
676
|
+
footer?: string | AddonFunction;
|
|
669
677
|
format?: ModuleFormat;
|
|
670
678
|
freeze?: boolean;
|
|
671
679
|
generatedCode?: GeneratedCodePreset | GeneratedCodeOptions;
|
|
@@ -674,16 +682,16 @@ export interface OutputOptions {
|
|
|
674
682
|
indent?: string | boolean;
|
|
675
683
|
inlineDynamicImports?: boolean;
|
|
676
684
|
interop?: InteropType | GetInterop;
|
|
677
|
-
intro?: string |
|
|
685
|
+
intro?: string | AddonFunction;
|
|
678
686
|
manualChunks?: ManualChunksOption;
|
|
679
687
|
minifyInternalExports?: boolean;
|
|
680
688
|
name?: string;
|
|
681
689
|
/** @deprecated Use "generatedCode.symbols" instead. */
|
|
682
690
|
namespaceToStringTag?: boolean;
|
|
683
691
|
noConflict?: boolean;
|
|
684
|
-
outro?: string |
|
|
692
|
+
outro?: string | AddonFunction;
|
|
685
693
|
paths?: OptionsPaths;
|
|
686
|
-
plugins?:
|
|
694
|
+
plugins?: OutputPluginOption;
|
|
687
695
|
/** @deprecated Use "generatedCode.constBindings" instead. */
|
|
688
696
|
preferConst?: boolean;
|
|
689
697
|
preserveModules?: boolean;
|
|
@@ -693,6 +701,7 @@ export interface OutputOptions {
|
|
|
693
701
|
sourcemapBaseUrl?: string;
|
|
694
702
|
sourcemapExcludeSources?: boolean;
|
|
695
703
|
sourcemapFile?: string;
|
|
704
|
+
sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
|
|
696
705
|
sourcemapPathTransform?: SourcemapPathTransformOption;
|
|
697
706
|
strict?: boolean;
|
|
698
707
|
systemNullSetters?: boolean;
|
|
@@ -702,19 +711,24 @@ export interface OutputOptions {
|
|
|
702
711
|
export interface NormalizedOutputOptions {
|
|
703
712
|
amd: NormalizedAmdOptions;
|
|
704
713
|
assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
|
|
705
|
-
banner:
|
|
714
|
+
banner: AddonFunction;
|
|
706
715
|
chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
707
716
|
compact: boolean;
|
|
708
717
|
dir: string | undefined;
|
|
709
718
|
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
|
|
710
719
|
dynamicImportFunction: string | undefined;
|
|
720
|
+
dynamicImportInCjs: boolean;
|
|
711
721
|
entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
712
|
-
esModule: boolean;
|
|
722
|
+
esModule: boolean | 'if-default-prop';
|
|
723
|
+
/** @deprecated This option is no longer needed and ignored. */
|
|
724
|
+
experimentalDeepDynamicChunkOptimization: boolean;
|
|
725
|
+
experimentalMinChunkSize: number;
|
|
713
726
|
exports: 'default' | 'named' | 'none' | 'auto';
|
|
714
727
|
extend: boolean;
|
|
728
|
+
externalImportAssertions: boolean;
|
|
715
729
|
externalLiveBindings: boolean;
|
|
716
730
|
file: string | undefined;
|
|
717
|
-
footer:
|
|
731
|
+
footer: AddonFunction;
|
|
718
732
|
format: InternalModuleFormat;
|
|
719
733
|
freeze: boolean;
|
|
720
734
|
generatedCode: NormalizedGeneratedCodeOptions;
|
|
@@ -723,16 +737,17 @@ export interface NormalizedOutputOptions {
|
|
|
723
737
|
indent: true | string;
|
|
724
738
|
inlineDynamicImports: boolean;
|
|
725
739
|
interop: GetInterop;
|
|
726
|
-
intro:
|
|
740
|
+
intro: AddonFunction;
|
|
727
741
|
manualChunks: ManualChunksOption;
|
|
728
742
|
minifyInternalExports: boolean;
|
|
729
743
|
name: string | undefined;
|
|
744
|
+
/** @deprecated Use "generatedCode.symbols" instead. */
|
|
730
745
|
namespaceToStringTag: boolean;
|
|
731
746
|
noConflict: boolean;
|
|
732
|
-
outro:
|
|
747
|
+
outro: AddonFunction;
|
|
733
748
|
paths: OptionsPaths;
|
|
734
749
|
plugins: OutputPlugin[];
|
|
735
|
-
/** @deprecated Use
|
|
750
|
+
/** @deprecated Use "generatedCode.constBindings" instead. */
|
|
736
751
|
preferConst: boolean;
|
|
737
752
|
preserveModules: boolean;
|
|
738
753
|
preserveModulesRoot: string | undefined;
|
|
@@ -741,6 +756,7 @@ export interface NormalizedOutputOptions {
|
|
|
741
756
|
sourcemapBaseUrl: string | undefined;
|
|
742
757
|
sourcemapExcludeSources: boolean;
|
|
743
758
|
sourcemapFile: string | undefined;
|
|
759
|
+
sourcemapIgnoreList: SourcemapIgnoreListOption;
|
|
744
760
|
sourcemapPathTransform: SourcemapPathTransformOption | undefined;
|
|
745
761
|
strict: boolean;
|
|
746
762
|
systemNullSetters: boolean;
|
|
@@ -765,8 +781,7 @@ export interface PreRenderedAsset {
|
|
|
765
781
|
|
|
766
782
|
export interface OutputAsset extends PreRenderedAsset {
|
|
767
783
|
fileName: string;
|
|
768
|
-
|
|
769
|
-
isAsset: true;
|
|
784
|
+
needsCodeReference: boolean;
|
|
770
785
|
}
|
|
771
786
|
|
|
772
787
|
export interface RenderedModule {
|
|
@@ -783,15 +798,12 @@ export interface PreRenderedChunk {
|
|
|
783
798
|
isDynamicEntry: boolean;
|
|
784
799
|
isEntry: boolean;
|
|
785
800
|
isImplicitEntry: boolean;
|
|
786
|
-
|
|
787
|
-
[id: string]: RenderedModule;
|
|
788
|
-
};
|
|
801
|
+
moduleIds: string[];
|
|
789
802
|
name: string;
|
|
790
803
|
type: 'chunk';
|
|
791
804
|
}
|
|
792
805
|
|
|
793
806
|
export interface RenderedChunk extends PreRenderedChunk {
|
|
794
|
-
code?: string;
|
|
795
807
|
dynamicImports: string[];
|
|
796
808
|
fileName: string;
|
|
797
809
|
implicitlyLoadedBefore: string[];
|
|
@@ -799,12 +811,15 @@ export interface RenderedChunk extends PreRenderedChunk {
|
|
|
799
811
|
[imported: string]: string[];
|
|
800
812
|
};
|
|
801
813
|
imports: string[];
|
|
802
|
-
|
|
814
|
+
modules: {
|
|
815
|
+
[id: string]: RenderedModule;
|
|
816
|
+
};
|
|
803
817
|
referencedFiles: string[];
|
|
804
818
|
}
|
|
805
819
|
|
|
806
820
|
export interface OutputChunk extends RenderedChunk {
|
|
807
821
|
code: string;
|
|
822
|
+
map: SourceMap | null;
|
|
808
823
|
}
|
|
809
824
|
|
|
810
825
|
export interface SerializablePluginCache {
|
|
@@ -835,7 +850,7 @@ export interface RollupOptions extends InputOptions {
|
|
|
835
850
|
output?: OutputOptions | OutputOptions[];
|
|
836
851
|
}
|
|
837
852
|
|
|
838
|
-
export interface MergedRollupOptions extends
|
|
853
|
+
export interface MergedRollupOptions extends InputOptionsWithPlugins {
|
|
839
854
|
output: OutputOptions[];
|
|
840
855
|
}
|
|
841
856
|
|
|
@@ -880,40 +895,37 @@ export interface RollupWatchOptions extends InputOptions {
|
|
|
880
895
|
watch?: WatcherOptions | false;
|
|
881
896
|
}
|
|
882
897
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
listeners<K extends keyof T>(event: K): Array<T[K]>;
|
|
890
|
-
off<K extends keyof T>(event: K, listener: T[K]): this;
|
|
891
|
-
on<K extends keyof T>(event: K, listener: T[K]): this;
|
|
892
|
-
once<K extends keyof T>(event: K, listener: T[K]): this;
|
|
893
|
-
prependListener<K extends keyof T>(event: K, listener: T[K]): this;
|
|
894
|
-
prependOnceListener<K extends keyof T>(event: K, listener: T[K]): this;
|
|
895
|
-
rawListeners<K extends keyof T>(event: K): Array<T[K]>;
|
|
896
|
-
removeAllListeners<K extends keyof T>(event?: K): this;
|
|
897
|
-
removeListener<K extends keyof T>(event: K, listener: T[K]): this;
|
|
898
|
-
setMaxListeners(n: number): this;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
export interface RollupAwaitingEmitter<T extends { [event: string]: (...args: any) => any }>
|
|
902
|
-
extends TypedEventEmitter<T> {
|
|
898
|
+
export type AwaitedEventListener<
|
|
899
|
+
T extends { [event: string]: (...parameters: any) => any },
|
|
900
|
+
K extends keyof T
|
|
901
|
+
> = (...parameters: Parameters<T[K]>) => void | Promise<void>;
|
|
902
|
+
|
|
903
|
+
export interface AwaitingEventEmitter<T extends { [event: string]: (...parameters: any) => any }> {
|
|
903
904
|
close(): Promise<void>;
|
|
904
|
-
|
|
905
|
+
emit<K extends keyof T>(event: K, ...parameters: Parameters<T[K]>): Promise<unknown>;
|
|
906
|
+
/**
|
|
907
|
+
* Removes an event listener.
|
|
908
|
+
*/
|
|
909
|
+
off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
910
|
+
/**
|
|
911
|
+
* Registers an event listener that will be awaited before Rollup continues.
|
|
912
|
+
* All listeners will be awaited in parallel while rejections are tracked via
|
|
913
|
+
* Promise.all.
|
|
914
|
+
*/
|
|
915
|
+
on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
905
916
|
/**
|
|
906
|
-
* Registers an event listener that will be awaited before Rollup continues
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
* Listeners are removed automatically when
|
|
910
|
-
* happens automatically after each run.
|
|
917
|
+
* Registers an event listener that will be awaited before Rollup continues.
|
|
918
|
+
* All listeners will be awaited in parallel while rejections are tracked via
|
|
919
|
+
* Promise.all.
|
|
920
|
+
* Listeners are removed automatically when removeListenersForCurrentRun is
|
|
921
|
+
* called, which happens automatically after each run.
|
|
911
922
|
*/
|
|
912
|
-
|
|
923
|
+
onCurrentRun<K extends keyof T>(
|
|
913
924
|
event: K,
|
|
914
|
-
listener: (...
|
|
925
|
+
listener: (...parameters: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
|
|
915
926
|
): this;
|
|
916
|
-
|
|
927
|
+
removeAllListeners(): this;
|
|
928
|
+
removeListenersForCurrentRun(): this;
|
|
917
929
|
}
|
|
918
930
|
|
|
919
931
|
export type RollupWatcherEvent =
|
|
@@ -929,7 +941,7 @@ export type RollupWatcherEvent =
|
|
|
929
941
|
| { code: 'END' }
|
|
930
942
|
| { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
|
|
931
943
|
|
|
932
|
-
export type RollupWatcher =
|
|
944
|
+
export type RollupWatcher = AwaitingEventEmitter<{
|
|
933
945
|
change: (id: string, change: { event: ChangeEvent }) => void;
|
|
934
946
|
close: () => void;
|
|
935
947
|
event: (event: RollupWatcherEvent) => void;
|
|
@@ -946,3 +958,8 @@ interface AcornNode {
|
|
|
946
958
|
|
|
947
959
|
export function defineConfig(options: RollupOptions): RollupOptions;
|
|
948
960
|
export function defineConfig(options: RollupOptions[]): RollupOptions[];
|
|
961
|
+
export function defineConfig(optionsFunction: RollupOptionsFunction): RollupOptionsFunction;
|
|
962
|
+
|
|
963
|
+
export type RollupOptionsFunction = (
|
|
964
|
+
commandLineArguments: Record<string, any>
|
|
965
|
+
) => MaybePromise<RollupOptions | RollupOptions[]>;
|