alexlamsl [Sat, 18 Feb 2017 11:22:24 +0000 (19:22 +0800)]
evaluate AST_SymbolRef as parameter
fix invalid boolean conversion now exposed in `make_node_from_constant()`
closes #1477
alexlamsl [Sat, 18 Feb 2017 11:19:55 +0000 (19:19 +0800)]
improve reduce_vars and fix a bug
- update modified flag between compress() passes
- support IIFE arguments
- fix corner case with multiple definitions
closes #1473
alexlamsl [Sat, 18 Feb 2017 11:19:12 +0000 (19:19 +0800)]
improve keep_fargs & keep_fnames
- utilise in_use_ids instead of unreferenced()
- drop_unused now up-to-date for subsequent passes
closes #1476
alexlamsl [Sat, 18 Feb 2017 11:15:09 +0000 (19:15 +0800)]
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
kzc [Sat, 18 Feb 2017 11:12:57 +0000 (19:12 +0800)]
smarter const replacement taking name length into account
closes #1459
alexlamsl [Sat, 18 Feb 2017 11:11:57 +0000 (19:11 +0800)]
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
alexlamsl [Sat, 18 Feb 2017 11:07:52 +0000 (19:07 +0800)]
improve string concatenation
shuffle associative operations to minimise parentheses and aid other uglification efforts
closes #1454
alexlamsl [Sat, 18 Feb 2017 11:07:03 +0000 (19:07 +0800)]
`-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
alexlamsl [Sat, 18 Feb 2017 11:05:54 +0000 (19:05 +0800)]
tweak do-while loops
- `do{...}while(false)` => `{...}`
- clean up `AST_While` logic
closes #1452
alexlamsl [Sat, 18 Feb 2017 11:05:11 +0000 (19:05 +0800)]
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
alexlamsl [Sat, 18 Feb 2017 11:03:53 +0000 (19:03 +0800)]
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
kzc [Sat, 18 Feb 2017 11:02:59 +0000 (19:02 +0800)]
fix stray else in compress with conditionals=false
closes #1449
alexlamsl [Sat, 18 Feb 2017 11:01:42 +0000 (19:01 +0800)]
enable typeof "undefined" for general use
move out of unsafe, guard corner case with screw_id8 instead
closes #1446
alexlamsl [Sat, 18 Feb 2017 11:00:54 +0000 (19:00 +0800)]
fix corner case in keep_fnames
happens when inner function:
- just below top level
- not referenced
- `unused` is disabled
closes #1445
alexlamsl [Sat, 18 Feb 2017 10:59:40 +0000 (18:59 +0800)]
remove unused AST_Scope.nesting & AST_SymbolRef.frame
they are computed but never used
closes #1444
alexlamsl [Sat, 18 Feb 2017 10:58:23 +0000 (18:58 +0800)]
fix crash in unsafe replacement of undefined
remove extraneous call to AST_SymbolRef.reference()
closes #1443
Anthony Van de Gejuchte [Sat, 18 Feb 2017 10:56:18 +0000 (18:56 +0800)]
Improve optimizing `function() { if(c){return foo} bar();}`
closes #1437
Alex Lam S.L [Thu, 26 Jan 2017 11:59:32 +0000 (19:59 +0800)]
update test (#1441)
improved reduce_vars & binary operands produce more optimal results
Alex Lam S.L [Thu, 26 Jan 2017 11:18:28 +0000 (19:18 +0800)]
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()
Alex Lam S.L [Thu, 26 Jan 2017 11:16:50 +0000 (19:16 +0800)]
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`
Alex Lam S.L [Thu, 26 Jan 2017 11:14:18 +0000 (19:14 +0800)]
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
alexlamsl [Tue, 17 Jan 2017 09:33:40 +0000 (17:33 +0800)]
add missing LHS cases which global_defs should avoid
kzc [Wed, 21 Dec 2016 15:52:30 +0000 (10:52 -0500)]
Have minify() and tests use figure_out_scope() as uglifyjs CLI does
Clarify docs, help and tests for --support-ie8 and screw_ie8=false
Anthony Van de Gejuchte [Wed, 30 Nov 2016 20:54:23 +0000 (21:54 +0100)]
Add preventive test involving non-ascii function identifiers
Wiktor Kwapisiewicz [Wed, 30 Nov 2016 13:54:15 +0000 (14:54 +0100)]
Add note about name mangling when using --mangle-props=unquoted (#1314)
kzc [Wed, 30 Nov 2016 06:18:52 +0000 (01:18 -0500)]
remove npm-shrinkwrap.json to work around npm@4.0.2 bug (#1384)
Richard van Velzen [Tue, 29 Nov 2016 21:29:59 +0000 (22:29 +0100)]
v2.7.5
Martijn Swaagman [Fri, 4 Nov 2016 18:49:59 +0000 (19:49 +0100)]
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.
1111hui [Sat, 29 Oct 2016 07:55:47 +0000 (15:55 +0800)]
docs: add doc for option.outFileName
1111hui [Sat, 29 Oct 2016 07:21:28 +0000 (15:21 +0800)]
feat: add option.outFileName for JS API, if absense, sourceMap.file field will deduced
Ashley (Scirra) [Thu, 27 Oct 2016 15:23:04 +0000 (11:23 -0400)]
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
Anthony Van de Gejuchte [Wed, 26 Oct 2016 15:34:30 +0000 (17:34 +0200)]
Do not overwrite options.comments + cleanup
Anthony Van de Gejuchte [Wed, 26 Oct 2016 10:34:38 +0000 (12:34 +0200)]
Pass mangle options to figure_out_scope before mangling in tests
Richard van Velzen [Sun, 23 Oct 2016 19:46:22 +0000 (21:46 +0200)]
v2.7.4
Anthony Van de Gejuchte [Sun, 16 Oct 2016 18:57:28 +0000 (20:57 +0200)]
Don't filter shebangs when using the 'some' comment filter
Also clarify documentation a bit more about using regexp as filter
Jann Horn [Fri, 14 Oct 2016 16:04:39 +0000 (18:04 +0200)]
fix uses_arguments handling (broken since
6605d1578351)
Using the symbol declaration tracking of UglifyJS doesn't make sense here
anyway, `arguments` always comes from something in the current scope.
fixes #1299
pengzhenqing [Sun, 9 Oct 2016 06:15:25 +0000 (14:15 +0800)]
Add an option for writing inline source map
Richard van Velzen [Thu, 6 Oct 2016 12:11:19 +0000 (14:11 +0200)]
Remove console.log and add extra test case
Richard van Velzen [Fri, 30 Sep 2016 10:27:45 +0000 (12:27 +0200)]
Add an option to wrap IIFEs in parenthesis
For #1307.
kzc [Sun, 2 Oct 2016 14:46:09 +0000 (10:46 -0400)]
Fix (typeof side_effect()) in boolean context
Fixes #1289 with suggestion by @rvanvelzen
alexlamsl [Tue, 20 Sep 2016 14:23:27 +0000 (22:23 +0800)]
Optimize unmodified variables
Anthony Van de Gejuchte [Sat, 3 Sep 2016 21:26:31 +0000 (23:26 +0200)]
Make all comment options in cli available in js api
Also removing more code within "loop" while at it.
Mihai Bazon [Thu, 1 Sep 2016 13:32:22 +0000 (16:32 +0300)]
Merge pull request #1277 from kzc/fix-string-plus-opt
Account for side effects in `string + expr` optimization
kzc [Thu, 1 Sep 2016 13:24:56 +0000 (09:24 -0400)]
Account for side effects in `string + expr` optimization
kzc [Fri, 26 Aug 2016 22:47:25 +0000 (18:47 -0400)]
implement optimization: (x = 2 * x) ---> (x *= 2)
Richard van Velzen [Wed, 17 Aug 2016 18:34:27 +0000 (20:34 +0200)]
v2.7.3
Richard van Velzen [Wed, 17 Aug 2016 09:43:50 +0000 (11:43 +0200)]
Fix negate_iife transform to return a correct tree for nested IIFEs
Fix for #1256, partially reverts
d854523783b4
Richard van Velzen [Wed, 17 Aug 2016 06:51:23 +0000 (08:51 +0200)]
v2.7.2
kzc [Wed, 17 Aug 2016 01:54:54 +0000 (21:54 -0400)]
Fix negate_iife regression #1254
Richard van Velzen [Sun, 14 Aug 2016 20:02:01 +0000 (22:02 +0200)]
v2.7.1
Timothy Gu [Fri, 12 Aug 2016 01:21:21 +0000 (18:21 -0700)]
Add missing `{` in README
Also fix a trivial style mistake.
kzc [Sun, 31 Jul 2016 06:35:14 +0000 (02:35 -0400)]
Fix --mangle-props and --mangle-props=unquoted
Fixes: #1247
Fix --mangle-props and --name-cache inconsistency.
AST_Dot and AST_Sub properties are now mangled by --mangle-props
without regard to being used in an assignment statement.
Note: if --mangle-props is used then *all* javascript files used must
be uglified with the same mangle options.
Fix the ignore_quoted=true mangle option, also known as
`--mangle-props=unquoted`. If a given property is quoted anywhere
it will not be mangled in any quoted or non-quoted context.
kzc [Sat, 30 Jul 2016 17:21:23 +0000 (13:21 -0400)]
Additional object literal property tests
kzc [Sat, 30 Jul 2016 01:27:30 +0000 (21:27 -0400)]
Add input file glob support to minify()
kzc [Fri, 29 Jul 2016 20:18:56 +0000 (16:18 -0400)]
Add simple file globbing to bin/uglifyjs for Windows
Lucas Wiener [Thu, 28 Jul 2016 07:30:12 +0000 (09:30 +0200)]
Moved test input files to test/input.
Lucas Wiener [Wed, 27 Jul 2016 14:02:33 +0000 (16:02 +0200)]
Added test for #1236
Lucas Wiener [Tue, 26 Jul 2016 07:54:02 +0000 (09:54 +0200)]
Fixed sourceMapIncludeSources and inSourceMap = string combination of the UglifyJS.minify function.
kzc [Sat, 23 Jul 2016 15:50:44 +0000 (11:50 -0400)]
Fix unneeded parens around unary args in new expression.
kzc [Fri, 22 Jul 2016 14:44:29 +0000 (10:44 -0400)]
Test reparsing test/compress/*.js output
Anthony Van de Gejuchte [Thu, 21 Jul 2016 01:19:24 +0000 (03:19 +0200)]
Legacy octal integer strict mode fixes
Richard van Velzen [Sun, 17 Jul 2016 16:17:33 +0000 (18:17 +0200)]
Build with AppVeyor on windows
homuler [Sat, 16 Jul 2016 13:03:36 +0000 (22:03 +0900)]
Fix the document of keep_fnames option
Yotam Spenser [Wed, 6 Jul 2016 10:02:07 +0000 (13:02 +0300)]
Source map URL override from programmatic API
Lauri Pokka [Mon, 4 Jul 2016 17:06:14 +0000 (02:06 +0900)]
lib/sourcemap.js: Copy sourceContent from old souce-map to the new source-map. Should fix #882
Anthony Van de Gejuchte [Thu, 14 Jul 2016 16:43:50 +0000 (18:43 +0200)]
Keep const in own scope while compressing
- Fixes #1205
- Fix provided by @kzc
kzc [Wed, 13 Jul 2016 15:44:28 +0000 (11:44 -0400)]
Fix mangle with option keep_fnames=true for Safari.
Fixes: #1202
Anthony Van de Gejuchte [Mon, 4 Jul 2016 00:51:20 +0000 (02:51 +0200)]
Fix error style for regex errors
Anthony Van de Gejuchte [Sun, 3 Jul 2016 22:51:09 +0000 (00:51 +0200)]
Backport mocha with test from harmony
Richard van Velzen [Sun, 3 Jul 2016 19:46:14 +0000 (21:46 +0200)]
v2.7.0
Anthony Van de Gejuchte [Wed, 15 Jun 2016 10:18:18 +0000 (12:18 +0200)]
Don't convert all strings to directives from moz-ast
Richard van Velzen [Mon, 20 Jun 2016 14:57:40 +0000 (16:57 +0200)]
Introduce a test that tests the --self build
kzc [Thu, 30 Jun 2016 20:54:52 +0000 (16:54 -0400)]
Document that the smallest sequences optimization length is 2
and a sequences value of 1 is considered to be `true` - which
will be set to the default value of 200.
kzc [Thu, 30 Jun 2016 18:56:12 +0000 (14:56 -0400)]
Change the default sequences limit to 200 to speed up compress.
Has little or no impact on minification size in the majority of
cases but can speed up rollup builds significantly.
This sequences change also has the beneficial side effect of avoiding
"stack size exceeded" errors on very large input files.
The user is free to alter the sequences limit if they are so inclined.
The previous sequences limit was 2000. 20 is often sufficient.
kzc [Sun, 26 Jun 2016 21:16:02 +0000 (17:16 -0400)]
Allow sequences maximum length to be user configurable.
Geraint [Mon, 27 Jun 2016 11:01:21 +0000 (12:01 +0100)]
Allow input files to be map (url->filename)
Anthony Van de Gejuchte [Mon, 13 Jun 2016 10:36:47 +0000 (12:36 +0200)]
Various LineTerminator changes
* Escaped newlines should also produce SyntaxError
* Fix multiline comment parsing and add tests
* Adapt makePredicate to handle \u2028 and \u2029
* Move up nlb check in regex so it's checked before any escape handling
* Change error messages to conform ecma standard
* Find_eol not recornizing \u2028 and \u2029 as line terminator
* Remove \u180e as it is removed in unicode 6.3.0 from the category zs
kzc [Thu, 30 Jun 2016 04:24:34 +0000 (00:24 -0400)]
Enable --screw-ie8 by default.
catch identifier is mangled correctly for ES5 standards-compliant JS engines by default.
Unconditionally use the ie8 if/do-while workaround whether or not --screw-ie8 is enabled.
To support non-standard ie8 javascript use: uglifyjs --support-ie8
iliashk [Sat, 25 Jun 2016 08:48:39 +0000 (11:48 +0300)]
Add Node API documentation for mangling options
kzc [Thu, 23 Jun 2016 16:54:38 +0000 (12:54 -0400)]
Fix spidermonkey AST (ESTree) export and import, Array holes
Fixes: #1156 #1161
Also add test to exercise Uglify after spidermonkey export/import of itself.
Anthony Van de Gejuchte [Thu, 23 Jun 2016 14:53:48 +0000 (16:53 +0200)]
Move OctalEscapeSequence to read_escape_char
This should simplify and improve implementation, make it easier to
implement template strings, and keep master a bit more in sync with
harmony.
Previous implementation wasn't broken, though the loop gave me the
impression it could read infinite numbers and annoyed me a bit. It was
also slightly unnecessary because the lookup involved only 3 characters.
Richard van Velzen [Wed, 22 Jun 2016 10:24:31 +0000 (12:24 +0200)]
v2.6.4
Mihai Bazon [Tue, 21 Jun 2016 20:14:05 +0000 (23:14 +0300)]
Merge pull request #1155 from kzc/issue_1154
Fix conditional expressions of form (x ? -1 : -1)
kzc [Tue, 21 Jun 2016 18:52:13 +0000 (14:52 -0400)]
Fix conditional expressions of form (x ? -1 : -1)
Fixes #1154, #1153
kzc [Sun, 19 Jun 2016 03:06:59 +0000 (23:06 -0400)]
Don't replace undefined, NaN and Infinity within with scope
Anthony Van de Gejuchte [Mon, 20 Jun 2016 12:18:47 +0000 (14:18 +0200)]
Keep master in sync with harmony
* Do not mangle when no mangle is required
* Improve use_asm reset while printing code
Richard van Velzen [Mon, 20 Jun 2016 06:39:46 +0000 (08:39 +0200)]
Don't assume DEBUG is defined when exporting --self
Potential fix for #1148
Richard van Velzen [Sun, 19 Jun 2016 19:56:06 +0000 (21:56 +0200)]
v2.6.3
Asia [Sat, 18 Jun 2016 20:17:51 +0000 (22:17 +0200)]
Document the except option to mangle
Added documentation for the `except` option to the `mangle` option in the API reference.
Shrey Banga [Thu, 5 May 2016 20:44:59 +0000 (13:44 -0700)]
Respect quote style in object literals
The option added in
fbbaa42ee55a7f753f7cab9b1a905ccf73cf26d5 wasn't
being respected inside object literals, so quoted property names would
still be stripped out with this option.
This is mostly a corner-case, but useful when the output is passed to
something like the Closure compiler, where quoted property names can be
used to prevent mangling.
Anthony Van de Gejuchte [Sat, 18 Jun 2016 15:28:22 +0000 (17:28 +0200)]
Normalize error messages
Anthony Van de Gejuchte [Mon, 13 Jun 2016 19:11:08 +0000 (21:11 +0200)]
Don't mix strings with directives in output
* Don't interpret strings with escaped content as directive
* Don't interpret strings after empty statement as directive
* Adapt output to prevent strings being represent as directive
* Introduce UGLIFY_DEBUG to allow internal testing like EXPECT_DIRECTIVE
Anthony Van de Gejuchte [Mon, 13 Jun 2016 16:19:06 +0000 (18:19 +0200)]
Fix test262 failures related to <, <=, in and instanceof
Fixed-by: @kzc
Anthony Van de Gejuchte [Sun, 12 Jun 2016 15:34:05 +0000 (17:34 +0200)]
Re-add parens after new expression in beautify mode
Anthony Van de Gejuchte [Sun, 12 Jun 2016 16:58:20 +0000 (18:58 +0200)]
Don't allow with statements in strict mode
Anthony Van de Gejuchte [Fri, 10 Jun 2016 13:42:55 +0000 (15:42 +0200)]
Stop dropping args in new expressions
Richard van Velzen [Sun, 12 Jun 2016 12:35:43 +0000 (14:35 +0200)]
Fix octal string strict mode tests
David Bau [Mon, 23 Dec 2013 16:05:04 +0000 (16:05 +0000)]
Escape null characters as \0 unless followed by 0-7.
Anthony Van de Gejuchte [Thu, 9 Jun 2016 22:34:20 +0000 (00:34 +0200)]
Don't drop unused if scope uses with statement
Fix provided by @kzc
Anthony Van de Gejuchte [Fri, 20 May 2016 08:25:35 +0000 (10:25 +0200)]
Throw errors in strict mode for octal strings
Adds a directive tracker for the parser/tokenizer to
allow parsing depending on directive context.