enable collapse_vars & reduce_vars by default

- fix corner cases in `const` optimisation
- deprecate `/*@const*/`

fixes #1497
closes #1498
This commit is contained in:
alexlamsl
2017-02-24 01:46:57 +08:00
parent 1e51586996
commit 4e49302916
8 changed files with 56 additions and 25 deletions

View File

@@ -469,8 +469,6 @@ separate file and include it into the build. For example you can have a
```javascript
const DEBUG = false;
const PRODUCTION = true;
// Alternative for environments that don't support `const`
/** @const */ var STAGING = false;
// etc.
```
@@ -481,7 +479,8 @@ and build your code like this:
UglifyJS will notice the constants and, since they cannot be altered, it
will evaluate references to them to the value itself and drop unreachable
code as usual. The build will contain the `const` declarations if you use
them. If you are targeting < ES6 environments, use `/** @const */ var`.
them. If you are targeting < ES6 environments which does not support `const`,
using `var` with `reduce_vars` (enabled by default) should suffice.
<a name="codegen-options"></a>