--module option, enables strict mode and toplevel options
This commit is contained in:
parent
569757d14d
commit
041482fd44
|
|
@ -110,6 +110,7 @@ a double dash to prevent input files being used as option arguments:
|
|||
--keep-classnames Do not mangle/drop class names.
|
||||
--keep-fnames Do not mangle/drop function names. Useful for
|
||||
code relying on Function.prototype.name.
|
||||
--module Input is an ES6 module
|
||||
--name-cache <file> File to hold mangled name mappings.
|
||||
--safari10 Support non-standard Safari 10/11.
|
||||
Equivalent to setting `safari10: true` in `minify()`
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ program.option("--ecma <version>", "Specify ECMAScript release: 5, 6, 7 or 8.");
|
|||
program.option("--ie8", "Support non-standard Internet Explorer 8.");
|
||||
program.option("--keep-classnames", "Do not mangle/drop class names.");
|
||||
program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
|
||||
program.option("--module", "Input is an ES6 module");
|
||||
program.option("--name-cache <file>", "File to hold mangled name mappings.");
|
||||
program.option("--rename", "Force symbol expansion.");
|
||||
program.option("--no-rename", "Disable symbol expansion.");
|
||||
|
|
@ -66,6 +67,7 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
|||
"compress",
|
||||
"ie8",
|
||||
"mangle",
|
||||
"module",
|
||||
"safari10",
|
||||
"sourceMap",
|
||||
"toplevel",
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ function Compressor(options, false_by_default) {
|
|||
keep_fnames : false,
|
||||
keep_infinity : false,
|
||||
loops : !false_by_default,
|
||||
module : false,
|
||||
negate_iife : !false_by_default,
|
||||
passes : 1,
|
||||
properties : !false_by_default,
|
||||
|
|
@ -138,6 +139,9 @@ function Compressor(options, false_by_default) {
|
|||
funcs: toplevel,
|
||||
vars: toplevel
|
||||
};
|
||||
if (this.options['module']) {
|
||||
this.directives['use strict'] = true;
|
||||
}
|
||||
var sequences = this.options["sequences"];
|
||||
this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
|
||||
this.warnings_produced = {};
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ function minify(files, options) {
|
|||
keep_classnames: undefined,
|
||||
keep_fnames: false,
|
||||
mangle: {},
|
||||
module: false,
|
||||
nameCache: null,
|
||||
output: {},
|
||||
parse: {},
|
||||
|
|
@ -76,6 +77,7 @@ function minify(files, options) {
|
|||
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
|
||||
set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
|
||||
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
||||
set_shorthand("module", options, [ "compress" ]);
|
||||
set_shorthand("safari10", options, [ "mangle", "output" ]);
|
||||
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
||||
set_shorthand("warnings", options, [ "compress" ]);
|
||||
|
|
|
|||
|
|
@ -1601,3 +1601,19 @@ issue_2874_3: {
|
|||
]
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
module_enables_strict_mode: {
|
||||
options = {
|
||||
module: true,
|
||||
}
|
||||
input: {
|
||||
if (1) {
|
||||
function xyz() {}
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
if (1) {
|
||||
function xyz() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user