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

11 years agoremove the $self hack
Mihai Bazon [Fri, 12 Oct 2012 08:07:35 +0000 (11:07 +0300)]
remove the $self hack

operations are destructive anyway, so there's no point to clone the nodes in
the transformer.  speed++

11 years agoadd test for issue #12
Mihai Bazon [Fri, 12 Oct 2012 07:49:48 +0000 (10:49 +0300)]
add test for issue #12

11 years agofix in_boolean_context() (two tests were broken)
Mihai Bazon [Fri, 12 Oct 2012 07:49:41 +0000 (10:49 +0300)]
fix in_boolean_context() (two tests were broken)

11 years agouse AST_Lambda for object setters/getters
Mihai Bazon [Fri, 12 Oct 2012 07:11:01 +0000 (10:11 +0300)]
use AST_Lambda for object setters/getters

so that the optimization that drops the name if unused doesn't apply.
close #12

11 years agofix pos in syntax error exception
Mihai Bazon [Thu, 11 Oct 2012 12:25:38 +0000 (15:25 +0300)]
fix pos in syntax error exception

11 years agostealing more hacks from acorn in the name of speed
Mihai Bazon [Thu, 11 Oct 2012 10:00:58 +0000 (13:00 +0300)]
stealing more hacks from acorn in the name of speed

11 years agousing makeComparator from acorn to generate functions that tests whether a
Mihai Bazon [Thu, 11 Oct 2012 08:52:05 +0000 (11:52 +0300)]
using makeComparator from acorn to generate functions that tests whether a
string is keyword, reserved etc.

speeds up the parser a bit, though not spectacular.. still far from acorn.

11 years agocleanup
Mihai Bazon [Thu, 11 Oct 2012 08:07:42 +0000 (11:07 +0300)]
cleanup

- use prototype-less objects where feasible (minor speed improvement)
- get rid of HOP

11 years agofix propagation of symbol references
Mihai Bazon [Thu, 11 Oct 2012 07:28:48 +0000 (10:28 +0300)]
fix propagation of symbol references

11 years agodisable warnings by default in `minify` (pass warnings: true to enable)
Mihai Bazon [Thu, 11 Oct 2012 06:30:22 +0000 (09:30 +0300)]
disable warnings by default in `minify` (pass warnings: true to enable)

close #11

11 years agofix node name
Mihai Bazon [Wed, 10 Oct 2012 20:16:40 +0000 (23:16 +0300)]
fix node name

11 years agoseems cleaner if AST_Label doesn't inherit from AST_SymbolDeclaration
Mihai Bazon [Wed, 10 Oct 2012 08:37:51 +0000 (11:37 +0300)]
seems cleaner if AST_Label doesn't inherit from AST_SymbolDeclaration

11 years agosmall improvements in wrap_commonjs:
Mihai Bazon [Wed, 10 Oct 2012 08:28:05 +0000 (11:28 +0300)]
small improvements in wrap_commonjs:

- use MAP.splice instead of a BlockStatement to inject code (avoids some
  warnings in the linter)
- use the original symbol in exports, so that we get the proper source mapping

11 years agodrop unused variable
Mihai Bazon [Wed, 10 Oct 2012 08:27:06 +0000 (11:27 +0300)]
drop unused variable

11 years agoadd `--lint` and display {file} in scope_warnings
Mihai Bazon [Wed, 10 Oct 2012 08:26:59 +0000 (11:26 +0300)]
add `--lint` and display {file} in scope_warnings

11 years agominor
Mihai Bazon [Tue, 9 Oct 2012 19:56:59 +0000 (22:56 +0300)]
minor

11 years agoupdate on @cc_on
Mihai Bazon [Tue, 9 Oct 2012 16:09:11 +0000 (19:09 +0300)]
update on @cc_on

11 years agoadd AST_Infinity node
Mihai Bazon [Tue, 9 Oct 2012 15:35:53 +0000 (18:35 +0300)]
add AST_Infinity node

11 years agomake `--comments` keep @cc_on too
Mihai Bazon [Tue, 9 Oct 2012 15:25:00 +0000 (18:25 +0300)]
make `--comments` keep @cc_on too

11 years agoadded $propdoc to AST nodes and some cleanups
Mihai Bazon [Tue, 9 Oct 2012 13:25:45 +0000 (16:25 +0300)]
added $propdoc to AST nodes and some cleanups

hopefully we can make the AST documentation self-generating

