Skip to content

Commit

Permalink
Update uglify-es options to use recommended features. Closes gh-1261
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 28, 2017
1 parent 8ba8a95 commit 241e1f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
8 changes: 8 additions & 0 deletions lib/tessel/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,14 @@ exportables.compress = function(source, options) {
cascade: true,
conditionals: true,
comparisons: true,
ecma: 6,
evaluate: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
loops: true,
passes: 3,
properties: true,
sequences: true,
unsafe: true,
Expand All @@ -783,20 +785,26 @@ exportables.compress = function(source, options) {
toplevel: true,
};

const output = {
ecma: 6,
};

const parse = {
bare_returns: true,
shebang: true,
};

Object.assign(compress, options.compress || {});
Object.assign(mangle, options.mangle || {});
Object.assign(output, options.output || {});
Object.assign(parse, options.parse || {});

const uOptions = {
toplevel: true,
warnings: false,
compress,
mangle,
output,
parse,
};

Expand Down
17 changes: 0 additions & 17 deletions lib/tessel/deployment/lists/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@ module.exports = {
},
compressionOptions: {
'extend': {
special: {
/*
The "extend" module uses the following unadvisable pattern:
module.exports = function NAME() {
... later calls NAME()
};
UglifyJS's compression algorithm wants to remove that unnecessary
function expression _name_. That's ok, because we can just as
easily use `keep_fnames: true` to avoid that removal. Unfortunately,
that's not enough in this case, as mangling produces sometimes
requires another pass with `figure_out_scope` to avoid
unhygienic mangling.
*/
rescope_after_mangle: true
},
compress: {
keep_fnames: true
},
Expand Down
11 changes: 6 additions & 5 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,22 @@ exports['deployment.js.compress'] = {
},

noOptionsCompress(test) {
test.expect(20);
test.expect(22);

const optionsCompress = {
// ------
booleans: true,
cascade: true,
conditionals: true,
comparisons: true,
ecma: 6,
evaluate: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
loops: true,
passes: 3,
properties: true,
sequences: true,
unsafe: true,
Expand Down Expand Up @@ -332,20 +334,22 @@ exports['deployment.js.compress'] = {
},

ourOptionsCompress(test) {
test.expect(20);
test.expect(22);

const ourExplicitSettings = {
// ------
booleans: true,
cascade: true,
conditionals: true,
comparisons: true,
ecma: 6,
evaluate: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
loops: true,
passes: 3,
properties: true,
sequences: true,
unsafe: true,
Expand Down Expand Up @@ -3326,9 +3330,6 @@ exports['deployment.js.lists'] = {
*/
var compressionOptions = {
extend: {
special: {
rescope_after_mangle: true
},
compress: {
keep_fnames: true
},
Expand Down

0 comments on commit 241e1f1

Please sign in to comment.