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
Richard van Velzen
4bd31607f6
Merge branch 'master' into harmony
2017-01-26 13:02:22 +01: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
Anthony Van de Gejuchte
4728bc73ad
Allow parsing regexp after arrow token ( #1439 )
2017-01-26 12:06:46 +01:00
alexlamsl
48284844a4
add missing LHS cases which global_defs should avoid
2017-01-19 21:06:28 +01:00
Anthony Van de Gejuchte
52ce9a333c
Fix compression with unused containing destructuring
2017-01-19 21:04:28 +01:00
kzc
abbeb266b5
[ES6] output parens for yield when parented by AST_Dot or AST_Sub ( #1419 )
2017-01-19 17:15:59 +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
Anthony Van de Gejuchte
da17766ddd
Add preventive test involving non-ascii function identifiers
2017-01-19 17:13:33 +01:00
Anthony Van de Gejuchte
b11c5151bc
Fix regression with non-ascii function identifiers
...
Regression since 110a1ac885
2017-01-19 16:47:37 +01:00
Wiktor Kwapisiewicz
0913db8c84
Add note about name mangling when using --mangle-props=unquoted ( #1314 )
2017-01-19 16:47:10 +01:00
Richard van Velzen
962b1f3d40
Merge branch 'master' into harmony
2016-11-30 18:59:32 +01:00
kzc
5c7705fcad
remove npm-shrinkwrap.json to work around npm@4.0.2 bug ( #1384 )
2016-11-30 18:09:52 +01:00
Richard van Velzen
3ee46e91e8
Merge branch 'master' into harmony
harmony-v2.7.5
2016-11-29 22:32:49 +01:00
Richard van Velzen
f6372483a0
v2.7.5
v2.7.5
2016-11-29 22:29:59 +01:00
Richard van Velzen
ee26e7f11b
Merge branch 'master' into harmony
2016-11-29 20:50:27 +01:00
Anthony Van de Gejuchte
937f534392
Fix flag name in readme
2016-11-29 20:44:22 +01:00