UglifyJS.git
7 years agoFix (typeof side_effect()) in boolean context
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

7 years agoOptimize unmodified variables
alexlamsl [Tue, 20 Sep 2016 14:23:27 +0000 (22:23 +0800)]
Optimize unmodified variables

8 years agoMake all comment options in cli available in js api
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.

8 years agoMerge pull request #1277 from kzc/fix-string-plus-opt
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

8 years agoAccount 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

8 years agoimplement optimization: (x = 2 * x) ---> (x *= 2)
kzc [Fri, 26 Aug 2016 22:47:25 +0000 (18:47 -0400)]
implement optimization: (x = 2 * x) ---> (x *= 2)

8 years agov2.7.3
Richard van Velzen [Wed, 17 Aug 2016 18:34:27 +0000 (20:34 +0200)]
v2.7.3

8 years agoFix negate_iife transform to return a correct tree for nested IIFEs
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

8 years agov2.7.2
Richard van Velzen [Wed, 17 Aug 2016 06:51:23 +0000 (08:51 +0200)]
v2.7.2

8 years agoFix negate_iife regression #1254
kzc [Wed, 17 Aug 2016 01:54:54 +0000 (21:54 -0400)]
Fix negate_iife regression #1254

8 years agov2.7.1
Richard van Velzen [Sun, 14 Aug 2016 20:02:01 +0000 (22:02 +0200)]
v2.7.1

8 years agoAdd missing `{` in README
Timothy Gu [Fri, 12 Aug 2016 01:21:21 +0000 (18:21 -0700)]
Add missing `{` in README

Also fix a trivial style mistake.

8 years agoFix --mangle-props and --mangle-props=unquoted
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.

8 years agoAdditional object literal property tests
kzc [Sat, 30 Jul 2016 17:21:23 +0000 (13:21 -0400)]
Additional object literal property tests

8 years agoAdd input file glob support to minify()
kzc [Sat, 30 Jul 2016 01:27:30 +0000 (21:27 -0400)]
Add input file glob support to minify()

8 years agoAdd simple file globbing to bin/uglifyjs for Windows
kzc [Fri, 29 Jul 2016 20:18:56 +0000 (16:18 -0400)]
Add simple file globbing to bin/uglifyjs for Windows

8 years agoMoved test input files to test/input.
Lucas Wiener [Thu, 28 Jul 2016 07:30:12 +0000 (09:30 +0200)]
Moved test input files to test/input.

8 years agoAdded test for #1236
Lucas Wiener [Wed, 27 Jul 2016 14:02:33 +0000 (16:02 +0200)]
Added test for #1236

8 years agoFixed sourceMapIncludeSources and inSourceMap = string combination of the UglifyJS...
Lucas Wiener [Tue, 26 Jul 2016 07:54:02 +0000 (09:54 +0200)]
Fixed sourceMapIncludeSources and inSourceMap = string combination of the UglifyJS.minify function.

8 years agoFix unneeded parens around unary args in new expression.
kzc [Sat, 23 Jul 2016 15:50:44 +0000 (11:50 -0400)]
Fix unneeded parens around unary args in new expression.

