--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-classnames Do not mangle/drop class names.
|
||||||
--keep-fnames Do not mangle/drop function names. Useful for
|
--keep-fnames Do not mangle/drop function names. Useful for
|
||||||
code relying on Function.prototype.name.
|
code relying on Function.prototype.name.
|
||||||
|
--module Input is an ES6 module
|
||||||
--name-cache <file> File to hold mangled name mappings.
|
--name-cache <file> File to hold mangled name mappings.
|
||||||
--safari10 Support non-standard Safari 10/11.
|
--safari10 Support non-standard Safari 10/11.
|
||||||
Equivalent to setting `safari10: true` in `minify()`
|
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("--ie8", "Support non-standard Internet Explorer 8.");
|
||||||
program.option("--keep-classnames", "Do not mangle/drop class names.");
|
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("--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("--name-cache <file>", "File to hold mangled name mappings.");
|
||||||
program.option("--rename", "Force symbol expansion.");
|
program.option("--rename", "Force symbol expansion.");
|
||||||
program.option("--no-rename", "Disable symbol expansion.");
|
program.option("--no-rename", "Disable symbol expansion.");
|
||||||
|
|
@ -66,6 +67,7 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
||||||
"compress",
|
"compress",
|
||||||
"ie8",
|
"ie8",
|
||||||
"mangle",
|
"mangle",
|
||||||
|
"module",
|
||||||
"safari10",
|
"safari10",
|
||||||
"sourceMap",
|
"sourceMap",
|
||||||
"toplevel",
|
"toplevel",
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ function Compressor(options, false_by_default) {
|
||||||
keep_fnames : false,
|
keep_fnames : false,
|
||||||
keep_infinity : false,
|
keep_infinity : false,
|
||||||
loops : !false_by_default,
|
loops : !false_by_default,
|
||||||
|
module : false,
|
||||||
negate_iife : !false_by_default,
|
negate_iife : !false_by_default,
|
||||||
passes : 1,
|
passes : 1,
|
||||||
properties : !false_by_default,
|
properties : !false_by_default,
|
||||||
|
|
@ -138,6 +139,9 @@ function Compressor(options, false_by_default) {
|
||||||
funcs: toplevel,
|
funcs: toplevel,
|
||||||
vars: toplevel
|
vars: toplevel
|
||||||
};
|
};
|
||||||
|
if (this.options['module']) {
|
||||||
|
this.directives['use strict'] = true;
|
||||||
|
}
|
||||||
var sequences = this.options["sequences"];
|
var sequences = this.options["sequences"];
|
||||||
this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
|
this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
|
||||||
this.warnings_produced = {};
|
this.warnings_produced = {};
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ function minify(files, options) {
|
||||||
keep_classnames: undefined,
|
keep_classnames: undefined,
|
||||||
keep_fnames: false,
|
keep_fnames: false,
|
||||||
mangle: {},
|
mangle: {},
|
||||||
|
module: false,
|
||||||
nameCache: null,
|
nameCache: null,
|
||||||
output: {},
|
output: {},
|
||||||
parse: {},
|
parse: {},
|
||||||
|
|
@ -76,6 +77,7 @@ function minify(files, options) {
|
||||||
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
|
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
|
||||||
set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
|
set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
|
||||||
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
||||||
|
set_shorthand("module", options, [ "compress" ]);
|
||||||
set_shorthand("safari10", options, [ "mangle", "output" ]);
|
set_shorthand("safari10", options, [ "mangle", "output" ]);
|
||||||
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
||||||
set_shorthand("warnings", options, [ "compress" ]);
|
set_shorthand("warnings", options, [ "compress" ]);
|
||||||
|
|
|
||||||
|
|
@ -1601,3 +1601,19 @@ issue_2874_3: {
|
||||||
]
|
]
|
||||||
node_version: ">=6"
|
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