1 | /// <reference lib="es2015" />
|
---|
2 |
|
---|
3 | import { RawSourceMap } from 'source-map';
|
---|
4 |
|
---|
5 | export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
|
---|
6 |
|
---|
7 | export interface ParseOptions {
|
---|
8 | bare_returns?: boolean;
|
---|
9 | ecma?: ECMA;
|
---|
10 | html5_comments?: boolean;
|
---|
11 | shebang?: boolean;
|
---|
12 | }
|
---|
13 |
|
---|
14 | export interface CompressOptions {
|
---|
15 | arguments?: boolean;
|
---|
16 | arrows?: boolean;
|
---|
17 | booleans_as_integers?: boolean;
|
---|
18 | booleans?: boolean;
|
---|
19 | collapse_vars?: boolean;
|
---|
20 | comparisons?: boolean;
|
---|
21 | computed_props?: boolean;
|
---|
22 | conditionals?: boolean;
|
---|
23 | dead_code?: boolean;
|
---|
24 | defaults?: boolean;
|
---|
25 | directives?: boolean;
|
---|
26 | drop_console?: boolean;
|
---|
27 | drop_debugger?: boolean;
|
---|
28 | ecma?: ECMA;
|
---|
29 | evaluate?: boolean;
|
---|
30 | expression?: boolean;
|
---|
31 | global_defs?: object;
|
---|
32 | hoist_funs?: boolean;
|
---|
33 | hoist_props?: boolean;
|
---|
34 | hoist_vars?: boolean;
|
---|
35 | ie8?: boolean;
|
---|
36 | if_return?: boolean;
|
---|
37 | inline?: boolean | InlineFunctions;
|
---|
38 | join_vars?: boolean;
|
---|
39 | keep_classnames?: boolean | RegExp;
|
---|
40 | keep_fargs?: boolean;
|
---|
41 | keep_fnames?: boolean | RegExp;
|
---|
42 | keep_infinity?: boolean;
|
---|
43 | loops?: boolean;
|
---|
44 | module?: boolean;
|
---|
45 | negate_iife?: boolean;
|
---|
46 | passes?: number;
|
---|
47 | properties?: boolean;
|
---|
48 | pure_funcs?: string[];
|
---|
49 | pure_getters?: boolean | 'strict';
|
---|
50 | reduce_funcs?: boolean;
|
---|
51 | reduce_vars?: boolean;
|
---|
52 | sequences?: boolean | number;
|
---|
53 | side_effects?: boolean;
|
---|
54 | switches?: boolean;
|
---|
55 | toplevel?: boolean;
|
---|
56 | top_retain?: null | string | string[] | RegExp;
|
---|
57 | typeofs?: boolean;
|
---|
58 | unsafe_arrows?: boolean;
|
---|
59 | unsafe?: boolean;
|
---|
60 | unsafe_comps?: boolean;
|
---|
61 | unsafe_Function?: boolean;
|
---|
62 | unsafe_math?: boolean;
|
---|
63 | unsafe_symbols?: boolean;
|
---|
64 | unsafe_methods?: boolean;
|
---|
65 | unsafe_proto?: boolean;
|
---|
66 | unsafe_regexp?: boolean;
|
---|
67 | unsafe_undefined?: boolean;
|
---|
68 | unused?: boolean;
|
---|
69 | }
|
---|
70 |
|
---|
71 | export enum InlineFunctions {
|
---|
72 | Disabled = 0,
|
---|
73 | SimpleFunctions = 1,
|
---|
74 | WithArguments = 2,
|
---|
75 | WithArgumentsAndVariables = 3
|
---|
76 | }
|
---|
77 |
|
---|
78 | export interface MangleOptions {
|
---|
79 | eval?: boolean;
|
---|
80 | keep_classnames?: boolean | RegExp;
|
---|
81 | keep_fnames?: boolean | RegExp;
|
---|
82 | module?: boolean;
|
---|
83 | properties?: boolean | ManglePropertiesOptions;
|
---|
84 | reserved?: string[];
|
---|
85 | safari10?: boolean;
|
---|
86 | toplevel?: boolean;
|
---|
87 | }
|
---|
88 |
|
---|
89 | export interface ManglePropertiesOptions {
|
---|
90 | builtins?: boolean;
|
---|
91 | debug?: boolean;
|
---|
92 | keep_quoted?: boolean | 'strict';
|
---|
93 | regex?: RegExp | string;
|
---|
94 | reserved?: string[];
|
---|
95 | }
|
---|
96 |
|
---|
97 | export interface FormatOptions {
|
---|
98 | ascii_only?: boolean;
|
---|
99 | /** @deprecated Not implemented anymore */
|
---|
100 | beautify?: boolean;
|
---|
101 | braces?: boolean;
|
---|
102 | comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
|
---|
103 | value: string,
|
---|
104 | type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
|
---|
105 | pos: number,
|
---|
106 | line: number,
|
---|
107 | col: number,
|
---|
108 | }) => boolean );
|
---|
109 | ecma?: ECMA;
|
---|
110 | ie8?: boolean;
|
---|
111 | indent_level?: number;
|
---|
112 | indent_start?: number;
|
---|
113 | inline_script?: boolean;
|
---|
114 | keep_quoted_props?: boolean;
|
---|
115 | max_line_len?: number | false;
|
---|
116 | preamble?: string;
|
---|
117 | preserve_annotations?: boolean;
|
---|
118 | quote_keys?: boolean;
|
---|
119 | quote_style?: OutputQuoteStyle;
|
---|
120 | safari10?: boolean;
|
---|
121 | semicolons?: boolean;
|
---|
122 | shebang?: boolean;
|
---|
123 | shorthand?: boolean;
|
---|
124 | source_map?: SourceMapOptions;
|
---|
125 | webkit?: boolean;
|
---|
126 | width?: number;
|
---|
127 | wrap_iife?: boolean;
|
---|
128 | wrap_func_args?: boolean;
|
---|
129 | }
|
---|
130 |
|
---|
131 | export enum OutputQuoteStyle {
|
---|
132 | PreferDouble = 0,
|
---|
133 | AlwaysSingle = 1,
|
---|
134 | AlwaysDouble = 2,
|
---|
135 | AlwaysOriginal = 3
|
---|
136 | }
|
---|
137 |
|
---|
138 | export interface MinifyOptions {
|
---|
139 | compress?: boolean | CompressOptions;
|
---|
140 | ecma?: ECMA;
|
---|
141 | ie8?: boolean;
|
---|
142 | keep_classnames?: boolean | RegExp;
|
---|
143 | keep_fnames?: boolean | RegExp;
|
---|
144 | mangle?: boolean | MangleOptions;
|
---|
145 | module?: boolean;
|
---|
146 | nameCache?: object;
|
---|
147 | format?: FormatOptions;
|
---|
148 | /** @deprecated */
|
---|
149 | output?: FormatOptions;
|
---|
150 | parse?: ParseOptions;
|
---|
151 | safari10?: boolean;
|
---|
152 | sourceMap?: boolean | SourceMapOptions;
|
---|
153 | toplevel?: boolean;
|
---|
154 | }
|
---|
155 |
|
---|
156 | export interface MinifyOutput {
|
---|
157 | code?: string;
|
---|
158 | map?: RawSourceMap | string;
|
---|
159 | }
|
---|
160 |
|
---|
161 | export interface SourceMapOptions {
|
---|
162 | /** Source map object, 'inline' or source map file content */
|
---|
163 | content?: RawSourceMap | string;
|
---|
164 | includeSources?: boolean;
|
---|
165 | filename?: string;
|
---|
166 | root?: string;
|
---|
167 | url?: string | 'inline';
|
---|
168 | }
|
---|
169 |
|
---|
170 | export function minify(files: string | string[] | { [file: string]: string }, options?: MinifyOptions): Promise<MinifyOutput>;
|
---|