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
Alex Lam S.L
229e42cdee
Merge pull request #1485 from alexlamsl/merge-2.8.0
...
2.8.0 staging
2017-02-24 07:33:57 +08:00
alexlamsl
4e49302916
enable collapse_vars & reduce_vars by default
...
- fix corner cases in `const` optimisation
- deprecate `/*@const*/`
fixes #1497
closes #1498
2017-02-24 01:46:57 +08:00
kzc
1e51586996
Support marking a call as pure
...
A function call or IIFE with an immediately preceding comment
containing `@__PURE__` or `#__PURE__` is deemed to be a
side-effect-free pure function call and can potentially be
dropped.
Depends on `side_effects` option.
`[#@]__PURE__` hint will be removed from comment when pure
call is dropped.
fixes #1261
closes #1448
2017-02-21 14:24:18 +08:00
Ondřej Španěl
d48a3080ac
Fix: AST_Accessor missing start / end tokens
...
fixes #1492
closes #1493
2017-02-21 13:32:16 +08:00
alexlamsl
26fbeece1c
fix pure_funcs & improve side_effects
...
- only drops side-effect-free arguments
- drop side-effect-free parts with discarded value from `AST_Seq` & `AST_SimpleStatement`
closes #1494
2017-02-21 13:31:59 +08:00
alexlamsl
8898b8a0fe
clean up max_line_len
...
- never exceed specified limit
- otherwise warning is shown
- enabled only for final output
closes #1496
2017-02-21 13:29:58 +08:00
alexlamsl
ec64acd2c8
introduce unsafe_proto
...
- `Array.prototype.slice` => `[].slice`
closes #1491
2017-02-21 13:29:58 +08:00
alexlamsl
ac0b61ed6e
remove extraneous spaces between ++/+/--/-
...
fixes #1377
closes #1488
2017-02-21 13:29:58 +08:00
Anthony Van de Gejuchte
c06a50f338
Add .gitattributes to checkout lf eol style
...
closes #1487
2017-02-21 13:29:58 +08:00
alexlamsl
09f9ae2de9
improve --beautify bracketize
...
reduce whitespaces from if-else statements
fixes #1482
closes #1483
2017-02-21 13:29:58 +08:00
alexlamsl
7e6331bb39
add benchmark & JetStream tests
...
- `test/benchmark.js` measures performance
- `test/jetstream.js` verifies correctness
- configurable mangle/compress/output options
closes #1479
2017-02-21 13:29:58 +08:00
alexlamsl
e275148998
enhance global_defs
...
- support arrays, objects & AST_Node
- support `"a.b":1` on both cli & API
- emit warning if variable is modified
- override top-level variables
fixes #1416
closes #1198
closes #1469
2017-02-21 13:29:58 +08:00
alexlamsl
974247c8c0
evaluate AST_SymbolRef as parameter
...
fix invalid boolean conversion now exposed in `make_node_from_constant()`
closes #1477
2017-02-21 13:29:58 +08:00
alexlamsl
a0f4fd390a
improve reduce_vars and fix a bug
...
- update modified flag between compress() passes
- support IIFE arguments
- fix corner case with multiple definitions
closes #1473
2017-02-21 13:29:58 +08:00
alexlamsl
b8b133d91a
improve keep_fargs & keep_fnames
...
- utilise in_use_ids instead of unreferenced()
- drop_unused now up-to-date for subsequent passes
closes #1476
2017-02-21 13:29:58 +08:00
alexlamsl
c525a2b190
fix duplicated test names
...
previously test cases with the same name would be skipped except for the last one
`test/run-test.js` will now report duplicated names as errors
closes #1461
2017-02-21 13:29:58 +08:00
kzc
6ffbecb72b
smarter const replacement taking name length into account
...
closes #1459
2017-02-21 13:29:58 +08:00
alexlamsl
f0ff6189be
clean up negate_iife
...
- remove extra tree scanning phase for `negate_iife`
- `negate_iife` now only deals with the narrowest form, i.e. IIFE sitting directly under `AST_SimpleStatement`
- `booleans`, `conditionals` etc. will now take care the rest via more accurate accounting
- `a(); void b();` => `a(); b();`
fixes #1288
closes #1451
2017-02-21 13:29:58 +08:00
alexlamsl
6b3c49e458
improve string concatenation
...
shuffle associative operations to minimise parentheses and aid other uglification efforts
closes #1454
2017-02-21 13:29:57 +08:00
alexlamsl
f584ca8d07
-c sequences=N suboptimal at N expression cutoff
...
N = 2:
a;
b;
c;
d;
was:
a, b;
c;
d;
now:
a, b;
c, d;
fixes #1455
closes #1457
2017-02-21 13:29:57 +08:00
alexlamsl
ae4db00991
tweak do-while loops
...
- `do{...}while(false)` => `{...}`
- clean up `AST_While` logic
closes #1452
2017-02-21 13:29:57 +08:00
alexlamsl
100307ab31
fixes & improvements to [].join()
...
fixes
- [a].join() => "" + a
- ["a", , "b"].join() => "a,,b"
- ["a", null, "b"].join() => "a,,b"
- ["a", undefined, "b"].join() => "a,,b"
improvements
- ["a", "b"].join(null) => "anullb"
- ["a", "b"].join(undefined) => "a,b"
- [a + "b", c].join("") => a + "b" + c
closes #1453
2017-02-21 13:29:57 +08:00
alexlamsl
148047fbbf
drop unused: toplevel, assign-only
...
- assign statement does not count towards variable usage by default
- only works with assignments on the same scope level as declaration
- can be disabled with `unused` set to "keep_assign"
- `toplevel` to drop unused top-level variables and/or functions
- `top_retain` to whitelist top-level exceptions
closes #1450
2017-02-21 13:29:57 +08:00
kzc
d11dca3cf9
fix stray else in compress with conditionals=false
...
closes #1449
2017-02-21 13:29:57 +08:00
alexlamsl
e5badb9541
enable typeof "undefined" for general use
...
move out of unsafe, guard corner case with screw_id8 instead
closes #1446
2017-02-18 19:01:42 +08:00
alexlamsl
fa668a28b4
fix corner case in keep_fnames
...
happens when inner function:
- just below top level
- not referenced
- `unused` is disabled
closes #1445
2017-02-18 19:00:54 +08:00
alexlamsl
686a496b1c
remove unused AST_Scope.nesting & AST_SymbolRef.frame
...
they are computed but never used
closes #1444
2017-02-18 18:59:40 +08:00
alexlamsl
11676f9d72
fix crash in unsafe replacement of undefined
...
remove extraneous call to AST_SymbolRef.reference()
closes #1443
2017-02-18 18:58:23 +08:00
Anthony Van de Gejuchte
dd31d12a91
Improve optimizing function() { if(c){return foo} bar();}
...
closes #1437
2017-02-18 18:56:18 +08:00
Mihai Bazon
eb55d8a9bb
Merge pull request #1481 from anatdagan/propsmangle_only_identifiers
...
verify that property names after mangle are legal
2017-02-12 10:59:43 +02:00
Anat Dagan
81f1df14d7
in mangle_names there is a check that the variable name is legal and that it is not a reserved word. This should apply to propsmangle as well.
2017-02-10 14:13:47 +02:00
Alex Lam S.L
7f8d72d9d3
update test ( #1441 )
...
improved reduce_vars & binary operands produce more optimal results
2017-01-26 12:59:32 +01:00
Alex Lam S.L
1eaa211e09
fix mangling collision with keep_fnames ( #1431 )
...
* fix mangling collision with keep_fnames
fixes #1423
* pass mangle options to figure_out_scope()
bring command-line in line with minify()
2017-01-26 12:18:28 +01:00
Alex Lam S.L
0610c020b1
optimise binary operands with evaluate() ( #1427 )
...
- remove call to evaluate() in is_constant() and let nested optimize() does its job instead
- reject RegExp in is_constant() and remove special case logic under collapse_vars
- operands to conditionals optimisation are now always evaluate()-ed
- throw error in constant_value() instead of returning undefined to catch possible bugs, similar to make_node_from_constant()
- optimise binary boolean operators under `evaluate` instead of `conditionals`
2017-01-26 12:16:50 +01:00
Alex Lam S.L
0d7d4918eb
augment evaluate to extract within objects ( #1425 )
...
- gated by `unsafe`
- replaces previous optimisation specific to String.length
- "123"[0] => 1
- [1, 2, 3][0] => 1
- [1, 2, 3].length => 3
- does not apply to objects with overridden prototype functions
2017-01-26 12:14:18 +01:00
alexlamsl
48284844a4
add missing LHS cases which global_defs should avoid
2017-01-19 21:06:28 +01:00
kzc
ec2e5fa3a2
Have minify() and tests use figure_out_scope() as uglifyjs CLI does
...
Clarify docs, help and tests for --support-ie8 and screw_ie8=false
2017-01-19 17:14:33 +01:00