2017-06-09 20:52:06 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2017-06-12 14:13:25 +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,
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
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-06-12 14:13:25 +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-06-12 14:13:25 +00:00
|
|
|
type _Error = {|error: Error|};
|
|
|
|
type _Result = {|code: string, warnings?: Array<string>|};
|
2017-06-09 20:52:06 +00:00
|
|
|
|
2017-06-12 14:13:25 +00:00
|
|
|
declare module 'uglify-es' {
|
2017-06-09 20:52:06 +00:00
|
|
|
declare function minify(
|
2017-06-12 14:13:25 +00:00
|
|
|
code: _Input,
|
|
|
|
options?: _Options,
|
|
|
|
): _Error | _Result;
|
2017-06-09 20:52:06 +00:00
|
|
|
declare function minify(
|
2017-06-12 14:13:25 +00:00
|
|
|
code: _Input,
|
|
|
|
options: {..._Options, sourceMap: _SourceMapOptions},
|
|
|
|
): _Error | {|..._Result, map: string|};
|
2017-06-09 20:52:06 +00:00
|
|
|
}
|