11 years agominor AST cleanup (AST_BlockStatement may inherit from AST_Block)
Mihai Bazon [Tue, 9 Oct 2012 10:52:32 +0000 (13:52 +0300)]
minor AST cleanup (AST_BlockStatement may inherit from AST_Block)

11 years agoadd `--ast-help`
Mihai Bazon [Tue, 9 Oct 2012 10:21:21 +0000 (13:21 +0300)]
add `--ast-help`

displays a rather cruel description of the AST classes, derived
directly from the node definitions.

11 years agofix detecting symbols in use
Mihai Bazon [Tue, 9 Oct 2012 10:13:55 +0000 (13:13 +0300)]
fix detecting symbols in use

11 years agoMerge pull request #8 from SevInf/master
Mihai Bazon [Tue, 9 Oct 2012 10:04:33 +0000 (03:04 -0700)]
Merge pull request #8 from SevInf/master

Fix crash in minify function

11 years agoFix nodejs minify without inSourceMap exception
Sergej Tatarincev [Tue, 9 Oct 2012 09:52:28 +0000 (12:52 +0300)]
Fix nodejs minify without inSourceMap exception

When inSourceMap is omitted fs.readFile throws exception. Fixed version
calls fs.readFile only when inSourceMap argument is present

11 years agofix `inSourceMap` in `minify` (should read the file)
Mihai Bazon [Mon, 8 Oct 2012 18:22:20 +0000 (21:22 +0300)]
fix `inSourceMap` in `minify` (should read the file)

11 years agoadd simple API wrapper: UglifyJS.minify
Mihai Bazon [Mon, 8 Oct 2012 18:15:47 +0000 (21:15 +0300)]
add simple API wrapper: UglifyJS.minify

