Mihai Bazon
6637c267a5
Fix mozilla-ast after module loading changes
...
Need to explicitly qualify stuff now, since it's not evaluated in some
global scope.
Ref #636
2015-09-24 18:13:21 +03:00
Mihai Bazon
99233c44cc
No longer use vm to load code.
...
Improves performance 2x on node > 0.10.
Ref #636
2015-09-24 17:58:51 +03:00
Mihai Bazon
33528002b4
Fix wrap_commonjs to include code first
...
(code could have directives, i.e. "use strict")
2015-09-24 17:58:51 +03:00
Ville Lautanala
5fd12451f9
Control keeping function arguments with a single option
2015-09-14 19:38:45 +02:00
Richard van Velzen
fcde6109b0
Fix bad parsing of new new x()() constructs
...
Fixes #739
2015-08-27 12:29:36 +03:00
Richard van Velzen
e3bd223dac
Don't change sequences that influence lexical binding in calls
...
Fixes #782
2015-08-25 10:53:35 +02:00
Christopher Chedeau
3ff0b9e0c9
[Fix] --define replaces SymbolRefs in LHS of assignments
...
See #208 for context
2015-08-10 11:22:36 -07:00
Richard van Velzen
759b3f7d6d
Fix mangling of property names which overwrite unmangleable properties
...
Fixes #747 .
2015-08-05 21:18:39 +02:00
Richard van Velzen
66761d7ecf
Fix semicolon printing when restricting max line length
...
Fixes #755
2015-07-30 16:13:32 +02:00
Chris Cowan
9854deb626
Re-use the caught exception's error message in the parse error call.
2015-07-29 15:06:52 +02:00
Chris Cowan
d6814050dd
Give a good error message if an invalid regular expression is found.
2015-07-29 15:05:59 +02:00
thorn0
252fc65558
Advanced way to specify if a function call might have side effects. #400
2015-07-29 14:36:42 +02:00
Mihai Bazon
905b601178
Don't attempt to negate non-boolean AST_Binary
...
Fix #751
2015-07-22 16:55:55 +03:00
Mihai Bazon
63fb2d5a44
Merge pull request #735 from kzc/master
...
optimizations for && and || where left side is constant expression
2015-07-20 09:58:01 +03:00
Mihai Bazon
85a5fc0aeb
Don't drop parens in a * (b * c). Close #744
2015-06-30 10:10:29 +03:00
kzc
f47b2b52a5
operator && and || optimization: add "else" before "if" as intended
2015-06-14 17:44:26 -04:00
kzc
fedb6191a1
optimizations for && and || where left side is constant expression
2015-06-11 23:22:38 -04:00
Joao Carlos
0ac6918a41
Add --mangle-regex option
2015-06-09 14:16:50 +03:00
Mihai Bazon
bce4307e9e
Treat \uFEFF as whitespace.
...
Fix #714
2015-05-20 16:17:46 +03:00
Mihai Bazon
a5b60217ce
Fix compressing conditionals
...
Only transform foo() ? EXP(x) : EXP(y) into EXP(foo() ? x : y) if EXP has no
side effects.
Fix #710
2015-05-18 13:56:04 +03:00
Mihai Bazon
44fd6694eb
fix again reserved props
2015-05-13 22:03:00 +03:00
Mihai Bazon
e48db3a8b6
Make reserved names take priority over the name cache
2015-05-07 15:01:16 +03:00
Mihai Bazon
e637bdaf4e
Only drop the BOM when it's the first character.
...
Close #704
2015-05-05 10:11:38 +03:00
Mihai Bazon
4aed0830e5
Fix blank lines in the output.
...
The issue was more obvious when max_line_len has a small value, rather than
the default 32K characters. A blank line showed up after most statements.
2015-05-04 17:55:42 +03:00
Mihai Bazon
c3a10c135e
Avoid spurious brackets when dropping unused vars
...
Fix #702
2015-05-04 14:49:17 +03:00
Mihai Bazon
92e4340732
Fix parsing strings with literal DOS newlines
...
(should not set newline_before)
Fix #693
2015-04-23 12:08:19 +03:00
Mihai Bazon
7b22f2031f
If name_cache is specified, do rename cached properties
...
(even if --mangle-props is not there)
2015-04-22 17:34:49 +03:00
Mihai Bazon
274e1b3dc7
Drop NaN -> 0/0 transformation.
...
Fix #687
2015-04-17 11:26:36 +03:00
Mihai Bazon
18c63ff3d8
Fix compression of conditionals
...
Don't move the condition on the right side of an assignment when
the left side may have side effects.
Fix #677
2015-04-13 17:29:48 +03:00
Mihai Bazon
e04ef56243
Use the before visitor in mangle props
...
(works around a bug in our tree walker which, while cloning nodes, breaks
references between labeled statements and break/continue labels)
2015-04-10 11:33:29 +03:00
Mihai Bazon
a79ff060d0
Merge branch 'propmangle'
2015-03-29 12:50:43 +03:00
Mihai Bazon
276b9a31cd
Fix compressing ![foo()]; as a statement
...
need to check whether the literal has any side effects before replacing that
with `false`.
2015-03-23 23:27:00 +02:00
Mihai Bazon
5801fa39e9
[sequencesize] Actually even better:
...
do create the sequence even if the stat list is bigger than 2000 statements,
but limit the sequence itself to 2000 expressions.
Ref #414
2015-03-22 13:02:45 +02:00
Mihai Bazon
f0ab1b02e6
Avoid sequencesize for more than 2000 statements.
...
It hardly saves any bytes for a sequence so long, and it risks blowing the
stack with the recursive Seq functions.
Ref #414
2015-03-22 12:51:15 +02:00
Mihai Bazon
36c28e02fd
Add start/end nodes for NaN/Infinity transformations
2015-03-22 12:50:36 +02:00
Mihai Bazon
ecfd881ac6
Keep unused function arguments by default
...
Discarding unused function arguments affects function.length, which can lead
to some hard to debug issues. This optimization is now done only in "unsafe
mode".
Fix #121
2015-03-20 10:28:51 +02:00
Mihai Bazon
80d1c8206b
Fix parsing for U+2028 / U+2029
...
(they should be treated as whitespace)
2015-03-18 10:11:37 +02:00
Mihai Bazon
d36faffeca
Fix parsing for U+2028 / U+2029
...
(they should be treated as whitespace)
2015-03-18 10:09:30 +02:00
Mihai Bazon
aa45f6586e
rename --prop-cache to --name-cache
...
... and support storing there variable names as well, to help with multiple
invocations when mangling toplevel.
2015-03-16 13:16:30 +02:00
Mihai Bazon
0c80d21e01
Fix prop mangling
...
Even if not “defined”, do mangle if name exists in the cache.
2015-03-16 10:53:31 +02:00
Mihai Bazon
ea3430102c
Add property name mangler
...
We only touch properties that are present in an object literal, or which are
assigned to. Example:
x = { foo: 1 };
x.bar = 2;
x["baz"] = 3;
x[cond ? "qwe" : "asd"] = 4;
console.log(x.stuff);
The names "foo", "bar", "baz", "qwe" and "asd" will be mangled, and the
resulting mangled names will be used for the same properties throughout the
code. The "stuff" will not be, since it's just referenced but never
assigned to.
This *will* break most of the code out there, but could work on carefully
written code: do not use eval, do not define methods or properties by
walking an array of names, etc. Also, a comprehensive list of exclusions
needs to be passed, to avoid mangling properties that are standard in
JavaScript, DOM, used in external libraries etc.
2015-03-14 11:22:28 +02:00
Edward Casbon
ae07714927
Add filename to the JS_Parse_Error exception.
...
It would be nice to have access to the filename of the file that includes the code that causes a JavaScript error. This is especially handy if uglifying multiple files at once.
Only a small change is needed for this to happen as it's already available in the function that throws the error.
2015-02-11 23:21:22 +01:00
Richard van Velzen
992b6b9fcc
Fix invalid removal of left side in && and || compression
...
See #637 . This does not produce the optimal result, but it does prevent the removal of non-side-effect-free code.
2015-02-11 21:08:41 +01:00
Richard van Velzen
605362f89d
Drop all console statements properly
...
Because the base reference can be an member expression as well, we have to dig a bit deeper to find the leftmost base reference.
Fixes #451
2015-01-31 13:24:44 +01:00
Mihai Bazon
fbbaa42ee5
Add option to preserve/enforce string quote style
...
`-q 0` (default) use single or double quotes such as to minimize the number of
bytes (prefers double quotes when both will do); this is the previous
behavior.
`-q 1` -- always use single quotes
`-q 2` -- always use double quotes
`-q 3` or just `-q` -- always use the original quotes.
Related codegen option: `quote_style`.
Close #495
Close #460
Some `yargs` guru please tell me why `uglifyjs --help` doesn't display the
help string for `-q` / `--quotes`, and why it doesn't output the expected
argument types anymore, like good old `optimist` did.
2015-01-27 22:26:27 +02:00
Anthony Van de Gejuchte
099992ecae
Keep single line comments after nlb, after nlb
...
Fixes #583
2015-01-26 12:11:52 +01:00
Bryce Cronkite-Ratcliff
5c02d65ddb
fixes issue #621 SourceMap toString JSON format
...
The correct format of a sourcemap is acquired
from a mozilla source map generator by calling
toJSON on this object. This patch alters the
toString function on mozilla generators to print
the format that is to spec instead of the generator's
internal representation of itself.
2015-01-24 00:33:02 -08:00
Mihai Bazon
d36067cd35
Merge pull request #615 from avdg/unicode
...
Give parser more unicode support
2015-01-20 13:00:31 +02:00
Anthony Van de Gejuchte
74cda80d3b
Add unicode digit parsing support
2015-01-20 00:17:24 +01:00
Anthony Van de Gejuchte
9a3a848cc8
Update unicode letter
2015-01-20 00:17:03 +01:00