8 years agoTest reparsing test/compress/*.js output
kzc [Fri, 22 Jul 2016 14:44:29 +0000 (10:44 -0400)]
Test reparsing test/compress/*.js output

8 years agoLegacy octal integer strict mode fixes
Anthony Van de Gejuchte [Thu, 21 Jul 2016 01:19:24 +0000 (03:19 +0200)]
Legacy octal integer strict mode fixes

8 years agoBuild with AppVeyor on windows
Richard van Velzen [Sun, 17 Jul 2016 16:17:33 +0000 (18:17 +0200)]
Build with AppVeyor on windows

8 years agoFix the document of keep_fnames option
homuler [Sat, 16 Jul 2016 13:03:36 +0000 (22:03 +0900)]
Fix the document of keep_fnames option

8 years agoSource map URL override from programmatic API
Yotam Spenser [Wed, 6 Jul 2016 10:02:07 +0000 (13:02 +0300)]
Source map URL override from programmatic API

8 years agolib/sourcemap.js: Copy sourceContent from old souce-map to the new source-map. Should...
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

8 years agoKeep const in own scope while compressing
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

8 years agoFix mangle with option keep_fnames=true for Safari.
kzc [Wed, 13 Jul 2016 15:44:28 +0000 (11:44 -0400)]
Fix mangle with option keep_fnames=true for Safari.

Fixes: #1202

8 years agoFix error style for regex errors
Anthony Van de Gejuchte [Mon, 4 Jul 2016 00:51:20 +0000 (02:51 +0200)]
Fix error style for regex errors

8 years agoBackport mocha with test from harmony
Anthony Van de Gejuchte [Sun, 3 Jul 2016 22:51:09 +0000 (00:51 +0200)]
Backport mocha with test from harmony

8 years agov2.7.0
Richard van Velzen [Sun, 3 Jul 2016 19:46:14 +0000 (21:46 +0200)]
v2.7.0

8 years agoDon't convert all strings to directives from moz-ast
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

8 years agoIntroduce a test that tests the --self build
Richard van Velzen [Mon, 20 Jun 2016 14:57:40 +0000 (16:57 +0200)]
Introduce a test that tests the --self build

8 years agoDocument that the smallest sequences optimization length is 2
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.

8 years agoChange the default sequences limit to 200 to speed up compress.
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.

8 years agoAllow sequences maximum length to be user configurable.
kzc [Sun, 26 Jun 2016 21:16:02 +0000 (17:16 -0400)]
Allow sequences maximum length to be user configurable.

8 years agoAllow input files to be map (url->filename)
Geraint [Mon, 27 Jun 2016 11:01:21 +0000 (12:01 +0100)]
Allow input files to be map (url->filename)

8 years agoVarious LineTerminator changes
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

8 years agoEnable --screw-ie8 by default.
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

8 years agoAdd Node API documentation for mangling options
iliashk [Sat, 25 Jun 2016 08:48:39 +0000 (11:48 +0300)]
Add Node API documentation for mangling options

8 years agoFix spidermonkey AST (ESTree) export and import, Array holes
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.

8 years agoMove OctalEscapeSequence to read_escape_char
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.

8 years agov2.6.4
Richard van Velzen [Wed, 22 Jun 2016 10:24:31 +0000 (12:24 +0200)]
v2.6.4

8 years agoMerge pull request #1155 from kzc/issue_1154
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)

8 years agoFix 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

8 years agoDon't replace undefined, NaN and Infinity within with scope
kzc [Sun, 19 Jun 2016 03:06:59 +0000 (23:06 -0400)]
Don't replace undefined, NaN and Infinity within with scope

8 years agoKeep master in sync with harmony
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

8 years agoDon't assume DEBUG is defined when exporting --self
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

8 years agov2.6.3
Richard van Velzen [Sun, 19 Jun 2016 19:56:06 +0000 (21:56 +0200)]
v2.6.3

8 years agoDocument the except option to mangle
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.

8 years agoRespect quote style in object literals
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.

8 years agoNormalize error messages
Anthony Van de Gejuchte [Sat, 18 Jun 2016 15:28:22 +0000 (17:28 +0200)]
Normalize error messages

8 years agoDon't mix strings with directives in output
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

8 years agoFix test262 failures related to <, <=, in and instanceof
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
8 years agoRe-add parens after new expression in beautify mode
Anthony Van de Gejuchte [Sun, 12 Jun 2016 15:34:05 +0000 (17:34 +0200)]
Re-add parens after new expression in beautify mode

8 years agoDon't allow with statements in strict mode
Anthony Van de Gejuchte [Sun, 12 Jun 2016 16:58:20 +0000 (18:58 +0200)]
Don't allow with statements in strict mode

8 years agoStop dropping args in new expressions
Anthony Van de Gejuchte [Fri, 10 Jun 2016 13:42:55 +0000 (15:42 +0200)]
Stop dropping args in new expressions

8 years agoFix octal string strict mode tests
Richard van Velzen [Sun, 12 Jun 2016 12:35:43 +0000 (14:35 +0200)]
Fix octal string strict mode tests

8 years agoEscape null characters as \0 unless followed by 0-7.
David Bau [Mon, 23 Dec 2013 16:05:04 +0000 (16:05 +0000)]
Escape null characters as \0 unless followed by 0-7.

8 years agoDon't drop unused if scope uses with statement
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

8 years agoThrow errors in strict mode for octal strings
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.

8 years agoCatch errors when compression test fails to parse
Anthony Van de Gejuchte [Wed, 8 Jun 2016 18:11:32 +0000 (20:11 +0200)]
Catch errors when compression test fails to parse

8 years agoFix uglify attempting to rewrite invalid new expressions
Anthony Van de Gejuchte [Mon, 6 Jun 2016 23:33:13 +0000 (01:33 +0200)]
Fix uglify attempting to rewrite invalid new expressions

8 years agoExport tokenizer function
ChALkeR [Tue, 7 Jun 2016 09:25:16 +0000 (12:25 +0300)]
Export tokenizer function

In uglify-js@1, both parser and tokenizer methods were exported

This allows to use tokenizer() separately, e.g. to wrap or override it, as
parse() method accepts not only text, but also tokenized functions.

8 years agoDo not allow newlines in regex
Anthony Van de Gejuchte [Sun, 5 Jun 2016 00:44:59 +0000 (02:44 +0200)]
Do not allow newlines in regex

8 years agocollapse_vars: Do not consider RegExp literals to be constants
kzc [Thu, 26 May 2016 18:47:16 +0000 (14:47 -0400)]
collapse_vars: Do not consider RegExp literals to be constants

Fixes #1100

8 years agoOptimize if_return for single if/return cases.
kzc [Sun, 22 May 2016 15:35:41 +0000 (11:35 -0400)]
Optimize if_return for single if/return cases.

Fixes #1089

8 years agoCompletely allow evaluating -0
Richard van Velzen [Wed, 18 May 2016 16:49:55 +0000 (18:49 +0200)]
Completely allow evaluating -0

8 years agoNever produce -0 when evaluating expressions (like -"")
Richard van Velzen [Tue, 17 May 2016 20:34:38 +0000 (22:34 +0200)]
Never produce -0 when evaluating expressions (like -"")

Fix for #1085. The major case was already there, but more expressions can result in -0.

8 years agoSimplify iife `new` fix
kzc [Sun, 15 May 2016 23:12:17 +0000 (19:12 -0400)]
Simplify iife `new` fix

as suggested by @rvanvelzen.

Added a test for IIFEs in nested contexts.

8 years agoDo not apply negate_iife optimization to `new` expression
kzc [Mon, 9 May 2016 07:19:28 +0000 (03:19 -0400)]
Do not apply negate_iife optimization to `new` expression

8 years agoRetain comments before AST_Constants during mangle.
kzc [Tue, 3 May 2016 19:08:40 +0000 (15:08 -0400)]
Retain comments before AST_Constants during mangle.

8 years agoFix regression causing tests to fail on windows
Anthony Van de Gejuchte [Tue, 3 May 2016 15:41:40 +0000 (17:41 +0200)]
Fix regression causing tests to fail on windows

8 years agoWorkaround for process.exit() tty output truncation.
kzc [Sun, 1 May 2016 04:59:29 +0000 (00:59 -0400)]
Workaround for process.exit() tty output truncation.

Fixes #1055

8 years agoAdd node 6 to travis
Anthony Van de Gejuchte [Tue, 26 Apr 2016 17:20:37 +0000 (19:20 +0200)]
Add node 6 to travis

8 years agoHandle CR line endings in comments.
kzc [Mon, 25 Apr 2016 04:42:18 +0000 (00:42 -0400)]
Handle CR line endings in comments.

Fixes #1050

8 years agoMerge pull request #1053 from rvanvelzen/hoist_if_return_funs
Mihai Bazon [Tue, 26 Apr 2016 19:09:52 +0000 (22:09 +0300)]
Merge pull request #1053 from rvanvelzen/hoist_if_return_funs

Hoist functions when reversing if (x) return; ... vs. if (!x) ...

8 years agoAdd test cases for slightly more esoteric cases
Richard van Velzen [Tue, 26 Apr 2016 09:49:55 +0000 (11:49 +0200)]
Add test cases for slightly more esoteric cases

8 years agoAdd test case for hoisting a single function
Richard van Velzen [Tue, 26 Apr 2016 09:43:03 +0000 (11:43 +0200)]
Add test case for hoisting a single function

8 years agoHoist functions when reversing if (x) return; ... vs. if (!x) ...
Richard van Velzen [Sat, 23 Apr 2016 21:48:33 +0000 (23:48 +0200)]
Hoist functions when reversing if (x) return; ... vs. if (!x) ...

Fixes #1052

8 years agoAdd `passes` compress option. Fix duplicate compress warnings.
kzc [Tue, 12 Apr 2016 13:19:38 +0000 (09:19 -0400)]
Add `passes` compress option. Fix duplicate compress warnings.

8 years agoParse comments without recursion to avoid RangeError.
kzc [Fri, 15 Apr 2016 23:58:46 +0000 (19:58 -0400)]
Parse comments without recursion to avoid RangeError.

Fixes #993

8 years agoPrevent endless recursion when evaluating self-referencing consts
Richard van Velzen [Tue, 12 Apr 2016 18:30:44 +0000 (20:30 +0200)]
Prevent endless recursion when evaluating self-referencing consts

Fix #1041

8 years agoAdd base54.reset() to compress tests
Richard van Velzen [Tue, 12 Apr 2016 18:08:09 +0000 (20:08 +0200)]
Add base54.reset() to compress tests

Without this reset, char counts bleed to next tests. One test had a bad expect clause.

8 years agoActually limit sequence length.
Mihai Bazon [Tue, 12 Apr 2016 11:15:14 +0000 (14:15 +0300)]
Actually limit sequence length.

Fix #1038

8 years agoFix warnings for referenced non-hoisted functions.
kzc [Sun, 10 Apr 2016 19:41:38 +0000 (15:41 -0400)]
Fix warnings for referenced non-hoisted functions.

Fixes #1034

Also added `expect_warnings` functionality to test framework.

8 years agoMerge pull request #1032 from kzc/member
Mihai Bazon [Thu, 7 Apr 2016 21:32:14 +0000 (00:32 +0300)]
Merge pull request #1032 from kzc/member

Simplify member(name, array) implementation.

8 years agoSimplify member(name, array) implementation.
kzc [Thu, 7 Apr 2016 13:57:30 +0000 (09:57 -0400)]
Simplify member(name, array) implementation.

8 years agoAvoid using inherited hasOwnProperty
Mihai Bazon [Thu, 7 Apr 2016 10:15:28 +0000 (13:15 +0300)]
Avoid using inherited hasOwnProperty

Fix #1031

8 years agoOptimize ternaries with boolean consequent or alternative.
kzc [Sat, 2 Apr 2016 04:21:13 +0000 (00:21 -0400)]
Optimize ternaries with boolean consequent or alternative.

Fixes #511

8 years agoSpeedup `unused` compress option for already minified code
kzc [Mon, 28 Mar 2016 21:58:50 +0000 (17:58 -0400)]
Speedup `unused` compress option for already minified code

Fixes: #321 #917 #1022

8 years agoadded documentation on conditional compilation using API
Sebastien Daniel [Fri, 4 Mar 2016 12:32:24 +0000 (07:32 -0500)]
added documentation on conditional compilation using API

8 years agoMerge pull request #1011 from kzc/dont-produce-let-in-mangle
Mihai Bazon [Thu, 24 Mar 2016 16:16:26 +0000 (18:16 +0200)]
Merge pull request #1011 from kzc/dont-produce-let-in-mangle

Do not produce `let` as a variable name in mangle.

8 years agoMerge pull request #1019 from kzc/escape-ascii-only
Mihai Bazon [Thu, 24 Mar 2016 16:08:57 +0000 (18:08 +0200)]
Merge pull request #1019 from kzc/escape-ascii-only

Escape all ASCII control characters within strings for ascii_only

8 years agoEscape all ASCII control characters within strings when using ascii_only.
kzc [Thu, 24 Mar 2016 15:51:54 +0000 (11:51 -0400)]
Escape all ASCII control characters within strings when using ascii_only.

Fixes #1017.

Tab characters within strings are now output as `\t` in all output modes.

8 years agoAttempt to increase timeout for mocha let test.
kzc [Tue, 15 Mar 2016 15:44:09 +0000 (11:44 -0400)]
Attempt to increase timeout for mocha let test.

8 years agoDo not produce `let` as a variable name in mangle.
kzc [Tue, 15 Mar 2016 15:20:32 +0000 (11:20 -0400)]
Do not produce `let` as a variable name in mangle.
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986.

8 years agoFix: Uglified Number.prototype functions on big numbers
philippsimon [Mon, 14 Mar 2016 11:21:25 +0000 (12:21 +0100)]
Fix: Uglified Number.prototype functions on big numbers

8 years ago#877 Ignore mangle sort option
kzc [Sat, 27 Feb 2016 20:33:10 +0000 (15:33 -0500)]
#877 Ignore mangle sort option

8 years agov2.6.2
Mihai Bazon [Mon, 22 Feb 2016 19:39:14 +0000 (21:39 +0200)]
v2.6.2