UglifyJS.git
11 years agofixes #189: use dotted member access when --screw-ie8 option given
Michael Ficarra [Sat, 20 Apr 2013 20:11:05 +0000 (15:11 -0500)]
fixes #189: use dotted member access when --screw-ie8 option given

11 years agoFix typeof evaluation for regex and function
Roman Bataev [Thu, 4 Apr 2013 02:34:38 +0000 (22:34 -0400)]
Fix typeof evaluation for regex and function

11 years agoAdd tests for typeof evaluation
Roman Bataev [Thu, 4 Apr 2013 02:34:19 +0000 (22:34 -0400)]
Add tests for typeof evaluation

11 years agoQuote objects with numeric keys
Vladimir Zhuravlev [Sun, 31 Mar 2013 13:55:11 +0000 (20:55 +0700)]
Quote objects with numeric keys

11 years agofix package.json
Mihai Bazon [Sun, 31 Mar 2013 10:38:02 +0000 (13:38 +0300)]
fix package.json

11 years agoDon't use \xYY for identifiers
Mihai Bazon [Sun, 31 Mar 2013 10:35:29 +0000 (13:35 +0300)]
Don't use \xYY for identifiers

Fix #173

11 years agoOutput, to_ascii: Escape non-ascii chars with \xnn instead of \unnnn whenever possible.
Andreas Lind Petersen [Sun, 31 Mar 2013 09:07:31 +0000 (11:07 +0200)]
Output, to_ascii: Escape non-ascii chars with \xnn instead of \unnnn whenever possible.

11 years agouglifyjs binary: Make read_whole_file async and don't attempt to read STDIN synchrono...
Andreas Lind Petersen [Sun, 31 Mar 2013 09:51:43 +0000 (11:51 +0200)]
uglifyjs binary: Make read_whole_file async and don't attempt to read STDIN synchronously.

11 years agoMerge pull request #163 from mzgol/screw-oldie
Mihai Bazon [Mon, 25 Mar 2013 16:05:44 +0000 (09:05 -0700)]
Merge pull request #163 from mzgol/screw-oldie

renamed --screw-ie to --screw-oldie, documented it in README.md, indicat...

11 years agorenamed --screw-ie to --screw-ie8, documented it in README.md, indicated it doesn...
Michał Gołębiowski [Mon, 25 Mar 2013 15:11:07 +0000 (16:11 +0100)]
renamed --screw-ie to --screw-ie8, documented it in README.md, indicated it doesn't break IE9+

11 years agoAdd support for enclose option. Closes #139.
Jake Harding [Fri, 1 Mar 2013 05:21:14 +0000 (21:21 -0800)]
Add support for enclose option. Closes #139.

11 years agoDon't print the warning on parse error, just throw a JS_Parse_Error.
Mihai Bazon [Sat, 23 Mar 2013 22:57:35 +0000 (00:57 +0200)]
Don't print the warning on parse error, just throw a JS_Parse_Error.

Fix #159

11 years agoKeep legit code working even when --screw-ie is not passed.
Mihai Bazon [Fri, 22 Mar 2013 16:02:08 +0000 (18:02 +0200)]
Keep legit code working even when --screw-ie is not passed.

