UNPKG

4.35 kBTypeScriptView Raw
1/// <reference lib="es2015" />
2
3import { RawSourceMap } from 'source-map';
4
5export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
6
7export interface ParseOptions {
8 bare_returns?: boolean;
9 ecma?: ECMA;
10 html5_comments?: boolean;
11 shebang?: boolean;
12}
13
14export 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
71export enum InlineFunctions {
72 Disabled = 0,
73 SimpleFunctions = 1,
74 WithArguments = 2,
75 WithArgumentsAndVariables = 3
76}
77
78export 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
89export interface ManglePropertiesOptions {
90 builtins?: boolean;
91 debug?: boolean;
92 keep_quoted?: boolean | 'strict';
93 regex?: RegExp | string;
94 reserved?: string[];
95}
96
97export interface FormatOptions {
98 ascii_only?: boolean;
99 beautify?: boolean;
100 braces?: boolean;
101 comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
102 value: string,
103 type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
104 pos: number,
105 line: number,
106 col: number,
107 }) => boolean );
108 ecma?: ECMA;
109 ie8?: boolean;
110 indent_level?: number;
111 indent_start?: number;
112 inline_script?: boolean;
113 keep_quoted_props?: boolean;
114 max_line_len?: number | false;
115 preamble?: string;
116 preserve_annotations?: boolean;
117 quote_keys?: boolean;
118 quote_style?: OutputQuoteStyle;
119 safari10?: boolean;
120 semicolons?: boolean;
121 shebang?: boolean;
122 shorthand?: boolean;
123 source_map?: SourceMapOptions;
124 webkit?: boolean;
125 width?: number;
126 wrap_iife?: boolean;
127 wrap_func_args?: boolean;
128}
129
130export enum OutputQuoteStyle {
131 PreferDouble = 0,
132 AlwaysSingle = 1,
133 AlwaysDouble = 2,
134 AlwaysOriginal = 3
135}
136
137export interface MinifyOptions {
138 compress?: boolean | CompressOptions;
139 ecma?: ECMA;
140 ie8?: boolean;
141 keep_classnames?: boolean | RegExp;
142 keep_fnames?: boolean | RegExp;
143 mangle?: boolean | MangleOptions;
144 module?: boolean;
145 nameCache?: object;
146 format?: FormatOptions;
147 /** @deprecated */
148 output?: FormatOptions;
149 parse?: ParseOptions;
150 safari10?: boolean;
151 sourceMap?: boolean | SourceMapOptions;
152 toplevel?: boolean;
153}
154
155export interface MinifyOutput {
156 code?: string;
157 map?: RawSourceMap | string;
158}
159
160export interface SourceMapOptions {
161 /** Source map object, 'inline' or source map file content */
162 content?: RawSourceMap | string;
163 includeSources?: boolean;
164 filename?: string;
165 root?: string;
166 url?: string | 'inline';
167}
168
169export function minify(files: string | string[] | { [file: string]: string }, options?: MinifyOptions): Promise<MinifyOutput>;