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

11 years agomore constant folding (for names defined with `const`)
Mihai Bazon [Tue, 2 Oct 2012 09:45:17 +0000 (12:45 +0300)]
more constant folding (for names defined with `const`)

11 years agoadd AST_SymbolConst for names defined with `const`
Mihai Bazon [Tue, 2 Oct 2012 09:22:39 +0000 (12:22 +0300)]
add AST_SymbolConst for names defined with `const`

11 years agodrop more unused names
Mihai Bazon [Tue, 2 Oct 2012 09:02:33 +0000 (12:02 +0300)]
drop more unused names

11 years agoa shy attempt to obey `width` in the beautifier; added `bracketize` option to always...
Mihai Bazon [Tue, 2 Oct 2012 08:00:47 +0000 (11:00 +0300)]
a shy attempt to obey `width` in the beautifier; added `bracketize` option to always print brackets around if/do/while/for statements; export more options via the CLI

11 years agominor
Mihai Bazon [Fri, 28 Sep 2012 08:12:47 +0000 (11:12 +0300)]
minor

11 years agofix mangling
Mihai Bazon [Wed, 26 Sep 2012 20:54:30 +0000 (23:54 +0300)]
fix mangling

(bug in our code prevented the mangler from using a name that was in use
prior to mangling but not after it)