Previously:

    Without `--screw-ie`, UglifyJS would always leak names of function
    expressions into the containing scope, as if they were function
    declarations.  That was to emulate IE<9 behavior.  Code relying on this
    IE bug would continue to work properly after mangling, although it would
    only work in IE (since other engines don't share the bug).  Sometimes
    this broke legitimage code (see #153 and #155).

    With `--screw-ie` the names would not be leaked into the current scope,
    working properly in legit cases; but still it broke legit code when
    running in IE<9 (see #24).

Currently:

    Regardless of the `--screw-ie` setting, the names will not be leaked.
    Code relying on the IE bug will not work properly after mangling.
    <evil laughter here>

    Without `--screw-ie`: a hack has been added to the mangler to avoid
    using the same name for a function expression and some other variable in
    the same scope.  This keeps legit code working, at the (negligible,
    indeed) cost of one more identifier.

    With `--screw-ie` you allow the mangler to name function expressions
    with the same identifier as another variable in scope.  After mangling
    code might break in IE<9.

Oh man, the commit message is longer than the patch.

Fix #153, #155

11 years agoMerge pull request #125 from devongovett/master
Mihai Bazon [Wed, 13 Mar 2013 08:36:55 +0000 (01:36 -0700)]
Merge pull request #125 from devongovett/master

Allow inSourceMap option to be a generated JSON source map

11 years agoSupport mangling toplevel names
Mihai Bazon [Wed, 13 Mar 2013 07:44:06 +0000 (09:44 +0200)]
Support mangling toplevel names

Close #127

11 years agoDisable `unsafe` by default
Mihai Bazon [Sun, 10 Mar 2013 22:04:31 +0000 (00:04 +0200)]
Disable `unsafe` by default

Close #147

11 years agoMerge pull request #146 from mbostock/read-all-stdin
Mihai Bazon [Wed, 6 Mar 2013 06:17:09 +0000 (22:17 -0800)]
Merge pull request #146 from mbostock/read-all-stdin

Read the entire STDIN.

11 years agoRead the entire STDIN.
Mike Bostock [Wed, 6 Mar 2013 04:35:49 +0000 (20:35 -0800)]
Read the entire STDIN.

The problem with reading synchronously from /dev/stdin is that you can get a
spurious EOF when the input buffer is empty, even if more content is coming. Now
STDIN is read from a loop, and only stops polling when all input has been read.
This fixes #70 #85 and other errors related to parsing large files on STDIN.

11 years agoFix reordering comparisons
Mihai Bazon [Mon, 4 Mar 2013 08:06:01 +0000 (10:06 +0200)]
Fix reordering comparisons

Close #143

11 years agoAdd `--screw-ie` option
Mihai Bazon [Sat, 2 Mar 2013 12:28:34 +0000 (14:28 +0200)]
Add `--screw-ie` option

For now the implication is that UglifyJS will not leak a function
expression's name in the surrounding scope (IE < 9 does that).

(ref. mishoo/UglifyJS#485)

11 years agoDrop last `default:` if it's the last branch and empty
Mihai Bazon [Fri, 1 Mar 2013 11:12:03 +0000 (13:12 +0200)]
Drop last `default:` if it's the last branch and empty

Close #141

11 years agoCompress boolean constants after evaluation
Mihai Bazon [Fri, 1 Mar 2013 08:26:06 +0000 (10:26 +0200)]
Compress boolean constants after evaluation

Close #137

11 years agoAdd license
Mihai Bazon [Fri, 22 Feb 2013 11:58:16 +0000 (13:58 +0200)]
Add license

Close #131

11 years agoFix compressing `do {...} while (false)`
Mihai Bazon [Tue, 19 Feb 2013 16:12:19 +0000 (18:12 +0200)]
Fix compressing `do {...} while (false)`

It's not safe to transform it to {...} because the body might contain
`break`.  The solution could be more elaborate (detect if body contains
`break`) but I don't think it's worth the trouble.

Close #129

11 years agov2.2.5
Mihai Bazon [Thu, 14 Feb 2013 10:51:13 +0000 (12:51 +0200)]
v2.2.5

11 years agoAllow inSourceMap to be a generated JSON source map instead of just a file name
Devon Govett [Sun, 10 Feb 2013 18:06:13 +0000 (10:06 -0800)]
Allow inSourceMap to be a generated JSON source map instead of just a file name

11 years agoForce space after literal regexp when used in "instanceof" or "in"
Mihai Bazon [Wed, 6 Feb 2013 09:57:59 +0000 (11:57 +0200)]
Force space after literal regexp when used in "instanceof" or "in"

Close #118

11 years agoGive up evaluating (unary-prefix '-' 0)
Mihai Bazon [Wed, 6 Feb 2013 09:51:09 +0000 (11:51 +0200)]
Give up evaluating (unary-prefix '-' 0)

Close #117

------

    JS, WHY YOU SUCK SO BADLY? ;-(

11 years agoFix parens for NaN
Mihai Bazon [Wed, 6 Feb 2013 09:38:29 +0000 (11:38 +0200)]
Fix parens for NaN

Close #116

11 years agoFix parens for negative numbers
Mihai Bazon [Wed, 6 Feb 2013 09:36:04 +0000 (11:36 +0200)]
Fix parens for negative numbers

Close #115

11 years agoFix parens for AST_New
Mihai Bazon [Wed, 6 Feb 2013 09:28:49 +0000 (11:28 +0200)]
Fix parens for AST_New

Close #114

11 years agoFix handling of constants
Mihai Bazon [Wed, 6 Feb 2013 09:15:31 +0000 (11:15 +0200)]
Fix handling of constants

Close #113

11 years agoUgly hack to print comments before return/throw statements
Mihai Bazon [Tue, 5 Feb 2013 17:10:33 +0000 (19:10 +0200)]
Ugly hack to print comments before return/throw statements

Close #112

11 years agoMerge pull request #111 from mattrobenolt/safer-sourcemap
Mihai Bazon [Mon, 4 Feb 2013 07:44:31 +0000 (23:44 -0800)]
Merge pull request #111 from mattrobenolt/safer-sourcemap

Wraps sourceMappingURL in a multiline comment. Fixes #108

11 years agoWraps sourceMappingURL in a multiline comment. Fixes #108
Matt Robenolt [Mon, 4 Feb 2013 00:01:01 +0000 (16:01 -0800)]
Wraps sourceMappingURL in a multiline comment. Fixes #108

11 years agov2.2.4
Mihai Bazon [Fri, 1 Feb 2013 11:31:28 +0000 (13:31 +0200)]
v2.2.4

11 years agoFix end token for Assign nodes
Mihai Bazon [Sat, 26 Jan 2013 12:24:54 +0000 (14:24 +0200)]
Fix end token for Assign nodes

11 years agoMerge pull request #94 from paulmillr/patch-1
Mihai Bazon [Fri, 1 Feb 2013 07:50:59 +0000 (23:50 -0800)]
Merge pull request #94 from paulmillr/patch-1

Add better fromstring docs.

11 years agoMerge pull request #106 from gibson042/105
Mihai Bazon [Thu, 24 Jan 2013 13:51:33 +0000 (05:51 -0800)]
Merge pull request #106 from gibson042/105

Fix #105: property comparison to undefined is not always safe

11 years agoFix #105: property comparison to undefined is not always safe
Richard Gibson [Thu, 24 Jan 2013 04:52:04 +0000 (23:52 -0500)]
Fix #105: property comparison to undefined is not always safe

11 years agoAdd --source-map-url option
Mihai Bazon [Sun, 20 Jan 2013 10:32:07 +0000 (12:32 +0200)]
Add --source-map-url option

Fix #100
Fix #47

11 years ago[AST_Hole] the print function can be a no-op.
Mihai Bazon [Thu, 17 Jan 2013 09:16:55 +0000 (11:16 +0200)]
[AST_Hole] the print function can be a no-op.

11 years agoFix output for arrays containing undefined values.
David Glasser [Wed, 16 Jan 2013 19:59:19 +0000 (14:59 -0500)]
Fix output for arrays containing undefined values.

1b6bcca7 was a first attempt at this. That commit made Uglify stop replacing
holes with undefined, but instead it started replacing undefined with
holes. This is slightly problematic, because there is a difference between a
hole and an undefined value. More problematically, it changed [1,undefined] to
[1,] which generally doesn't even parse as a hole (just as a trailing comma), so
it didn't even preserve the length of the array!

Instead, parse holes as their own special AST node which prints invisibly.

11 years agoMerge pull request #98 from ForbesLindesay/patch-1
Mihai Bazon [Thu, 17 Jan 2013 09:08:59 +0000 (01:08 -0800)]
Merge pull request #98 from ForbesLindesay/patch-1

Update installation instructions

11 years agoHandle String() with no arguments.
Mihai Bazon [Thu, 17 Jan 2013 09:01:38 +0000 (11:01 +0200)]
Handle String() with no arguments.

Fix #91

11 years agoUpdate installation instructions re #4
Forbes Lindesay [Thu, 17 Jan 2013 00:13:42 +0000 (00:13 +0000)]
Update installation instructions re #4

11 years agoAdd better fromstring docs.
Paul Miller [Sun, 13 Jan 2013 16:45:43 +0000 (18:45 +0200)]
Add better fromstring docs.

11 years agoMerge pull request #90 from jakearchibald/patch-1
Mihai Bazon [Tue, 8 Jan 2013 22:21:25 +0000 (14:21 -0800)]
Merge pull request #90 from jakearchibald/patch-1

Compressor options use underscores rather than hyphens

11 years agoCompressor options use underscores rather than hyphens
Jake Archibald [Tue, 8 Jan 2013 20:33:58 +0000 (12:33 -0800)]
Compressor options use underscores rather than hyphens

11 years agov2.2.3
Mihai Bazon [Fri, 4 Jan 2013 20:50:53 +0000 (22:50 +0200)]
v2.2.3

11 years agoFix handling of labels in nested scopes
Mihai Bazon [Fri, 4 Jan 2013 12:17:33 +0000 (14:17 +0200)]
Fix handling of labels in nested scopes

11 years agoSupport `output`, `mangle` and `compress` options to `UglifyJS.minify`.
Mihai Bazon [Fri, 4 Jan 2013 09:24:29 +0000 (11:24 +0200)]
Support `output`, `mangle` and `compress` options to `UglifyJS.minify`.

Close #57
Close #86
Close #33

11 years agoMerge pull request #87 from BenoitZugmeyer/master
Mihai Bazon [Thu, 3 Jan 2013 10:28:35 +0000 (02:28 -0800)]
Merge pull request #87 from BenoitZugmeyer/master

Add a --version option

11 years agoSet --version as a boolean #87
Benoît Zugmeyer [Thu, 3 Jan 2013 10:22:37 +0000 (11:22 +0100)]
Set --version as a boolean #87

11 years ago--version option
Benoît Zugmeyer [Thu, 3 Jan 2013 10:06:07 +0000 (11:06 +0100)]
--version option

11 years agoImplement `-m sort=true`
Mihai Bazon [Wed, 2 Jan 2013 10:39:00 +0000 (12:39 +0200)]
Implement `-m sort=true`

close #83

11 years agoAccept string or number as name of an accessor.
Mihai Bazon [Fri, 21 Dec 2012 23:24:04 +0000 (01:24 +0200)]
Accept string or number as name of an accessor.

[not sure I'm happy about this fix]

Reference mishoo/UglifyJS#478

11 years agoOptimize new Array(1, 2, 3) → [1, 2, 3]
Mihai Bazon [Fri, 21 Dec 2012 19:04:15 +0000 (21:04 +0200)]
Optimize new Array(1, 2, 3) â†’ [1, 2, 3]

Close #74

11 years agoFix output when semicolons is off.
Mihai Bazon [Fri, 21 Dec 2012 09:57:08 +0000 (11:57 +0200)]
Fix output when semicolons is off.

(need to force a semicolon for the empty body of an `if`)

Close #72

11 years agoSmall cleanup
Mihai Bazon [Wed, 12 Dec 2012 09:50:03 +0000 (11:50 +0200)]
Small cleanup

11 years agov2.2.2
Mihai Bazon [Thu, 6 Dec 2012 12:25:18 +0000 (14:25 +0200)]
v2.2.2

11 years agoAdd proper parens in "NoIn" expressions.
Mihai Bazon [Thu, 6 Dec 2012 10:27:57 +0000 (12:27 +0200)]
Add proper parens in "NoIn" expressions.

fix #60.

11 years agosmall improvement on merging assignments into hoisted vars
Mihai Bazon [Wed, 5 Dec 2012 11:14:49 +0000 (13:14 +0200)]
small improvement on merging assignments into hoisted vars

11 years agoWhen hoisting variables, try to merge in assignments that follow.
Mihai Bazon [Wed, 5 Dec 2012 10:30:25 +0000 (12:30 +0200)]
When hoisting variables, try to merge in assignments that follow.

11 years agoRevert "Fixed reading from STDIN."
Mihai Bazon [Fri, 30 Nov 2012 09:33:50 +0000 (11:33 +0200)]
Revert "Fixed reading from STDIN."

It breaks usage like this:

    echo '...code...' | uglifyjs

This reverts commit e48802ad291fae5a16f2d23cbd25a0c433cdbe48.

11 years agoAdd test for issue #59
Mihai Bazon [Fri, 30 Nov 2012 09:26:37 +0000 (11:26 +0200)]
Add test for issue #59

11 years agoDon't messup compressor stack while optimizing Switch
Mihai Bazon [Fri, 30 Nov 2012 09:16:09 +0000 (11:16 +0200)]
Don't messup compressor stack while optimizing Switch

Fix #59

11 years agoMerge pull request #58 from roxeteer/master
Mihai Bazon [Thu, 29 Nov 2012 09:23:07 +0000 (01:23 -0800)]
Merge pull request #58 from roxeteer/master

Fixed reading from STDIN

11 years agoFixed reading from STDIN.
Visa Kopu [Thu, 29 Nov 2012 08:51:15 +0000 (10:51 +0200)]
Fixed reading from STDIN.

11 years agofix #55
Mihai Bazon [Sat, 24 Nov 2012 08:02:08 +0000 (10:02 +0200)]
fix #55

11 years agov2.2.1
Mihai Bazon [Fri, 23 Nov 2012 08:25:44 +0000 (10:25 +0200)]
v2.2.1

11 years agofix for https://github.com/mishoo/UglifyJS/issues/474
Mihai Bazon [Fri, 23 Nov 2012 08:20:00 +0000 (10:20 +0200)]
fix for https://github.com/mishoo/UglifyJS/issues/474

11 years agorename the npm package to "uglify-js" and cli tool to "uglifyjs"
Mihai Bazon [Wed, 21 Nov 2012 11:27:03 +0000 (13:27 +0200)]
rename the npm package to "uglify-js" and cli tool to "uglifyjs"

11 years agofix #51
Mihai Bazon [Sun, 18 Nov 2012 15:37:45 +0000 (17:37 +0200)]
fix #51

11 years agoretain (1,eval) as is when it's the expression of an AST_Call
Mihai Bazon [Sat, 17 Nov 2012 10:05:31 +0000 (12:05 +0200)]
retain (1,eval) as is when it's the expression of an AST_Call

otherwise we change the meaning of eval from global to lexical.

11 years agoAdd support for somewhat preserving line numbers.
Richard van Velzen [Wed, 14 Nov 2012 13:04:47 +0000 (14:04 +0100)]
Add support for somewhat preserving line numbers.

Usage: uglifyjs2 -b "beautify=0,preserve_line=1" /path/to/js

ref #46

11 years agobetter solution for the last test in constant switch folding
Mihai Bazon [Wed, 14 Nov 2012 10:21:43 +0000 (12:21 +0200)]
better solution for the last test in constant switch folding

11 years agooptimize constant switch blocks
Mihai Bazon [Wed, 14 Nov 2012 10:06:07 +0000 (12:06 +0200)]
optimize constant switch blocks

ref. mishoo/UglifyJS#441

11 years agoMerge branch 'optimize_concat' of https://github.com/rvanvelzen/UglifyJS2 into rvanve...
Mihai Bazon [Tue, 13 Nov 2012 12:34:38 +0000 (14:34 +0200)]
Merge branch 'optimize_concat' of https://github.com/rvanvelzen/UglifyJS2 into rvanvelzen-optimize_concat

11 years agodon't change order in binary expressions if both operands have side effects
Mihai Bazon [Tue, 13 Nov 2012 12:32:07 +0000 (14:32 +0200)]
don't change order in binary expressions if both operands have side effects

11 years agoAdd simple optimization for empty-string concats.
Richard van Velzen [Mon, 12 Nov 2012 14:41:03 +0000 (15:41 +0100)]
Add simple optimization for empty-string concats.

ref. #43

11 years agov2.1.11
Mihai Bazon [Mon, 12 Nov 2012 11:24:52 +0000 (13:24 +0200)]
v2.1.11

11 years agofix invalid AST produced by dropping unused variable
Mihai Bazon [Mon, 12 Nov 2012 11:23:57 +0000 (13:23 +0200)]
fix invalid AST produced by dropping unused variable

close #44

11 years agoMerge pull request #41 from Skalman/toString-patch
Mihai Bazon [Mon, 12 Nov 2012 08:47:56 +0000 (00:47 -0800)]
Merge pull request #41 from Skalman/toString-patch

Convert x.toString() to ""+x instead of x+""

11 years agoconvert x.toString() to ""+x instead of x+""
Dan Wolff [Sun, 11 Nov 2012 13:53:34 +0000 (15:53 +0200)]
convert x.toString() to ""+x instead of x+""

In some places this can save one byte in whitespace, e.g. after return.
Example:

function f(arg) {
        // return""+arg - no space between return and ""
        return arg.toString();
}

11 years agodeclare dependency versions
Mihai Bazon [Fri, 9 Nov 2012 14:43:49 +0000 (16:43 +0200)]
declare dependency versions

close #40

11 years agoAST_LabelRef no longer inherits from AST_SymbolRef
Mihai Bazon [Thu, 8 Nov 2012 13:39:14 +0000 (15:39 +0200)]
AST_LabelRef no longer inherits from AST_SymbolRef

11 years agov2.1.10
Mihai Bazon [Thu, 8 Nov 2012 10:33:27 +0000 (12:33 +0200)]
v2.1.10

11 years agofix API breakage
Mihai Bazon [Thu, 8 Nov 2012 10:31:28 +0000 (12:31 +0200)]
fix API breakage

close #36, #38

11 years agooptimization for if/break as first statement in a loop body
Mihai Bazon [Wed, 7 Nov 2012 16:57:51 +0000 (18:57 +0200)]
optimization for if/break as first statement in a loop body

    for(...; x; ...) if (y) break; â†’ for(...; x&&!y; ...);

similarly for `while` and some combinations (i.e. the `break` appears in the
`else` clause, etc.)

11 years agoignore node_modules/
Mihai Bazon [Wed, 7 Nov 2012 13:27:12 +0000 (15:27 +0200)]
ignore node_modules/

11 years agov2.1.9
Mihai Bazon [Wed, 7 Nov 2012 11:31:58 +0000 (13:31 +0200)]
v2.1.9

11 years agofix another small regression
Mihai Bazon [Wed, 7 Nov 2012 11:31:43 +0000 (13:31 +0200)]
fix another small regression

we do need parens here: `new (foo.bar().baz)`, but not here: `new foo.bar.baz`

11 years agov2.1.8
Mihai Bazon [Wed, 7 Nov 2012 11:03:11 +0000 (13:03 +0200)]
v2.1.8

11 years agofix regression from 5346fb94 (shouldn't parenthesize i++ in x[i++])
Mihai Bazon [Wed, 7 Nov 2012 11:02:51 +0000 (13:02 +0200)]
fix regression from 5346fb94 (shouldn't parenthesize i++ in x[i++])

11 years agov2.1.7
Mihai Bazon [Wed, 7 Nov 2012 10:45:23 +0000 (12:45 +0200)]
v2.1.7

11 years agoadd AST_Accessor and AST_SymbolAccessor node types
Mihai Bazon [Wed, 7 Nov 2012 10:43:27 +0000 (12:43 +0200)]
add AST_Accessor and AST_SymbolAccessor node types

AST_Accessor will represent the function for a setter or getter.  Since they
are not mangleable, and they should not introduce a name in scope, we have a
new node for their name (AST_SymbolAccessor) which doesn't inherit from
AST_SymbolDeclaration.

fix #37

11 years agoparenthesize property access when it's the expression in New
Mihai Bazon [Wed, 7 Nov 2012 10:26:33 +0000 (12:26 +0200)]
parenthesize property access when it's the expression in New

refs #35

11 years agofurther fix for parens around New (refs #35)
Mihai Bazon [Wed, 7 Nov 2012 09:49:06 +0000 (11:49 +0200)]
further fix for parens around New (refs #35)

11 years agoparenthesize a Call expression when its parent is New
Mihai Bazon [Wed, 7 Nov 2012 09:36:15 +0000 (11:36 +0200)]
parenthesize a Call expression when its parent is New

fix #35