(refs #7)

11 years agoadded some basic API doc
Mihai Bazon [Mon, 8 Oct 2012 11:30:34 +0000 (14:30 +0300)]
added some basic API doc

11 years agoshould not expose base54.sort() in the API docs, I think
Mihai Bazon [Mon, 8 Oct 2012 10:37:27 +0000 (13:37 +0300)]
should not expose base54.sort() in the API docs, I think

11 years agoadded --self to easily get a browser-runnable version of UglifyJS
Mihai Bazon [Mon, 8 Oct 2012 09:55:18 +0000 (12:55 +0300)]
added --self to easily get a browser-runnable version of UglifyJS

11 years agoeliminate redundant directives in the same scope
Mihai Bazon [Mon, 8 Oct 2012 09:53:17 +0000 (12:53 +0300)]
eliminate redundant directives in the same scope

11 years agofor certain nodes that we invent we might not have a original source file to
Mihai Bazon [Mon, 8 Oct 2012 09:52:25 +0000 (12:52 +0300)]
for certain nodes that we invent we might not have a original source file to
map from, so just use "?".  and in any case, don't fail hard when addMapping throws.

11 years agofix typo
Mihai Bazon [Fri, 5 Oct 2012 20:10:52 +0000 (23:10 +0300)]
fix typo

11 years agoremove unused code
Mihai Bazon [Fri, 5 Oct 2012 19:59:05 +0000 (22:59 +0300)]
remove unused code

11 years agominor
Mihai Bazon [Fri, 5 Oct 2012 17:24:56 +0000 (20:24 +0300)]
minor

11 years agoreplace `(function(){ ...no side effects ... })()` with `undefined`.
Mihai Bazon [Fri, 5 Oct 2012 13:51:16 +0000 (16:51 +0300)]
replace `(function(){ ...no side effects ... })()` with `undefined`.

11 years agoprevent mangling only when eval is *called*, not when it's just referenced
Mihai Bazon [Fri, 5 Oct 2012 13:17:31 +0000 (16:17 +0300)]
prevent mangling only when eval is *called*, not when it's just referenced

11 years agoadd note about installation
Mihai Bazon [Fri, 5 Oct 2012 12:31:41 +0000 (15:31 +0300)]
add note about installation

11 years agoadded --acorn and --spidermonkey options
Mihai Bazon [Fri, 5 Oct 2012 12:22:12 +0000 (15:22 +0300)]
added --acorn and --spidermonkey options

11 years agofixed import of locations from SpiderMonkey AST
Mihai Bazon [Fri, 5 Oct 2012 12:05:06 +0000 (15:05 +0300)]
fixed import of locations from SpiderMonkey AST

11 years agouse the appropriate constructor for symbols
Mihai Bazon [Thu, 4 Oct 2012 14:28:35 +0000 (17:28 +0300)]
use the appropriate constructor for symbols

11 years agominor
Mihai Bazon [Thu, 4 Oct 2012 14:28:09 +0000 (17:28 +0300)]
minor

11 years agoremoved some unused variables
Mihai Bazon [Thu, 4 Oct 2012 05:49:18 +0000 (08:49 +0300)]
removed some unused variables

11 years agomoving code around
Mihai Bazon [Wed, 3 Oct 2012 18:39:47 +0000 (21:39 +0300)]
moving code around

11 years agodefine AST_Node.from_mozilla_ast(ast)
Mihai Bazon [Wed, 3 Oct 2012 17:03:17 +0000 (20:03 +0300)]
define AST_Node.from_mozilla_ast(ast)

returns an UglifyJS2 AST given a Mozilla AST.  Still needs some work to do
(need to create specific nodes like AST_SymbolRef, AST_SymbolLambda
etc. instead of base AST_Symbol, in order for the mangler/compressor to work
properly)

11 years agoignore tmp/
Mihai Bazon [Wed, 3 Oct 2012 17:01:32 +0000 (20:01 +0300)]
ignore tmp/

11 years agomore cleanup (dropped AST_SwitchBlock)
Mihai Bazon [Wed, 3 Oct 2012 12:52:01 +0000 (15:52 +0300)]
more cleanup (dropped AST_SwitchBlock)

11 years agoAST cleanup (dropped AST_StatementBase)
Mihai Bazon [Wed, 3 Oct 2012 12:41:11 +0000 (15:41 +0300)]
AST cleanup (dropped AST_StatementBase)

11 years agoadded package.json
Mihai Bazon [Wed, 3 Oct 2012 10:19:00 +0000 (13:19 +0300)]
added package.json

11 years agoadded option for side-effect-free statements, fix test
Mihai Bazon [Wed, 3 Oct 2012 10:08:03 +0000 (13:08 +0300)]
added option for side-effect-free statements, fix test

11 years agofix endless loop in tests
Mihai Bazon [Wed, 3 Oct 2012 09:49:47 +0000 (12:49 +0300)]
fix endless loop in tests

11 years agodrop tmp. files
Mihai Bazon [Wed, 3 Oct 2012 09:49:33 +0000 (12:49 +0300)]
drop tmp. files

11 years agodocument the CLI tool
Mihai Bazon [Wed, 3 Oct 2012 09:22:59 +0000 (12:22 +0300)]
document the CLI tool

11 years agofix for `a = !b && !c && !d && !e → a=!(b||c||d||e)`
Mihai Bazon [Wed, 3 Oct 2012 08:34:05 +0000 (11:34 +0300)]
fix for `a = !b && !c && !d && !e → a=!(b||c||d||e)`

11 years agodisable `hoist_vars` by default and change `comparations` to `comparisons`
Mihai Bazon [Wed, 3 Oct 2012 08:27:05 +0000 (11:27 +0300)]
disable `hoist_vars` by default and change `comparations` to `comparisons`

11 years agofixed usage string
Mihai Bazon [Tue, 2 Oct 2012 18:08:16 +0000 (21:08 +0300)]
fixed usage string

11 years agosupport for `--comments` option to keep comments containing @license or @preserve
Mihai Bazon [Tue, 2 Oct 2012 13:40:42 +0000 (16:40 +0300)]
support for `--comments` option to keep comments containing @license or @preserve

11 years agodiscard annoying nodejs warning
Mihai Bazon [Tue, 2 Oct 2012 13:40:01 +0000 (16:40 +0300)]
discard annoying nodejs warning

11 years agoline numbers start at 1
Mihai Bazon [Tue, 2 Oct 2012 13:39:53 +0000 (16:39 +0300)]
line numbers start at 1

11 years agoadded option to keep some comments in the output
Mihai Bazon [Tue, 2 Oct 2012 11:32:30 +0000 (14:32 +0300)]
added option to keep some comments in the output

11 years agooption to exclude certain names from mangling
Mihai Bazon [Tue, 2 Oct 2012 11:02:33 +0000 (14:02 +0300)]
option to exclude certain names from mangling

11 years agosupport defines
Mihai Bazon [Tue, 2 Oct 2012 10:20:07 +0000 (13:20 +0300)]
support defines

11 years ago"use strict";
Mihai Bazon [Tue, 2 Oct 2012 09:45:31 +0000 (12:45 +0300)]
"use strict";