2017-06-09 20:52:06 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-10-31 10:44:59 +00:00
|
|
|
*
|
|
|
|
* @format
|
2017-06-09 20:52:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2017-09-19 19:15:31 +00:00
|
|
|
type _Input =
|
|
|
|
| string // code or file name
|
|
|
|
| Array<string> // array of file names
|
|
|
|
| {[filename: string]: string}; // file names and corresponding code
|
|
|
|
|
|
|
|
type _Options = {
|
|
|
|
// https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options
|
|
|
|
compress?: false | Object,
|
|
|
|
ie8?: boolean,
|
2017-10-31 10:44:59 +00:00
|
|
|
mangle?:
|
|
|
|
| boolean
|
|
|
|
| {
|
|
|
|
eval?: boolean,
|
|
|
|
keep_fnames?: boolean,
|
|
|
|
properties?:
|
|
|
|
| boolean
|
|
|
|
| {
|
|
|
|
builtins?: boolean,
|
|
|
|
debug?: boolean,
|
|
|
|
keep_quoted?: boolean,
|
|
|
|
regex?: RegExp,
|
|
|
|
reserved?: Array<string>,
|
|
|
|
},
|
|
|
|
reserved?: Array<string>,
|
|
|
|
safari10?: boolean,
|
|
|
|
toplevel?: boolean,
|
|
|
|
},
|
2017-09-19 19:15:31 +00:00
|
|
|
output?: {
|
|
|
|
ascii_only?: boolean,
|
|
|
|
beautify?: boolean,
|
|
|
|
bracketize?: boolean,
|
|
|
|
comments?: boolean | 'all' | 'some' | RegExp | Function,
|
|
|
|
ecma?: 5 | 6,
|
|
|
|
indent_level?: number,
|
|
|
|
indent_start?: number,
|
|
|
|
inline_script?: number,
|
|
|
|
keep_quoted_props?: boolean,
|
|
|
|
max_line_len?: false | number,
|
|
|
|
preamble?: string,
|
|
|
|
preserve_line?: boolean,
|
|
|
|
quote_keys?: boolean,
|
|
|
|
quote_style?: 0 | 1 | 2 | 3,
|
|
|
|
semicolons?: boolean,
|
|
|
|
shebang?: boolean,
|
|
|
|
width?: number,
|
|
|
|
wrap_iife?: boolean,
|
|
|
|
},
|
|
|
|
parse?: {
|
|
|
|
bare_returns: boolean,
|
|
|
|
html5_comments: boolean,
|
|
|
|
shebang: boolean,
|
|
|
|
},
|
|
|
|
sourceMap?: false,
|
|
|
|
toplevel?: boolean,
|
|
|
|
warnings?: boolean | 'verbose',
|
|
|
|
};
|
|
|
|
|
2017-06-09 20:52:06 +00:00
|
|
|
type _SourceMap = {
|
|
|
|
file?: string,
|
|
|
|
mappings: string,
|
|
|
|
names: Array<string>,
|
|
|
|
sourceRoot?: string,
|
|
|
|
sources: Array<string>,
|
|
|
|
sourcesContent?: Array<?string>,
|
|
|
|
version: number,
|
|
|
|
};
|
|
|
|
|
2017-10-31 10:44:59 +00:00
|
|
|
type _SourceMapOptions =
|
|
|
|
| true
|
|
|
|
| {
|
|
|
|
filename?: string,
|
|
|
|
content?: ?string | _SourceMap,
|
|
|
|
includeSources?: boolean,
|
|
|
|
root?: string,
|
|
|
|
url?: string,
|
|
|
|
};
|
2017-06-09 20:52:06 +00:00
|
|
|
|
2017-09-19 19:15:31 +00:00
|
|
|
type _Error = {|error: Error|};
|
|
|
|
type _Result = {|code: string, warnings?: Array<string>|};
|
2017-06-09 20:52:06 +00:00
|
|
|
|
2017-09-19 19:15:31 +00:00
|
|
|
declare module 'uglify-es' {
|
2017-10-31 10:44:59 +00:00
|
|
|
declare function minify(code: _Input, options?: _Options): _Error | _Result;
|
2017-06-09 20:52:06 +00:00
|
|
|
declare function minify(
|
2017-09-19 19:15:31 +00:00
|
|
|
code: _Input,
|
|
|
|
options: {..._Options, sourceMap: _SourceMapOptions},
|
|
|
|
): _Error | {|..._Result, map: string|};
|
2017-06-09 20:52:06 +00:00
|
|
|
}
|