improve compression of undefined, NaN & Infinitiy (#1748)

- migrate transformation logic from `OutputStream` to `Compressor`
- always turn `undefined` into `void 0` (unless `unsafe`)
- always keep `NaN` except when avoiding local variable redefinition
- introduce `keep_infinity` to suppress `1/0` transform, except when avoiding local variable redefinition

supersedes #1723
fixes #1730
This commit is contained in:
Alex Lam S.L
2017-04-01 03:02:14 +08:00
committed by GitHub
parent 1ddc05725d
commit 257ddc3bdb
9 changed files with 170 additions and 56 deletions

View File

@@ -443,6 +443,9 @@ to set `true`; it's effectively a shortcut for `foo=true`).
integer argument larger than 1 to further reduce code size in some cases.
Note: raising the number of passes will increase uglify compress time.
- `keep_infinity` -- default `false`. Pass `true` to prevent `Infinity` from
being compressed into `1/0`, which may cause performance issues on Chrome.
### The `unsafe` option
It enables some transformations that *might* break code logic in certain