Closed Rich-Harris closed 7 years ago
Merging #97 into master will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #97 +/- ##
=======================================
Coverage 87.36% 87.36%
=======================================
Files 71 71
Lines 1527 1527
=======================================
Hits 1334 1334
Misses 193 193
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 4826591...387755f. Read the comment docs.
In some cases Uglify fails (async, anonymous function declaration default exports), and in some cases it generates bad output (class a||b{})
ES2017 is not yet supported in uglify: https://github.com/mishoo/UglifyJS2/issues/1789
Just created the PR https://github.com/mishoo/UglifyJS2/issues/1954 for exporting default anonymous functions and classes.
What input leads to (class a||b{})
?
It'd be great if you'd create uglify issues as you find bugs. We're all friends here.
It'd be great if you'd create uglify issues as you find bugs. We're all friends here.
I mean to — just trying to work through some of the low-hanging fruit first. Sorry, trying to juggle too many things!
What input leads to
(class a||b{})
?
Typo — I meant class foo extends a || b {}
. It's possible for a superclass to be an expression, but in most cases (anything below 18 in the operator precedence table) it needs to be parenthesized:
// valid
class foo extends (a||b) {}
// invalid
class foo extends a||b {}
Uglify is removing the parentheses (I only found this via eslump — highly recommended if you're not already using something like it).
Thanks!
I'll have to check out eslump!
Uglify is removing the parentheses
More accurately since Uglify parses to an AST, it's not adding the parentheses. :-)
It's a different perspective with a magic-string based approach.
OT - Buble hit a technical snag related having multiple transforms operate on the same object literal in a few tickets. Only so much inserting/deleting/removing/moving you can do at a single character position. See: https://gitlab.com/Rich-Harris/buble/issues/182 - I'm aware of a fix with a preprocessor pass to add parens around object literals, but it would not be pretty and would screw up source mappings.
since Uglify parses to an AST, it's not adding the parentheses. :-)
True!
OT - Buble hit a technical snag related having multiple transforms operate on the same object literal in a few tickets
Rats. Will take a poke soon.
This adds a warning if Uglify does a better job of compressing a test sample than Butternut. In some cases Uglify fails (
async
, anonymous function declaration default exports), and in some cases it generates bad output (class a||b{}
), but in many cases it's just doing a better job, and we should steal those optimisations.A few examples:
Removing unused function expression IDs
Removing empty IIFEs
Writing
Infinity
as1/0
Inlining certain values
Inlining function calls and removing redundant return statements
Not parenthesizing assignment expressions
Inlining return values from functions
Optimising
if(a)return b;else return c
Removing parens in NewExpression without parameters
There's a couple of others but those are the main ones.