aboutsummaryrefslogtreecommitdiff
path: root/lib/minify.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/minify.js')
-rw-r--r--lib/minify.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/minify.js b/lib/minify.js
index f9d726bf..806c3aeb 100644
--- a/lib/minify.js
+++ b/lib/minify.js
@@ -55,6 +55,7 @@ function minify(files, options) {
nameCache: null,
output: {},
parse: {},
+ rename: undefined,
sourceMap: false,
timings: false,
toplevel: false,
@@ -64,6 +65,9 @@ function minify(files, options) {
var timings = options.timings && {
start: Date.now()
};
+ if (options.rename === undefined) {
+ options.rename = options.compress && options.mangle;
+ }
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
@@ -137,6 +141,11 @@ function minify(files, options) {
if (options.wrap) {
toplevel = toplevel.wrap_commonjs(options.wrap);
}
+ if (timings) timings.rename = Date.now();
+ if (options.rename) {
+ toplevel.figure_out_scope(options.mangle);
+ toplevel.expand_names(options.mangle);
+ }
if (timings) timings.compress = Date.now();
if (options.compress) toplevel = new Compressor(options.compress).compress(toplevel);
if (timings) timings.scope = Date.now();
@@ -197,7 +206,8 @@ function minify(files, options) {
if (timings) {
timings.end = Date.now();
result.timings = {
- parse: 1e-3 * (timings.compress - timings.parse),
+ parse: 1e-3 * (timings.rename - timings.parse),
+ rename: 1e-3 * (timings.compress - timings.rename),
compress: 1e-3 * (timings.scope - timings.compress),
scope: 1e-3 * (timings.mangle - timings.scope),
mangle: 1e-3 * (timings.properties - timings.mangle),