UglifyJS.git
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 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

11 years agoadd proper parens around unary expressions
Mihai Bazon [Wed, 7 Nov 2012 09:23:17 +0000 (11:23 +0200)]
add proper parens around unary expressions

fix #34

11 years agoadd option to mangle names even if eval/with is in use
Mihai Bazon [Tue, 6 Nov 2012 09:39:41 +0000 (11:39 +0200)]
add option to mangle names even if eval/with is in use

(for more fair comparison to Closure compiler)

11 years agodiscard the hack that worked around the deprecation warning
Mihai Bazon [Mon, 5 Nov 2012 20:23:51 +0000 (22:23 +0200)]
discard the hack that worked around the deprecation warning

(since the source-map module no longer uses require.js)

refs #9

11 years agoconvert `while` into `for`
Mihai Bazon [Mon, 5 Nov 2012 14:01:20 +0000 (16:01 +0200)]
convert `while` into `for`

11 years agominor
Mihai Bazon [Mon, 5 Nov 2012 14:01:09 +0000 (16:01 +0200)]
minor

11 years agominor optimization
Mihai Bazon [Mon, 5 Nov 2012 11:13:06 +0000 (13:13 +0200)]
minor optimization

for `==` or `!=` against a constant, prefer to display the constant first.
should help a bit after gzip, i.e.:

    typeof foo=="undefined"
    ^^^^^^    ^^^^^^^^^^^^^

vs:

    "undefined"==typeof foo
    ^^^^^^^^^^^^^^^^^^^     (longer sequence that could repeat)

idea stolen from closure.

11 years agoprint final semicolon
Mihai Bazon [Mon, 5 Nov 2012 11:09:39 +0000 (13:09 +0200)]
print final semicolon

close #28

11 years agouse a Dictionary object instead of plain object for hashes
Mihai Bazon [Fri, 2 Nov 2012 08:58:45 +0000 (10:58 +0200)]
use a Dictionary object instead of plain object for hashes

to mitigate the `__proto__` issue

related to #30

11 years agov2.1.6
Mihai Bazon [Thu, 1 Nov 2012 14:55:10 +0000 (16:55 +0200)]
v2.1.6

11 years agoit's safe to negate expression in !EXP only in boolean context
Mihai Bazon [Thu, 1 Nov 2012 13:49:05 +0000 (15:49 +0200)]
it's safe to negate expression in !EXP only in boolean context

#kendo

11 years agoadded unsafe_comps for negating `<=` with `>`
Mihai Bazon [Thu, 1 Nov 2012 13:14:56 +0000 (15:14 +0200)]
added unsafe_comps for negating `<=` with `>`

since it has the potential to break code, let's keep it disabled by default

11 years agofix compressing UnaryPrefix
Mihai Bazon [Thu, 1 Nov 2012 11:35:08 +0000 (13:35 +0200)]
fix compressing UnaryPrefix

only try negating the expression if the operator is `!`

#kendo

11 years agov2.1.5
Mihai Bazon [Tue, 30 Oct 2012 12:51:05 +0000 (14:51 +0200)]
v2.1.5

11 years agodon't move expressions containing the binary `in` operator into the `for` initializer
Mihai Bazon [Tue, 30 Oct 2012 12:50:47 +0000 (14:50 +0200)]
don't move expressions containing the binary `in` operator into the `for` initializer

(opera can't parse it)

close #25

11 years agov2.1.4
Mihai Bazon [Thu, 25 Oct 2012 15:52:49 +0000 (18:52 +0300)]
v2.1.4