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

11 years agocripple scope to make IE happy :-(
Mihai Bazon [Thu, 25 Oct 2012 15:52:35 +0000 (18:52 +0300)]
cripple scope to make IE happy :-(

close #24

11 years agotest for fs.existsSync
Mihai Bazon [Thu, 25 Oct 2012 07:58:48 +0000 (10:58 +0300)]
test for fs.existsSync

11 years agov2.1.3
Mihai Bazon [Wed, 24 Oct 2012 06:41:40 +0000 (09:41 +0300)]
v2.1.3

11 years agofix for `if (...) return; else return ...;`
Mihai Bazon [Wed, 24 Oct 2012 06:33:32 +0000 (09:33 +0300)]
fix for `if (...) return; else return ...;`

(it was assumed that the first `return` always contains a value)

close #22

11 years agomore sequence optimizations (lift some sequences above binary/unary expressions so...
Mihai Bazon [Mon, 22 Oct 2012 08:49:58 +0000 (11:49 +0300)]
more sequence optimizations (lift some sequences above binary/unary expressions so that we can avoid parens)

11 years agov2.1.2
Mihai Bazon [Mon, 22 Oct 2012 04:57:28 +0000 (07:57 +0300)]
v2.1.2

11 years agoMerge branch 'master' of github.com:mishoo/UglifyJS2
Mihai Bazon [Sat, 20 Oct 2012 08:14:25 +0000 (11:14 +0300)]
Merge branch 'master' of github.com:mishoo/UglifyJS2

11 years agoalternate hack to disable deprecation warning
Mihai Bazon [Sat, 20 Oct 2012 08:12:21 +0000 (11:12 +0300)]
alternate hack to disable deprecation warning

ref #9, close #20

11 years agoMerge pull request #19 from SevInf/master
Mihai Bazon [Fri, 19 Oct 2012 11:29:40 +0000 (04:29 -0700)]
Merge pull request #19 from SevInf/master

Allow to specify sourceRoot in minify

11 years agominor fix for dropping unused definitions.
Mihai Bazon [Fri, 19 Oct 2012 09:57:29 +0000 (12:57 +0300)]
minor fix for dropping unused definitions.

    function f(x, y) {
        var g = function() { return h() };
        var h = function() { return g() };
        return x + y;
    }

now compresses to `function f(x, y) { return x + y }`

11 years agoAdd sourceRoot option to minify
Sergej Tatarincev [Fri, 19 Oct 2012 09:35:19 +0000 (12:35 +0300)]
Add sourceRoot option to minify

11 years agoadd fromString argument to `UglifyJS.minify` (allows to pass the source
Mihai Bazon [Thu, 18 Oct 2012 12:49:15 +0000 (15:49 +0300)]
add fromString argument to `UglifyJS.minify` (allows to pass the source
code, instead of file names, as first argument).

close #17

11 years agomore optimizations for some break/continue cases
Mihai Bazon [Thu, 18 Oct 2012 12:14:57 +0000 (15:14 +0300)]
more optimizations for some break/continue cases

11 years agov2.1.1
Mihai Bazon [Thu, 18 Oct 2012 07:54:30 +0000 (10:54 +0300)]
v2.1.1

11 years agofix `--comments` (close #16)
Mihai Bazon [Thu, 18 Oct 2012 07:54:10 +0000 (10:54 +0300)]
fix `--comments` (close #16)

11 years agov2.1.0
Mihai Bazon [Wed, 17 Oct 2012 19:00:11 +0000 (22:00 +0300)]
v2.1.0

11 years agoadded note about API docs and online demo
Mihai Bazon [Wed, 17 Oct 2012 18:59:36 +0000 (21:59 +0300)]
added note about API docs and online demo

11 years agomore small optimizations
Mihai Bazon [Wed, 17 Oct 2012 18:57:08 +0000 (21:57 +0300)]
more small optimizations

(unlikely to help for hand-written code)

11 years agodefine aborts on AST_If: true if both branches abort
Mihai Bazon [Wed, 17 Oct 2012 13:17:14 +0000 (16:17 +0300)]
define aborts on AST_If: true if both branches abort

11 years agoemploy a better parser for command-line arguments
Mihai Bazon [Wed, 17 Oct 2012 12:56:45 +0000 (15:56 +0300)]
employ a better parser for command-line arguments

to support passing commas in strings in for example:

    uglifyjs2 -cd TEST="'a,b'" <<EOF
    console.log(TEST);
    EOF

    â†’ console.log("a,b")

close #14

11 years agothe `sort` option is broken anyway, removed it
Mihai Bazon [Wed, 17 Oct 2012 12:24:47 +0000 (15:24 +0300)]
the `sort` option is broken anyway, removed it

we need to mangle names from outermost to innermost scope; mangling names
from inner scopes before we got to the outer scope won't work correctly,
therefore sorting doesn't make sense.

11 years agoadd `semicolons` option in the code generator (default: `true`)
Mihai Bazon [Wed, 17 Oct 2012 11:51:27 +0000 (14:51 +0300)]
add `semicolons` option in the code generator (default: `true`)

pass `false` to separate statements with newlines instead of semicolons

11 years agofix small glitches in source map generation
Mihai Bazon [Tue, 16 Oct 2012 12:54:12 +0000 (15:54 +0300)]
fix small glitches in source map generation

11 years agodisable warnings in the test suite
Mihai Bazon [Sat, 13 Oct 2012 12:18:11 +0000 (15:18 +0300)]
disable warnings in the test suite

11 years agodrop unused function arguments
Mihai Bazon [Sat, 13 Oct 2012 12:04:44 +0000 (15:04 +0300)]
drop unused function arguments

also add test for "drop_unused" (the last one fails for now)

11 years agoadd parens to AST_Seq whose parent is AST_Unary
Mihai Bazon [Sat, 13 Oct 2012 11:32:08 +0000 (14:32 +0300)]
add parens to AST_Seq whose parent is AST_Unary

11 years agofix compressing benchmark.js (it tried to evaluate a statement)
Mihai Bazon [Sat, 13 Oct 2012 09:56:56 +0000 (12:56 +0300)]
fix compressing benchmark.js (it tried to evaluate a statement)

the following code in benchmark.js triggered the issue:

    support.decompilation = Function(
      'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')'
    )()(0).x === '1';

technically that could be resolved into a constant expression, but seems
it's being used here for browser bugs detection :-\

11 years agominor
Mihai Bazon [Sat, 13 Oct 2012 09:42:01 +0000 (12:42 +0300)]
minor

11 years agofix regression from fb5c01c073d06034815d5f3b782fd11cbdf6d6f5
Mihai Bazon [Sat, 13 Oct 2012 09:24:27 +0000 (12:24 +0300)]
fix regression from fb5c01c073d06034815d5f3b782fd11cbdf6d6f5

is_digit takes a char code now, not a string

11 years agofix end tokens in spidermonkey ast import
Mihai Bazon [Sat, 13 Oct 2012 08:37:58 +0000 (11:37 +0300)]
fix end tokens in spidermonkey ast import

11 years agoupdate for acorn
Mihai Bazon [Fri, 12 Oct 2012 21:35:24 +0000 (00:35 +0300)]
update for acorn

11 years agominor
Mihai Bazon [Fri, 12 Oct 2012 11:55:54 +0000 (14:55 +0300)]
minor

11 years agoactually enable the option that drops unused names in the test of issue #12
Mihai Bazon [Fri, 12 Oct 2012 08:41:48 +0000 (11:41 +0300)]
actually enable the option that drops unused names in the test of issue #12