11 years agoremoved the "squeeze" method (it's now effectively "transform")
Mihai Bazon [Wed, 26 Sep 2012 16:52:32 +0000 (19:52 +0300)]
removed the "squeeze" method (it's now effectively "transform")

11 years agosome speedup and more savings from unused vars that have side effects in initialization
Mihai Bazon [Wed, 26 Sep 2012 13:43:14 +0000 (16:43 +0300)]
some speedup and more savings from unused vars that have side effects in initialization

11 years agocompressor successfully moved to TreeTransformer
Mihai Bazon [Wed, 26 Sep 2012 10:04:54 +0000 (13:04 +0300)]
compressor successfully moved to TreeTransformer

11 years agocheckpoint (refactoring, WIP)
Mihai Bazon [Wed, 26 Sep 2012 09:16:16 +0000 (12:16 +0300)]
checkpoint (refactoring, WIP)

11 years agominor
Mihai Bazon [Wed, 26 Sep 2012 08:24:04 +0000 (11:24 +0300)]
minor

11 years agomore cleanups
Mihai Bazon [Tue, 25 Sep 2012 15:03:31 +0000 (18:03 +0300)]
more cleanups

11 years agomoving code around (refactoring, WIP)
Mihai Bazon [Tue, 25 Sep 2012 12:59:27 +0000 (15:59 +0300)]
moving code around (refactoring, WIP)

11 years agodiscard all \uFEFF characters (https://github.com/mishoo/UglifyJS/issues/462)
Mihai Bazon [Tue, 25 Sep 2012 12:30:59 +0000 (15:30 +0300)]
discard all \uFEFF characters (https://github.com/mishoo/UglifyJS/issues/462)

11 years agostarted some refactoring (WIP) -- moving squeezer to TreeTransformer
Mihai Bazon [Tue, 25 Sep 2012 12:15:47 +0000 (15:15 +0300)]
started some refactoring (WIP) -- moving squeezer to TreeTransformer

11 years agominor
Mihai Bazon [Tue, 25 Sep 2012 09:48:36 +0000 (12:48 +0300)]
minor

11 years agoit's not safe to assume that property access is side-effect-free
Mihai Bazon [Tue, 25 Sep 2012 07:32:14 +0000 (10:32 +0300)]
it's not safe to assume that property access is side-effect-free

(getters/setters + various browser bugs will trigger side effects; also, an
exception is thrown when the expression is undefined)

11 years agosome boolean cleanup
Mihai Bazon [Tue, 25 Sep 2012 07:31:03 +0000 (10:31 +0300)]
some boolean cleanup

11 years agoSupport input source map
Mihai Bazon [Mon, 24 Sep 2012 14:02:18 +0000 (17:02 +0300)]
Support input source map

This is useful while compressing generated code; for example compressing JS
compiled by CoffeeScript (assuming you got a source map):

    uglifyjs2 --in-source-map generated.js.map \
              --source-map uglified.js.map \
              -o uglified.js

The above assumes you have a "generated.js.map" file which is the source
mapping between your CoffeeScript and the generated.js (compiled output from
CoffeeScript).  The name of the input file is not present in this example;
it will be fetched from the source map (but it can be passed manually too).

The output will be in "uglified.js" and the output map "uglified.js.map"
will actually map to the original CoffeeScript code, rather than to
generated.js.

12 years agominor tests fix
Mihai Bazon [Mon, 24 Sep 2012 07:27:49 +0000 (10:27 +0300)]
minor tests fix

12 years agoproperly drop mutually-referring declarations that are not otherwise
Mihai Bazon [Sun, 23 Sep 2012 09:47:34 +0000 (12:47 +0300)]
properly drop mutually-referring declarations that are not otherwise
referenced and have no side effects

12 years agotree transformer api (WIP)
Mihai Bazon [Sat, 22 Sep 2012 10:32:32 +0000 (13:32 +0300)]
tree transformer api (WIP)

12 years agolog filename in parse errors / compressor warnings
Mihai Bazon [Fri, 21 Sep 2012 11:38:52 +0000 (14:38 +0300)]
log filename in parse errors / compressor warnings

12 years agobetter support for multiple input files:
Mihai Bazon [Fri, 21 Sep 2012 11:19:05 +0000 (14:19 +0300)]
better support for multiple input files:

- use a single AST_Toplevel node for all files
- keep original source filename in the tokens

12 years agomore on detecting side effects
Mihai Bazon [Fri, 21 Sep 2012 08:23:44 +0000 (11:23 +0300)]
more on detecting side effects

12 years agodrop unused variables
Mihai Bazon [Wed, 19 Sep 2012 09:27:38 +0000 (12:27 +0300)]
drop unused variables

12 years agosupport -c with no arguments to disable compression entirely
Mihai Bazon [Wed, 19 Sep 2012 07:22:36 +0000 (10:22 +0300)]
support -c with no arguments to disable compression entirely

12 years agofixed label scope/mangling
Mihai Bazon [Tue, 18 Sep 2012 16:26:46 +0000 (19:26 +0300)]
fixed label scope/mangling

12 years agominor
Mihai Bazon [Tue, 18 Sep 2012 11:17:23 +0000 (14:17 +0300)]
minor

12 years agosupport for directives
Mihai Bazon [Tue, 18 Sep 2012 10:21:09 +0000 (13:21 +0300)]
support for directives

12 years agoadded AST_NaN (output as 0/0)
Mihai Bazon [Tue, 18 Sep 2012 07:53:46 +0000 (10:53 +0300)]
added AST_NaN (output as 0/0)

12 years agoonly do the typeof x == "undefined" optimization if x is a symbol reference and it...
Mihai Bazon [Mon, 17 Sep 2012 17:02:14 +0000 (20:02 +0300)]
only do the typeof x == "undefined" optimization if x is a symbol reference and it's declared in scope, or x is not a symbol reference.

12 years agomoved `typeof foo == "undefined"` ==> `foo === undefined` under `--unsafe`
Mihai Bazon [Mon, 17 Sep 2012 15:49:52 +0000 (18:49 +0300)]
moved `typeof foo == "undefined"` ==> `foo === undefined` under `--unsafe`

because https://github.com/mishoo/UglifyJS2/commit/43fd45154bac89b89330e13bd1f167e2a927a23c#commitcomment-1864505

12 years agofix .undeclared (it's now a function)
Mihai Bazon [Mon, 17 Sep 2012 12:06:06 +0000 (15:06 +0300)]
fix .undeclared (it's now a function)

12 years agominor
Mihai Bazon [Mon, 17 Sep 2012 11:33:36 +0000 (14:33 +0300)]
minor

12 years agoone more test for sequences
Mihai Bazon [Mon, 17 Sep 2012 09:53:52 +0000 (12:53 +0300)]
one more test for sequences

12 years agopossible optimization for AST_Undefined
Mihai Bazon [Mon, 17 Sep 2012 09:24:21 +0000 (12:24 +0300)]
possible optimization for AST_Undefined

if undefined is defined, ;-), we replace AST_Undefined nodes to a reference
to the "undefined" variable; in turn the mangler will compress it to a
single letter; this helps at least on jQuery.

12 years agoempty block to empty statement: {} ==> ;
Mihai Bazon [Mon, 17 Sep 2012 09:03:02 +0000 (12:03 +0300)]
empty block to empty statement: {} ==> ;

12 years agomore smallish optimizations
Mihai Bazon [Mon, 17 Sep 2012 08:50:35 +0000 (11:50 +0300)]
more smallish optimizations

12 years agotry negating AST_Binary
Mihai Bazon [Mon, 17 Sep 2012 08:16:44 +0000 (11:16 +0300)]
try negating AST_Binary

12 years agosome cleanup
Mihai Bazon [Sun, 16 Sep 2012 15:05:15 +0000 (18:05 +0300)]
some cleanup

12 years agomore sequencesizing (WIP)
Mihai Bazon [Sun, 16 Sep 2012 13:29:17 +0000 (16:29 +0300)]
more sequencesizing (WIP)

12 years agodrop unused function
Mihai Bazon [Sun, 16 Sep 2012 12:46:47 +0000 (15:46 +0300)]
drop unused function

12 years agorewrite handle_if_return
Mihai Bazon [Sun, 16 Sep 2012 12:46:20 +0000 (15:46 +0300)]
rewrite handle_if_return

optimizations of if/return/continue seem to be even better now

12 years agoother small optimization:
Mihai Bazon [Sat, 15 Sep 2012 13:06:09 +0000 (16:06 +0300)]
other small optimization:

if (foo) continue;
...body...

==>

if (!foo) { ...body ... }

Only when the parent block is the target loop of the `continue` statement.

12 years agofigure out label targets
Mihai Bazon [Sat, 15 Sep 2012 13:05:01 +0000 (16:05 +0300)]
figure out label targets

12 years agojoin_vars:
Mihai Bazon [Sat, 15 Sep 2012 07:54:59 +0000 (10:54 +0300)]
join_vars:

var XXX;
for (var YYY; ...)

==>

for (var XXX,YYY; ...)

12 years agocompress typeof x == "undefined" to x === undefined, which further gets
Mihai Bazon [Fri, 14 Sep 2012 16:56:59 +0000 (19:56 +0300)]
compress typeof x == "undefined" to x === undefined, which further gets
shortened to x === void 0 (or x === [][0] in unsafe mode)

12 years agominor
Mihai Bazon [Fri, 14 Sep 2012 16:04:18 +0000 (19:04 +0300)]
minor

when unsafe, compress undefined as [][0]

12 years agoadding an imaginary "return undefined" can sometimes help
Mihai Bazon [Fri, 14 Sep 2012 13:26:30 +0000 (16:26 +0300)]
adding an imaginary "return undefined" can sometimes help

function f() {
  if (foo) return x();
  if (!bar) return y();
}

==>

function f() {
  return foo ? x() : bar ? void 0 : y();
}

12 years agomore optimizations that v1 does and some cleanups
Mihai Bazon [Fri, 14 Sep 2012 12:36:38 +0000 (15:36 +0300)]
more optimizations that v1 does and some cleanups

- a = a + x ==> a+=x
- joining consecutive var statements (hoisting is not always desirable)
- x == false ==> x == 0, x != true ==> x != 1
- x, x ==> x; x = exp(), x ==> x = exp()
- discarding useless break-s

12 years agoadded -m and -c options
Mihai Bazon [Thu, 13 Sep 2012 16:45:16 +0000 (19:45 +0300)]
added -m and -c options

12 years agofew more optimizations:
Mihai Bazon [Thu, 13 Sep 2012 12:20:57 +0000 (15:20 +0300)]
few more optimizations:

- do multiple passes in tighten_body if it was changed
- transform if (foo) return x; return y; ==> return foo?x:y
- don't optimize !0 as true (use best_of after evaluation of constant expr)

With hoist_vars off we now beat UglifyJS v1 on jQuery-1.8.1

12 years agominor
Mihai Bazon [Wed, 12 Sep 2012 13:29:20 +0000 (16:29 +0300)]
minor

12 years agomore AST_If optimizations
Mihai Bazon [Wed, 12 Sep 2012 13:10:03 +0000 (16:10 +0300)]
more AST_If optimizations

12 years agoside effect fixes and small optimization for gzip
Mihai Bazon [Wed, 12 Sep 2012 10:23:24 +0000 (13:23 +0300)]
side effect fixes and small optimization for gzip

prefer to always use > and >= operators (idea from Closure)

12 years agofixed run-tests and an issue about reversing the condition in AST_If
Mihai Bazon [Wed, 12 Sep 2012 10:00:13 +0000 (13:00 +0300)]
fixed run-tests and an issue about reversing the condition in AST_If

12 years agominor
Mihai Bazon [Tue, 11 Sep 2012 15:37:08 +0000 (18:37 +0300)]
minor

12 years agofixed some mess with symbols/scope
Mihai Bazon [Tue, 11 Sep 2012 12:42:28 +0000 (15:42 +0300)]
fixed some mess with symbols/scope

- all symbols now have a `thedef` property which is a SymbolDef object,
  instead of the `uniq` that we had before (pointing to the first occurrence
  of the name as declaration).

- for undeclared symbols we still create a SymbolDef object in the toplevel
  scope but mark it "undeclared"

- we can now call figure_out_scope after squeezing, which is useful in order
  not to mangle names that were dropped by the squeezer

12 years agocheckpoint
Mihai Bazon [Tue, 11 Sep 2012 10:15:55 +0000 (13:15 +0300)]
checkpoint

- discard statements with no side effects (unsafe? could be)
- safer hoist_vars (needs some revamping of scope/mangling)

12 years agohoist_vars is pretty bad, it seems. cancelled it for now.
Mihai Bazon [Mon, 10 Sep 2012 19:40:18 +0000 (22:40 +0300)]
hoist_vars is pretty bad, it seems.  cancelled it for now.

12 years agoadaptive base54 digits depending on char frequency (WIP)
Mihai Bazon [Mon, 10 Sep 2012 15:25:52 +0000 (18:25 +0300)]
adaptive base54 digits depending on char frequency (WIP)

12 years agomore progress on the compressor (WIP)
Mihai Bazon [Mon, 10 Sep 2012 12:54:17 +0000 (15:54 +0300)]
more progress on the compressor (WIP)

12 years agofix "file" in the source map
Mihai Bazon [Mon, 10 Sep 2012 12:52:53 +0000 (15:52 +0300)]
fix "file" in the source map

12 years agominor
Mihai Bazon [Sat, 8 Sep 2012 14:03:09 +0000 (17:03 +0300)]
minor

12 years agofix output for division followed by regexp
Mihai Bazon [Sat, 8 Sep 2012 12:38:58 +0000 (15:38 +0300)]
fix output for division followed by regexp

( v1 report: https://github.com/mishoo/UglifyJS/pull/458 )

12 years agocheckpoint
Mihai Bazon [Fri, 7 Sep 2012 15:55:13 +0000 (18:55 +0300)]
checkpoint

12 years agofix bug (forgot arg name)
Mihai Bazon [Fri, 7 Sep 2012 13:02:08 +0000 (16:02 +0300)]
fix bug (forgot arg name)

12 years agoalways keep declarations found in unreachable code
Mihai Bazon [Fri, 7 Sep 2012 12:18:32 +0000 (15:18 +0300)]
always keep declarations found in unreachable code

a few more tests and some cleanups.