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
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
Anthony Van de Gejuchte
da17766ddd
Add preventive test involving non-ascii function identifiers
2017-01-19 17:13:33 +01:00
Wiktor Kwapisiewicz
0913db8c84
Add note about name mangling when using --mangle-props=unquoted ( #1314 )
2017-01-19 16:47:10 +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
f6372483a0
v2.7.5
v2.7.5
2016-11-29 22:29:59 +01:00
Martijn Swaagman
98f330658f
Generate source map data from normalized files
...
If using `inSourceMap` this fix will ensure the copying of `sourcesContent` is based on potentially normalized `sources` values (https://github.com/mozilla/source-map/blob/master/lib/source-map-consumer.js#L304-L309 ).
For example `normalize` (https://github.com/mozilla/source-map/blob/master/lib/util.js#L80-L123 ) will rewrite `./dist/mySource.js` to `dist/mySource.js` in the target `_sources` of the `SourceMapConsumer`. As a result `orig_map.sourceContentFor(source, true);` would return `null` since the orginal `source` was no longer available in the consumer. By using the keys generating from the `SourceMapConsumer.constructor` consistency is ensured.
2016-11-29 20:42:56 +01:00
1111hui
a7b3b0d3a5
docs: add doc for option.outFileName
2016-11-29 20:29:12 +01:00
1111hui
0a35acbbe7
feat: add option.outFileName for JS API, if absense, sourceMap.file field will deduced
2016-11-29 20:29:12 +01:00
Ashley (Scirra)
2a9989dd18
Add --mangle-props-debug and fix --mangle-props=unquoted collision
...
Patch by @AshleyScirra
Based on: PR #1316
Renamed the CLI debug option to --mangle-props-debug
Fixes : #1321 name collision in --mangle-props=unquoted
2016-11-29 20:25:39 +01:00
Anthony Van de Gejuchte
79b98a9fe8
Do not overwrite options.comments + cleanup
2016-11-29 20:24:08 +01:00
Anthony Van de Gejuchte
057de570e6
Pass mangle options to figure_out_scope before mangling in tests
2016-10-27 22:55:49 +02:00
Richard van Velzen
557b3e412f
v2.7.4
v2.7.4
2016-10-23 21:46:22 +02:00
Anthony Van de Gejuchte
8d74f34373
Don't filter shebangs when using the 'some' comment filter
...
Also clarify documentation a bit more about using regexp as filter
2016-10-23 21:31:03 +02:00
Jann Horn
266ddd9639
fix uses_arguments handling (broken since 6605d15783)
...
Using the symbol declaration tracking of UglifyJS doesn't make sense here
anyway, `arguments` always comes from something in the current scope.
fixes #1299
2016-10-23 21:29:18 +02:00
pengzhenqing
e51c6ba380
Add an option for writing inline source map
2016-10-23 21:21:39 +02:00
Richard van Velzen
6389e52305
Remove console.log and add extra test case
2016-10-06 14:11:32 +02:00
Richard van Velzen
e05510f3bc
Add an option to wrap IIFEs in parenthesis
...
For #1307 .
2016-10-06 14:11:32 +02:00
kzc
fc9804b909
Fix (typeof side_effect()) in boolean context
...
Fixes #1289 with suggestion by @rvanvelzen
2016-10-06 13:50:11 +02:00
alexlamsl
4761d07e0b
Optimize unmodified variables
2016-10-01 11:36:11 +02:00
Anthony Van de Gejuchte
0111497fc9
Make all comment options in cli available in js api
...
Also removing more code within "loop" while at it.
2016-09-06 17:54:45 +02:00
Mihai Bazon
7d8dea3b26
Merge pull request #1277 from kzc/fix-string-plus-opt
...
Account for side effects in `string + expr` optimization
2016-09-01 16:32:22 +03:00
kzc
25fc02743a
Account for side effects in string + expr optimization
2016-09-01 09:24:56 -04:00
kzc
0bd8053524
implement optimization: (x = 2 * x) ---> (x *= 2)
2016-08-30 08:43:02 -04:00
Richard van Velzen
1a78bbcd23
v2.7.3
v2.7.3
2016-08-17 20:34:27 +02:00
Richard van Velzen
8430123e9d
Fix negate_iife transform to return a correct tree for nested IIFEs
...
Fix for #1256 , partially reverts d854523783
2016-08-17 11:55:59 +02:00
Richard van Velzen
614db97cca
v2.7.2
v2.7.2
2016-08-17 08:51:23 +02:00