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