Alex Lam S.L
dedbeeff15
plan B for IE8 do-while semi-colon fix ( #1572 )
...
- omitting trailing semi-colon in do-while breaks non-browser parser, e.g. uglify-js 1.x
- trailing semi-colon only breaks IE8 if followed by `else` or `while`
- always use braces in do-while body to workaround 2nd case with no size loss in compression
fixes #1568
2017-03-08 05:07:05 +08:00
Alex Lam S.L
bd6dee52ab
fix return from recursive IIFE ( #1570 )
...
`side-effects` did not account for IIFEs being able to reference itself thus making its return value potentially significant
2017-03-08 03:31:51 +08:00
Alex Lam S.L
144052ca49
v2.8.8
v2.8.8
2017-03-07 19:58:41 +08:00
Alex Lam S.L
65c848cc6f
include benchmark.js in test suite ( #1564 )
...
- report file sizes and overall run time
- exit with non-zero code upon error
2017-03-07 19:25:12 +08:00
Alex Lam S.L
8a8a94a596
fix deep cloning of labels ( #1565 )
...
`AST_Label.references` get `.initialize()` to `[]` every time after `.clone()`
So walk down the tree to pick up the cloned `AST_LoopControl` pieces and put it back together.
2017-03-07 18:38:27 +08:00
Alex Lam S.L
8153b7bd8a
transform function calls to IIFEs ( #1560 )
...
- expose function body to call sites for potential optimisations
- suppress substitution of variable used within `AST_Defun`
2017-03-07 15:37:52 +08:00
Alex Lam S.L
d787d70127
avoid substitution of global variables ( #1557 )
...
- unless `toplevel` is enabled
- global `const` works as before
2017-03-07 03:11:03 +08:00
kzc
3ac2421932
collapse_vars: do not replace a constant in loop condition or init ( #1562 )
2017-03-07 01:42:33 +08:00
Alex Lam S.L
a9fc9ddc33
suppress semicolons after do/while ( #1556 )
...
- unless both `beautify` & `screw-ie8` are enabled
- deprecate workaround for if-do-while-else
fixes #186
2017-03-06 17:31:35 +08:00
Alex Lam S.L
a5d62a3fc6
v2.8.7
v2.8.7
2017-03-05 17:17:08 +08:00
Alex Lam S.L
067e5a5762
fixup for #1553 ( #1555 )
...
- `++a` is the one that is foldable
- transform `a++` into `++a` for better optimisation
2017-03-05 17:15:37 +08:00
Alex Lam S.L
33b5f31984
v2.8.6
v2.8.6
2017-03-05 15:48:28 +08:00
Alex Lam S.L
35a849dc48
collapse assignment with adjacent subsequent usage ( #1553 )
...
- consolidate `cascade` optimisations
- support ++/-- postfixes
- remove redundant optimisation identified in #1460
fixes #368
2017-03-05 14:56:14 +08:00
Alex Lam S.L
b70591be1a
handle variable declaration within catch blocks ( #1546 )
...
accounts for IE8- scoping
2017-03-05 13:13:44 +08:00
Alex Lam S.L
b33e7f88e6
improve unsafe on undefined ( #1548 )
...
`unsafe` turns undefined keyword into a variable of the same name if found, but that interferes with other related optimisations.
Keep track of such transformations to ensure zero information loss in the process.
2017-03-05 13:09:27 +08:00
Alex Lam S.L
1f0333e9f1
stay safe with constants in IE8- ( #1547 )
...
- `undefined` etc. can be redefined at top-level for IE8-, so disable related optimisations
- fixed `--support-ie8` catch mangle bug
2017-03-05 12:51:11 +08:00
Alex Lam S.L
eb98a7f2f3
fix handling of shebang and preamble ( #1545 )
...
fixes #1332
2017-03-05 12:16:02 +08:00
Alex Lam S.L
78d1bb92d4
fix a corner case in #1530 ( #1552 )
2017-03-05 12:12:59 +08:00
Alex Lam S.L
ea9ab9fb0e
resolve issue with outdated version of async ( #1549 )
...
fixes #746
2017-03-05 01:54:20 +08:00
kzc
ce54c9ccee
disallow collapse_vars constant replacement in for-in statements ( #1543 )
2017-03-04 02:39:54 +08:00
Alex Lam S.L
07accd2fbb
process code with implicit return statement ( #1522 )
...
Bookmarklet for instance implicitedly assumes a "completion value" without using `return`.
The `expression` option now supports such use cases.
Optimisations on IIFEs also enhanced.
fixes #354
fixes #543
fixes #625
fixes #628
fixes #640
closes #1293
2017-03-03 18:13:07 +08:00
Alex Lam S.L
18059cc94f
compress numerical expressions ( #1513 )
...
safe operations
- `a === b` => `a == b`
- `a + -b` => `a - b`
- `-a + b` => `b - a`
- `a+ +b` => `+b+a`
associative operations
(bit-wise operations are safe, otherwise `unsafe_math`)
- `a + (b + c)` => `(a + b) + c`
- `(n + 2) + 3` => `5 + n`
- `(2 * n) * 3` => `6 * n`
- `(a | 1) | (2 | d)` => `(3 | a) | b`
fixes #412
2017-03-03 18:04:32 +08:00
Alex Lam S.L
b5e0e8c203
facilitate fix for #1531 ( #1542 )
2017-03-03 07:12:24 +08:00
Alex Lam S.L
e5cb9275df
v2.8.5
v2.8.5
2017-03-03 05:14:21 +08:00
Alex Lam S.L
17b81350d4
fix chained assignment with unused ( #1540 )
...
When #1450 optimises `a=b=42`, it stops after the first variable even if both are unused.
fixes #1539
2017-03-03 04:45:20 +08:00
kzc
4d63d4f5b3
collapse_vars should not replace constant in for-in init section ( #1538 )
...
fixes #1537
2017-03-03 03:51:15 +08:00
Alex Lam S.L
70d72ad806
properly cover all cases of for-in loop variables ( #1536 )
2017-03-03 02:39:57 +08:00
Alex Lam S.L
fe9227a41b
fix reference marking in for-in loops ( #1535 )
...
fixes #1533
2017-03-03 00:56:06 +08:00
Alex Lam S.L
b49e142a26
disable do{...}while(false) optimisation ( #1534 )
...
- fails to handle `break` in body
fixes #1532
2017-03-03 00:54:41 +08:00
kzc
ee3b39b909
optimize trivial IIFEs returning constants ( #1530 )
2017-03-02 15:11:40 +08:00
Alex Lam S.L
9699ffb1af
trim unused invocation parameters ( #1526 )
2017-03-02 11:33:59 +08:00
Alex Lam S.L
fdc9b9413b
minor improvement to string optimisation ( #1514 )
...
- "" + "a" => "a"
- "" + a + "b" => a + "b"
- "a" + "" => "a" (improving on #45 )
2017-03-02 11:31:39 +08:00
Alex Lam S.L
40ceddb48a
v2.8.4
v2.8.4
2017-03-02 00:24:49 +08:00
Alex Lam S.L
7aa69117e1
fix corner cases in reduce_vars ( #1524 )
...
Avoid variable substitution in the following cases:
- use of variable before declaration
- declaration within conditional code blocks
- declaration within loop body
fixes #1518
fixes #1525
2017-03-02 00:20:53 +08:00
Alex Lam S.L
bff7ad67bb
v2.8.3
v2.8.3
2017-03-01 15:28:46 +08:00
Alex Lam S.L
c2334baa48
fix crash on missing props to string_template() ( #1523 )
...
Patched up `make_node()` without `orig`.
There may be other cases where `start` could be missing, so make it print "undefined" instead of crashing.
fixes #1518
2017-03-01 15:25:26 +08:00
Alex Lam S.L
fb2b6c7c6f
v2.8.2
v2.8.2
2017-03-01 04:46:12 +08:00
Alex Lam S.L
f5cbe19b75
invert reduce_vars tracking flag ( #1519 )
...
Modules like webpack and grunt-contrib-uglify still uses `ast.transform(compressor)` before `Compressor.compress(ast)` was introduced.
Workaround this compatibility issue by deactivating `reduce_vars` in such case.
Also fix use case with omitted `options` when calling `Compressor()`.
fixes #1516
2017-03-01 04:12:10 +08:00
Alex Lam S.L
b34fa11a13
fix evaluate on object getter & setter ( #1515 )
2017-03-01 02:03:47 +08:00
Alex Lam S.L
320984c5f5
v2.8.1
v2.8.1
2017-03-01 00:27:08 +08:00
Alex Lam S.L
4365a51237
temporarily disables reduce_vars ( #1517 )
...
... as we investigate #1516
2017-03-01 00:25:43 +08:00
Alex Lam S.L
858e6c78a4
warn & drop #__PURE__ iff IIFE is dropped ( #1511 )
...
- consolidate `side-effects` optimisations
- improve string `+` optimisation
- enhance literal & `conditionals` optimisations
2017-02-28 02:25:44 +08:00
Alex Lam S.L
0b0296eb2a
v2.8.0
v2.8.0
2017-02-27 03:47:54 +08:00
Alex Lam S.L
872270b149
improve error messages ( #1506 )
...
- better inheritance of `Error` sub-classes
- mark parse error against source in CLI
closes #235
closes #348
closes #524
closes #1356
closes #1405
2017-02-27 03:40:54 +08:00
kzc
b1c593a041
add harmony branch details in README ( #1507 )
2017-02-27 01:55:24 +08:00
Alex Lam S.L
13be50a4a9
faster tree transversal ( #1462 )
...
- convert `[].forEach()` to for-loops
2017-02-26 05:58:26 +08:00
Alex Lam S.L
16cd5d57a5
consolidate evaluate & reduce_vars ( #1505 )
...
- improve marking efficiency
- apply smarter `const` replacement to `var`
fixes #1501
2017-02-26 00:40:33 +08:00
Alex Lam S.L
834f9f3924
update docs for pure_funcs & drop_console ( #1503 )
...
closes #1362
closes #1399
2017-02-25 04:13:10 +08:00
Alex Lam S.L
cf0951f726
allow --in-source-map inline ( #1490 )
...
- limited to one input file (or `stdin`)
- only works with built-in parser
fixes #520
2017-02-25 04:11:21 +08:00
Ondřej Španěl
852f78491a
Avoid using exports when undefined ( #1471 )
...
Makes direct usage within web browser easier, even if officially unsupported.
2017-02-24 08:51:24 +08:00