1 | import { BuildOptions, Metafile, Plugin as Plugin$1, Loader } from 'esbuild';
|
2 | import { SourceMap as SourceMap$1, TreeshakingOptions, TreeshakingPreset, InputOption } from 'rollup';
|
3 | import { RawSourceMap } from 'source-map';
|
4 |
|
5 | declare type GeneratedColumn = number;
|
6 | declare type SourcesIndex = number;
|
7 | declare type SourceLine = number;
|
8 | declare type SourceColumn = number;
|
9 | declare type NamesIndex = number;
|
10 | declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
11 |
|
12 | declare class TraceMap implements SourceMap {
|
13 | version: SourceMapV3['version'];
|
14 | file: SourceMapV3['file'];
|
15 | names: SourceMapV3['names'];
|
16 | sourceRoot: SourceMapV3['sourceRoot'];
|
17 | sources: SourceMapV3['sources'];
|
18 | sourcesContent: SourceMapV3['sourcesContent'];
|
19 | resolvedSources: string[];
|
20 | private _encoded;
|
21 | private _decoded;
|
22 | private _decodedMemo;
|
23 | private _bySources;
|
24 | private _bySourceMemos;
|
25 | constructor(map: SourceMapInput, mapUrl?: string | null);
|
26 | }
|
27 |
|
28 | interface SourceMapV3 {
|
29 | file?: string | null;
|
30 | names: string[];
|
31 | sourceRoot?: string;
|
32 | sources: (string | null)[];
|
33 | sourcesContent?: (string | null)[];
|
34 | version: 3;
|
35 | }
|
36 | interface EncodedSourceMap extends SourceMapV3 {
|
37 | mappings: string;
|
38 | }
|
39 | interface DecodedSourceMap extends SourceMapV3 {
|
40 | mappings: SourceMapSegment[][];
|
41 | }
|
42 | interface Section {
|
43 | offset: {
|
44 | line: number;
|
45 | column: number;
|
46 | };
|
47 | map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap;
|
48 | }
|
49 | interface SectionedSourceMap {
|
50 | file?: string | null;
|
51 | sections: Section[];
|
52 | version: 3;
|
53 | }
|
54 | declare type SourceMapInput = string | Ro<EncodedSourceMap> | Ro<DecodedSourceMap> | TraceMap;
|
55 | declare type SectionedSourceMapInput = SourceMapInput | Ro<SectionedSourceMap>;
|
56 | declare abstract class SourceMap {
|
57 | version: SourceMapV3['version'];
|
58 | file: SourceMapV3['file'];
|
59 | names: SourceMapV3['names'];
|
60 | sourceRoot: SourceMapV3['sourceRoot'];
|
61 | sources: SourceMapV3['sources'];
|
62 | sourcesContent: SourceMapV3['sourcesContent'];
|
63 | resolvedSources: SourceMapV3['sources'];
|
64 | }
|
65 | declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
|
66 | declare type RoArray<T> = Ro<T>[];
|
67 | declare type RoObject<T> = {
|
68 | [K in keyof T]: T[K] | Ro<T[K]>;
|
69 | };
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
|
76 |
|
77 | interface ParseOptions {
|
78 | bare_returns?: boolean;
|
79 |
|
80 | ecma?: ECMA;
|
81 | html5_comments?: boolean;
|
82 | shebang?: boolean;
|
83 | }
|
84 |
|
85 | interface CompressOptions {
|
86 | arguments?: boolean;
|
87 | arrows?: boolean;
|
88 | booleans_as_integers?: boolean;
|
89 | booleans?: boolean;
|
90 | collapse_vars?: boolean;
|
91 | comparisons?: boolean;
|
92 | computed_props?: boolean;
|
93 | conditionals?: boolean;
|
94 | dead_code?: boolean;
|
95 | defaults?: boolean;
|
96 | directives?: boolean;
|
97 | drop_console?: boolean;
|
98 | drop_debugger?: boolean;
|
99 | ecma?: ECMA;
|
100 | evaluate?: boolean;
|
101 | expression?: boolean;
|
102 | global_defs?: object;
|
103 | hoist_funs?: boolean;
|
104 | hoist_props?: boolean;
|
105 | hoist_vars?: boolean;
|
106 | ie8?: boolean;
|
107 | if_return?: boolean;
|
108 | inline?: boolean | InlineFunctions;
|
109 | join_vars?: boolean;
|
110 | keep_classnames?: boolean | RegExp;
|
111 | keep_fargs?: boolean;
|
112 | keep_fnames?: boolean | RegExp;
|
113 | keep_infinity?: boolean;
|
114 | loops?: boolean;
|
115 | module?: boolean;
|
116 | negate_iife?: boolean;
|
117 | passes?: number;
|
118 | properties?: boolean;
|
119 | pure_funcs?: string[];
|
120 | pure_getters?: boolean | 'strict';
|
121 | reduce_funcs?: boolean;
|
122 | reduce_vars?: boolean;
|
123 | sequences?: boolean | number;
|
124 | side_effects?: boolean;
|
125 | switches?: boolean;
|
126 | toplevel?: boolean;
|
127 | top_retain?: null | string | string[] | RegExp;
|
128 | typeofs?: boolean;
|
129 | unsafe_arrows?: boolean;
|
130 | unsafe?: boolean;
|
131 | unsafe_comps?: boolean;
|
132 | unsafe_Function?: boolean;
|
133 | unsafe_math?: boolean;
|
134 | unsafe_symbols?: boolean;
|
135 | unsafe_methods?: boolean;
|
136 | unsafe_proto?: boolean;
|
137 | unsafe_regexp?: boolean;
|
138 | unsafe_undefined?: boolean;
|
139 | unused?: boolean;
|
140 | }
|
141 |
|
142 | declare enum InlineFunctions {
|
143 | Disabled = 0,
|
144 | SimpleFunctions = 1,
|
145 | WithArguments = 2,
|
146 | WithArgumentsAndVariables = 3
|
147 | }
|
148 |
|
149 | interface MangleOptions {
|
150 | eval?: boolean;
|
151 | keep_classnames?: boolean | RegExp;
|
152 | keep_fnames?: boolean | RegExp;
|
153 | module?: boolean;
|
154 | nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler;
|
155 | properties?: boolean | ManglePropertiesOptions;
|
156 | reserved?: string[];
|
157 | safari10?: boolean;
|
158 | toplevel?: boolean;
|
159 | }
|
160 |
|
161 | /**
|
162 | * An identifier mangler for which the output is invariant with respect to the source code.
|
163 | */
|
164 | interface SimpleIdentifierMangler {
|
165 | |
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 | get(n: number): string;
|
172 | }
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | consider(chars: string, delta: number): number;
|
185 | |
186 |
|
187 |
|
188 | reset(): void;
|
189 | |
190 |
|
191 |
|
192 | sort(): void;
|
193 | }
|
194 |
|
195 | interface ManglePropertiesOptions {
|
196 | builtins?: boolean;
|
197 | debug?: boolean;
|
198 | keep_quoted?: boolean | 'strict';
|
199 | nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler;
|
200 | regex?: RegExp | string;
|
201 | reserved?: string[];
|
202 | }
|
203 |
|
204 | interface FormatOptions {
|
205 | ascii_only?: boolean;
|
206 |
|
207 | beautify?: boolean;
|
208 | braces?: boolean;
|
209 | comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
|
210 | value: string,
|
211 | type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
|
212 | pos: number,
|
213 | line: number,
|
214 | col: number,
|
215 | }) => boolean );
|
216 | ecma?: ECMA;
|
217 | ie8?: boolean;
|
218 | keep_numbers?: boolean;
|
219 | indent_level?: number;
|
220 | indent_start?: number;
|
221 | inline_script?: boolean;
|
222 | keep_quoted_props?: boolean;
|
223 | max_line_len?: number | false;
|
224 | preamble?: string;
|
225 | preserve_annotations?: boolean;
|
226 | quote_keys?: boolean;
|
227 | quote_style?: OutputQuoteStyle;
|
228 | safari10?: boolean;
|
229 | semicolons?: boolean;
|
230 | shebang?: boolean;
|
231 | shorthand?: boolean;
|
232 | source_map?: SourceMapOptions;
|
233 | webkit?: boolean;
|
234 | width?: number;
|
235 | wrap_iife?: boolean;
|
236 | wrap_func_args?: boolean;
|
237 | }
|
238 |
|
239 | declare enum OutputQuoteStyle {
|
240 | PreferDouble = 0,
|
241 | AlwaysSingle = 1,
|
242 | AlwaysDouble = 2,
|
243 | AlwaysOriginal = 3
|
244 | }
|
245 |
|
246 | interface MinifyOptions {
|
247 | compress?: boolean | CompressOptions;
|
248 | ecma?: ECMA;
|
249 | enclose?: boolean | string;
|
250 | ie8?: boolean;
|
251 | keep_classnames?: boolean | RegExp;
|
252 | keep_fnames?: boolean | RegExp;
|
253 | mangle?: boolean | MangleOptions;
|
254 | module?: boolean;
|
255 | nameCache?: object;
|
256 | format?: FormatOptions;
|
257 | /** @deprecated */
|
258 | output?: FormatOptions;
|
259 | parse?: ParseOptions;
|
260 | safari10?: boolean;
|
261 | sourceMap?: boolean | SourceMapOptions;
|
262 | toplevel?: boolean;
|
263 | }
|
264 |
|
265 | interface SourceMapOptions {
|
266 |
|
267 | content?: SectionedSourceMapInput | string;
|
268 | includeSources?: boolean;
|
269 | filename?: string;
|
270 | root?: string;
|
271 | url?: string | 'inline';
|
272 | }
|
273 |
|
274 |
|
275 | declare type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
|
276 |
|
277 | type Logger = ReturnType<typeof createLogger>;
|
278 | declare const createLogger: (name?: string) => {
|
279 | setName(_name: string): void;
|
280 | success(label: string, ...args: any[]): void;
|
281 | info(label: string, ...args: any[]): void;
|
282 | error(label: string, ...args: any[]): void;
|
283 | warn(label: string, ...args: any[]): void;
|
284 | log(label: string, type: 'info' | 'success' | 'error' | 'warn', ...data: unknown[]): void;
|
285 | };
|
286 |
|
287 | type ChunkInfo = {
|
288 | type: 'chunk';
|
289 | code: string;
|
290 | map?: string | RawSourceMap | null;
|
291 | path: string;
|
292 | |
293 |
|
294 |
|
295 | mode?: number;
|
296 | entryPoint?: string;
|
297 | exports?: string[];
|
298 | imports?: Metafile['outputs'][string]['imports'];
|
299 | };
|
300 | type RenderChunk = (this: PluginContext, code: string, chunkInfo: ChunkInfo) => MaybePromise<{
|
301 | code: string;
|
302 | map?: object | string | SourceMap$1 | null;
|
303 | } | undefined | null | void>;
|
304 | type BuildStart = (this: PluginContext) => MaybePromise<void>;
|
305 | type BuildEnd = (this: PluginContext, ctx: {
|
306 | writtenFiles: WrittenFile[];
|
307 | }) => MaybePromise<void>;
|
308 | type ModifyEsbuildOptions = (this: PluginContext, options: BuildOptions) => void;
|
309 | type Plugin = {
|
310 | name: string;
|
311 | esbuildOptions?: ModifyEsbuildOptions;
|
312 | buildStart?: BuildStart;
|
313 | renderChunk?: RenderChunk;
|
314 | buildEnd?: BuildEnd;
|
315 | };
|
316 | type PluginContext = {
|
317 | format: Format;
|
318 | splitting?: boolean;
|
319 | options: NormalizedOptions;
|
320 | logger: Logger;
|
321 | };
|
322 | type WrittenFile = {
|
323 | readonly name: string;
|
324 | readonly size: number;
|
325 | };
|
326 |
|
327 | type TreeshakingStrategy = boolean | TreeshakingOptions | TreeshakingPreset;
|
328 |
|
329 | type KILL_SIGNAL = 'SIGKILL' | 'SIGTERM';
|
330 | type Format = 'cjs' | 'esm' | 'iife';
|
331 | type ContextForOutPathGeneration = {
|
332 | options: NormalizedOptions;
|
333 | format: Format;
|
334 |
|
335 | pkgType?: string;
|
336 | };
|
337 | type OutExtensionObject = {
|
338 | js?: string;
|
339 | dts?: string;
|
340 | };
|
341 | type OutExtensionFactory = (ctx: ContextForOutPathGeneration) => OutExtensionObject;
|
342 | type DtsConfig = {
|
343 | entry?: InputOption;
|
344 |
|
345 | resolve?: boolean | (string | RegExp)[];
|
346 |
|
347 | only?: boolean;
|
348 |
|
349 | banner?: string;
|
350 |
|
351 | footer?: string;
|
352 | |
353 |
|
354 |
|
355 |
|
356 | compilerOptions?: any;
|
357 | };
|
358 | type ExperimentalDtsConfig = {
|
359 | entry?: InputOption;
|
360 | |
361 |
|
362 |
|
363 |
|
364 | compilerOptions?: any;
|
365 | };
|
366 | type BannerOrFooter = {
|
367 | js?: string;
|
368 | css?: string;
|
369 | } | ((ctx: {
|
370 | format: Format;
|
371 | }) => {
|
372 | js?: string;
|
373 | css?: string;
|
374 | } | undefined);
|
375 | type BrowserTarget = 'chrome' | 'deno' | 'edge' | 'firefox' | 'hermes' | 'ie' | 'ios' | 'node' | 'opera' | 'rhino' | 'safari';
|
376 | type BrowserTargetWithVersion = `${BrowserTarget}${number}` | `${BrowserTarget}${number}.${number}` | `${BrowserTarget}${number}.${number}.${number}`;
|
377 | type EsTarget = 'es3' | 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
|
378 | type Target = BrowserTarget | BrowserTargetWithVersion | EsTarget;
|
379 | type Entry = string[] | Record<string, string>;
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | type Options = {
|
385 |
|
386 | name?: string;
|
387 | |
388 |
|
389 |
|
390 | entryPoints?: Entry;
|
391 | entry?: Entry;
|
392 | |
393 |
|
394 |
|
395 | legacyOutput?: boolean;
|
396 | |
397 |
|
398 |
|
399 |
|
400 |
|
401 | target?: Target | Target[];
|
402 | minify?: boolean | 'terser';
|
403 | terserOptions?: MinifyOptions;
|
404 | minifyWhitespace?: boolean;
|
405 | minifyIdentifiers?: boolean;
|
406 | minifySyntax?: boolean;
|
407 | keepNames?: boolean;
|
408 | watch?: boolean | string | (string | boolean)[];
|
409 | ignoreWatch?: string[] | string;
|
410 | onSuccess?: string | (() => Promise<void | undefined | (() => void | Promise<void>)>);
|
411 | jsxFactory?: string;
|
412 | jsxFragment?: string;
|
413 | outDir?: string;
|
414 | outExtension?: OutExtensionFactory;
|
415 | format?: Format[] | Format;
|
416 | globalName?: string;
|
417 | env?: {
|
418 | [k: string]: string;
|
419 | };
|
420 | define?: {
|
421 | [k: string]: string;
|
422 | };
|
423 | dts?: boolean | string | DtsConfig;
|
424 | experimentalDts?: boolean | string | ExperimentalDtsConfig;
|
425 | sourcemap?: boolean | 'inline';
|
426 | /** Always bundle modules matching given patterns */
|
427 | noExternal?: (string | RegExp)[];
|
428 | /** Don't bundle these modules */
|
429 | external?: (string | RegExp)[];
|
430 | /**
|
431 | * Replace `process.env.NODE_ENV` with `production` or `development`
|
432 | * `production` when the bundled is minified, `development` otherwise
|
433 | */
|
434 | replaceNodeEnv?: boolean;
|
435 | /**
|
436 | * Code splitting
|
437 | * Default to `true` for ESM, `false` for CJS.
|
438 | *
|
439 | * You can set it to `true` explicitly, and may want to disable code splitting sometimes: [`#255`](https:
|
440 | */
|
441 | splitting?: boolean;
|
442 | |
443 |
|
444 |
|
445 | clean?: boolean | string[];
|
446 | esbuildPlugins?: Plugin$1[];
|
447 | esbuildOptions?: (options: BuildOptions, context: {
|
448 | format: Format;
|
449 | }) => void;
|
450 | |
451 |
|
452 |
|
453 | silent?: boolean;
|
454 | |
455 |
|
456 |
|
457 |
|
458 | skipNodeModulesBundle?: boolean;
|
459 | |
460 |
|
461 |
|
462 | pure?: string | string[];
|
463 | |
464 |
|
465 |
|
466 | bundle?: boolean;
|
467 | |
468 |
|
469 |
|
470 |
|
471 | inject?: string[];
|
472 | |
473 |
|
474 |
|
475 |
|
476 | metafile?: boolean;
|
477 | footer?: BannerOrFooter;
|
478 | banner?: BannerOrFooter;
|
479 | |
480 |
|
481 |
|
482 |
|
483 | platform?: 'node' | 'browser' | 'neutral';
|
484 | |
485 |
|
486 |
|
487 | loader?: Record<string, Loader>;
|
488 | |
489 |
|
490 |
|
491 |
|
492 | config?: boolean | string;
|
493 | |
494 |
|
495 |
|
496 | tsconfig?: string;
|
497 | |
498 |
|
499 |
|
500 |
|
501 | injectStyle?: boolean | ((css: string, fileId: string) => string);
|
502 | |
503 |
|
504 |
|
505 |
|
506 | shims?: boolean;
|
507 | |
508 |
|
509 |
|
510 |
|
511 |
|
512 | plugins?: Plugin[];
|
513 | |
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 | treeshake?: TreeshakingStrategy;
|
521 | |
522 |
|
523 |
|
524 | publicDir?: string | boolean;
|
525 | killSignal?: KILL_SIGNAL;
|
526 | |
527 |
|
528 |
|
529 |
|
530 | cjsInterop?: boolean;
|
531 | };
|
532 | interface NormalizedExperimentalDtsConfig {
|
533 | entry: {
|
534 | [entryAlias: string]: string;
|
535 | };
|
536 | compilerOptions?: any;
|
537 | }
|
538 | type NormalizedOptions = Omit<MarkRequired<Options, 'entry' | 'outDir'>, 'dts' | 'experimentalDts' | 'format'> & {
|
539 | dts?: DtsConfig;
|
540 | experimentalDts?: NormalizedExperimentalDtsConfig;
|
541 | tsconfigResolvePaths: Record<string, string[]>;
|
542 | tsconfigDecoratorMetadata?: boolean;
|
543 | format: Format[];
|
544 | };
|
545 |
|
546 | type MaybePromise<T> = T | Promise<T>;
|
547 |
|
548 | declare const defineConfig: (options: Options | Options[] | ((overrideOptions: Options) => MaybePromise<Options | Options[]>)) => Options | Options[] | ((overrideOptions: Options) => MaybePromise<Options | Options[]>);
|
549 | declare function build(_options: Options): Promise<void>;
|
550 |
|
551 | export { Format, NormalizedOptions, Options, build, defineConfig };
|
552 |
|
\ | No newline at end of file |