Alex Lam S.L
fd4caf7a9c
support generator functions ( #4620 )
2021-02-08 06:44:20 +08:00
Alex Lam S.L
ba6e29d6fd
introduce templates ( #4603 )
2021-02-01 17:20:13 +08:00
Alex Lam S.L
d4685640a0
support template literals ( #4601 )
2021-02-01 10:36:45 +08:00
Alex Lam S.L
9d23ba0a22
support exponentiation operator ( #4593 )
2021-01-25 05:48:51 +08:00
Alex Lam S.L
8bfd891c09
support BigInt literals ( #4583 )
2021-01-24 09:51:18 +08:00
Alex Lam S.L
ba54d074d8
support asynchronous arrow functions ( #4530 )
2021-01-10 11:34:26 +08:00
Alex Lam S.L
c3d358a5b8
support rest parameters ( #4515 )
2021-01-07 10:04:09 +08:00
Alex Lam S.L
2390fae5c4
support default values ( #4442 )
2020-12-24 06:22:55 +08:00
Alex Lam S.L
f85a206b9e
fix corner case when parsing expression ( #4435 )
2020-12-23 02:16:04 +08:00
Alex Lam S.L
7aefe97083
parse destructuring under strict mode correctly ( #4429 )
2020-12-20 20:48:51 +08:00
Alex Lam S.L
b7c49b72b3
support async function within object literal ( #4424 )
2020-12-20 08:19:04 +08:00
Alex Lam S.L
e6dd471f8f
support destructuring of catch variable ( #4412 )
2020-12-19 12:28:38 +08:00
Alex Lam S.L
a96f087ac3
support arrow function ( #4385 )
2020-12-17 18:23:41 +08:00
Alex Lam S.L
fea9da9866
forbid AST_Await in computed function arguments ( #4352 )
...
fixes #4351
2020-12-08 12:59:08 +08:00
Alex Lam S.L
4733159782
fix corner cases with await ( #4350 )
...
fixes #4349
2020-12-08 11:26:03 +08:00
Alex Lam S.L
9eb65f3af3
extend trailing comma support ( #4334 )
2020-12-07 10:07:34 +08:00
Alex Lam S.L
2cbbf5c375
support async function ( #4333 )
2020-12-07 05:22:40 +08:00
Alex Lam S.L
1e4985ed9e
support spread syntax ( #4328 )
2020-12-06 05:19:31 +08:00
Alex Lam S.L
e5f80afc53
support destructured literals ( #4278 )
2020-11-17 08:01:24 +08:00
Alex Lam S.L
91fc1c82b5
support computed property name in object literal ( #4268 )
2020-11-08 23:38:32 +08:00
Alex Lam S.L
1cbd07e789
support shorthand method name in object literal ( #4264 )
2020-11-08 13:17:53 +08:00
Alex Lam S.L
b82de04775
support shorthand property name in object literal ( #4263 )
2020-11-08 10:44:44 +08:00
Alex Lam S.L
4bbeb09f7c
fix corner case in reduce_vars ( #4262 )
...
fixes #4261
2020-11-07 10:00:04 +08:00
Alex Lam S.L
8ecaa40c6e
extend support for Unicode ( #4228 )
2020-10-19 09:34:17 +08:00
Alex Lam S.L
96bf7fceab
support let ( #4227 )
2020-10-19 08:32:39 +08:00
Alex Lam S.L
55451e7b78
support const ( #4190 )
2020-10-12 01:18:57 +08:00
Alex Lam S.L
8f0521d51d
retrofit try-catch-finally as block-scoped ( #4178 )
...
- support optional catch binding
2020-10-05 05:30:14 +08:00
Alex Lam S.L
58ac5b9bd5
extend support for numeral literals ( #4176 )
2020-10-05 00:05:03 +08:00
Alex Lam S.L
7de8daa4b1
minor clean up ( #4149 )
2020-09-23 23:06:12 +08:00
Alex Lam S.L
fa13ed4391
reject multiple defaults in switch ( #4053 )
...
fixes #4050
2020-08-17 10:09:12 +08:00
Alex Lam S.L
6bf1486935
update links to repository after rename ( #3847 )
2020-05-05 21:07:33 +08:00
Alex Lam S.L
b39228892d
fix line accounting in multi-line strings ( #3752 )
...
fixes #3748
2020-03-21 07:17:41 +08:00
Alex Lam S.L
22b47cdd63
improve unicode handling ( #3648 )
2019-12-28 18:06:51 +00:00
Alex Lam S.L
ab050e7a94
fix corner case in directives ( #3645 )
2019-12-25 00:55:39 +00:00
Alex Lam S.L
1283d73853
fix corner case in parsing directives ( #3615 )
2019-11-29 18:57:29 +08:00
Alex Lam S.L
0f4cfa877a
fix corner case in comments ( #3550 )
2019-10-30 03:49:39 +08:00
Alex Lam S.L
9199ab5846
minor tweaks ( #3502 )
2019-10-20 15:19:19 +08:00
Alex Lam S.L
2ea96549c5
unify logging functionality ( #3392 )
...
fixes #3253
fixes #3254
2019-04-30 06:32:24 +08:00
Alex Lam S.L
21cd7e3f57
reduce test exports ( #3361 )
2019-04-17 16:19:08 +08:00
Alex Lam S.L
5172ba5f2a
introduce functions ( #3360 )
...
`var f = function() {};` => `function f() {}`
2019-04-15 22:23:11 +08:00
Alex Lam S.L
d90777b724
parse mangle.properties.regex in --config-file properly ( #3337 )
...
fixes #3315
2019-03-15 00:20:20 +08:00
Alex Lam S.L
9e19e63551
general clean-ups ( #3175 )
2018-06-06 17:50:56 +08:00
Alex Lam S.L
81603ecd15
improve performance through makePredicate() ( #3048 )
2018-04-03 15:15:01 +08:00
Alex Lam S.L
49bfc6b555
improve performance ( #3020 )
...
- replace `find_if()` with `all()` wherever possible
- move ESTree-specific logic out of `figure_out_scope()`
2018-03-23 03:43:52 +08:00
Alex Lam S.L
082e004b87
compress undefined property names ( #2811 )
...
- enforce property names as string
- handle `void 0` as `undefined` in `hoist_props` & `reduce_vars`
2018-01-19 00:36:30 +08:00
Alex Lam S.L
b4aef753e7
general improvements around AST_ForIn ( #2796 )
...
- compress using `collapse_vars`
- remove unused `name`
- simplify `loop_body`
2018-01-16 17:03:12 +08:00
Alex Lam S.L
a6873a3859
forbid block-scoped AST_Defun in strict mode ( #2718 )
2018-01-04 18:45:51 +08:00
Alex Lam S.L
446fb0198b
extend __PURE__ to AST_New ( #2706 )
...
fixes #2705
2018-01-03 04:48:07 +08:00
Alex Lam S.L
0fe259e9c5
parse LF & comment correctly ( #2653 )
...
fixes #2652
2017-12-26 01:38:01 +08:00
Alex Lam S.L
efffb81735
fix comments output & improve /*@__PURE__*/
...
- fix whitespace around comments
- fix comment parsing around parentheses
- consider parentheses when parsing `/*@__PURE__*/`
- remove all `/*@__PURE__*/` on output
fixes #2638
2017-12-24 12:38:45 +08:00
Alex Lam S.L
edb4e3bd52
make comments output more robust ( #2633 )
...
- improve handling of comments right after `return`
- retain comments after `OutputStream`
- preserve trailing comments
- fix handling of new line before comments
- handle comments around parentheses
fixes #88
fixes #112
fixes #218
fixes #372
fixes #2629
2017-12-22 04:59:54 +08:00
Alex Lam S.L
93f3b2b114
escape consecutive unpaired surrogates ( #2576 )
...
fixes #2569
2017-12-11 01:15:44 +08:00
Alex Lam S.L
2dcc552ce0
trap invalid use of reserved words ( #2338 )
...
fixes #2337
2017-10-01 02:10:41 +08:00
Alex Lam S.L
0692435f01
fix for-in loop parsing ( #2144 )
2017-06-23 04:14:30 +08:00
Alex Lam S.L
1743621889
clean up lib/parse.js ( #2047 )
...
- remove unused definitions
- replace `array_to_hash()`
2017-06-03 14:00:59 +08:00
Alex Lam S.L
c6c9f4f5a8
implement --help options ( #2017 )
2017-05-28 18:21:44 +08:00
Alex Lam S.L
569c21e952
improve RegExp handling ( #1959 )
...
- remove `options.output.unescape_regexps`
- preserve original pattern whenever possible
fixes #54
fixes #1929
2017-05-17 20:10:50 +08:00
Alex Lam S.L
9464d3c20f
fix parsing of property access after new line ( #1944 )
...
Account for comments when detecting property access in `tokenizer`.
fixes #1943
2017-05-16 05:40:49 +08:00
Alex Lam S.L
265008c948
improve keyword-related parser errors ( #1941 )
...
fixes #1937
2017-05-15 23:02:55 +08:00
Alex Lam S.L
e005099fb1
fix & improve coverage of estree ( #1935 )
...
- fix `estree` conversion of getter/setter
- fix non-directive literal in `to_mozilla_ast()`
- revamp `test/mozilla-ast.js`
- reuse `test/ufuzz.js` for code generation
- use `acorn.parse()` for creating `estree`
- extend `test/ufuzz.js` for `acorn` workaround
- catch variable redefinition
- non-trivial literal as directive
- adjust options for tolerance
Miscellaneous
- optional semi-colon when parsing directives
fixes #1914
closes #1915
2017-05-15 02:37:53 +08:00
Alex Lam S.L
3ca902258c
fix bugs with getter/setter ( #1926 )
...
- `reduce_vars`
- `side_effects`
- property access for object
- `AST_SymbolAccessor` as key names
enhance `test/ufuzz.js`
- add object getter & setter
- property assignment to setter
- avoid infinite recursion in setter
- fix & adjust assignment operators
- 50% `=`
- 25% `+=`
- 2.5% each for the rest
- avoid "Invalid array length"
- fix `console.log()`
- bypass getter
- curb recursive reference
- deprecate `-E`, always report runtime errors
2017-05-14 02:10:34 +08:00
Alex Lam S.L
c391576d52
remove support for const ( #1910 )
...
As this is not part of ES5.
2017-05-12 14:57:41 +08:00
Alex Lam S.L
9bf72cf758
improve parser under "use strict" ( #1836 )
...
- `const` without value
- `delete` of expression
- redefining `arguments` or `eval`
extend `test/ufuzz.js`
- optionally generate "use strict"
- improve handling of test cases with syntax errors
- group IIFE generation
- generate bare anonymous functions
- workaround `console.log()` for `new function()`
- generate expressions with `this`
fixes #1810
2017-04-23 20:05:22 +08:00
Alex Lam S.L
b4b9305db0
fix parser bugs & CLI reporting ( #1827 )
...
fixes #1825
2017-04-19 04:27:13 +08:00
Alex Lam S.L
ec443e422c
unify CLI & API under minify() ( #1811 )
...
- rename `screw_ie8` to `ie8`
- rename `mangle.except` to `mangle.reserved`
- rename `mangle.properties.ignore_quoted` to `mangle.properties.keep_quoted`
- compact `sourceMap` options
- more stringent verification on input `options`
- toplevel shorthands
- `ie8`
- `keep_fnames`
- `toplevel`
- `warnings`
- support arrays and unquoted string values on CLI
- drop `fromString` from `minify()`
- `minify()` no longer handles any `fs` operations
- unify order of operations for `mangle_properties()` on CLI & API
- `bin/uglifyjs` used to `mangle_properties()` before even `Compressor`
- `minify()` used to `mangle_properties()` after `Compressor` but before `mangle_names()`
- both will now do `Compressor`, `mangle_names()` then `mangle_properties()`
- `options.parse` / `--parse` for parser options beyond `bare_returns`
- add `mangle.properties.builtins` to disable built-in reserved list
- disable with `--mangle-props builtins` on CLI
- `warnings` now off by default
- add `--warn` and `--verbose` on CLI
- drop `--enclose`
- drop `--export-all`
- drop `--reserved-file`
- use `--mangle reserved` instead
- drop `--reserve-domprops`
- enabled by default, disable with `--mangle-props domprops`
- drop `--prefix`
- use `--source-map base` instead
- drop `--lint`
- remove `bin/extract-props.js`
- limit exposure of internal APIs
- update documentations
closes #96
closes #102
closes #136
closes #166
closes #243
closes #254
closes #261
closes #311
closes #700
closes #748
closes #912
closes #1072
closes #1366
fixes #101
fixes #123
fixes #124
fixes #263
fixes #379
fixes #419
fixes #423
fixes #461
fixes #465
fixes #576
fixes #737
fixes #772
fixes #958
fixes #1036
fixes #1142
fixes #1175
fixes #1220
fixes #1223
fixes #1280
fixes #1359
fixes #1368
2017-04-15 23:50:50 +08:00
Alex Lam S.L
2244743545
convert AST_Seq from binary tree to array ( #1460 )
...
- rename `AST_Seq` to `AST_Sequence`
- raise default sequences_limit from 200 to 800
2017-04-12 21:56:27 +08:00
Alex Lam S.L
a0c3836ba0
sort options in alphabetical order ( #1743 )
...
They started off as functional groups I guess, but given the sheer number of options this is becoming too difficult to read.
2017-03-31 16:41:04 +08:00
Alex Lam S.L
2e0dc97003
improve error marker placement ( #1644 )
...
For AST_UnaryPrefix, points to the operator rather than end of expression.
2017-03-24 14:28:40 +08:00
kzc
79334dda10
fix regression: CLI options with hyphens like -b ascii-only ( #1640 )
...
fixes #1637
2017-03-24 11:55:03 +08:00
Alex Lam S.L
4bceb85cbf
throw parse error on invalid assignments ( #1627 )
...
fixes #1626
2017-03-21 14:11:32 +08:00
Alex Lam S.L
cf45e2f79b
fixup for #1585 ( #1589 )
...
As patched on `harmony`, `statement()` is the only user of `embed_tokens()` with a missing error branch.
Updated test case and match up with `harmony` to facilitate future merging.
2017-03-10 10:49:41 +08:00
Michael Mior
93cdb194f4
Correctly raise a parse exception with a missing loop body ( #1585 )
2017-03-10 03:08:43 +08:00
Alex Lam S.L
eb98a7f2f3
fix handling of shebang and preamble ( #1545 )
...
fixes #1332
2017-03-05 12:16:02 +08:00
Alex Lam S.L
872270b149
improve error messages ( #1506 )
...
- better inheritance of `Error` sub-classes
- mark parse error against source in CLI
closes #235
closes #348
closes #524
closes #1356
closes #1405
2017-02-27 03:40:54 +08:00
Ondřej Španěl
d48a3080ac
Fix: AST_Accessor missing start / end tokens
...
fixes #1492
closes #1493
2017-02-21 13:32:16 +08:00
Anthony Van de Gejuchte
642273c290
Legacy octal integer strict mode fixes
2016-07-21 14:42:16 +02:00
Anthony Van de Gejuchte
2d8af8947e
Fix error style for regex errors
2016-07-15 13:14:30 +02:00
Anthony Van de Gejuchte
a97690fc72
Various LineTerminator changes
...
* Escaped newlines should also produce SyntaxError
* Fix multiline comment parsing and add tests
* Adapt makePredicate to handle \u2028 and \u2029
* Move up nlb check in regex so it's checked before any escape handling
* Change error messages to conform ecma standard
* Find_eol not recornizing \u2028 and \u2029 as line terminator
* Remove \u180e as it is removed in unicode 6.3.0 from the category zs
2016-06-30 22:12:50 +02:00
Anthony Van de Gejuchte
3a7d53f3cf
Move OctalEscapeSequence to read_escape_char
...
This should simplify and improve implementation, make it easier to
implement template strings, and keep master a bit more in sync with
harmony.
Previous implementation wasn't broken, though the loop gave me the
impression it could read infinite numbers and annoyed me a bit. It was
also slightly unnecessary because the lookup involved only 3 characters.
2016-06-30 21:42:15 +02:00
Anthony Van de Gejuchte
6c99816855
Normalize error messages
2016-06-19 21:08:34 +02:00
Anthony Van de Gejuchte
2149bfb707
Don't mix strings with directives in output
...
* Don't interpret strings with escaped content as directive
* Don't interpret strings after empty statement as directive
* Adapt output to prevent strings being represent as directive
* Introduce UGLIFY_DEBUG to allow internal testing like EXPECT_DIRECTIVE
2016-06-19 20:59:17 +02:00
Anthony Van de Gejuchte
bb9c9707aa
Don't allow with statements in strict mode
2016-06-12 19:08:16 +02:00
Anthony Van de Gejuchte
4d7746baf3
Throw errors in strict mode for octal strings
...
Adds a directive tracker for the parser/tokenizer to
allow parsing depending on directive context.
2016-06-12 14:27:08 +02:00
Anthony Van de Gejuchte
00ad57e393
Do not allow newlines in regex
2016-06-05 17:02:19 +02:00
kzc
f39fd3d583
Handle CR line endings in comments.
...
Fixes #1050
2016-05-04 20:02:29 +02:00
kzc
e4fa4b109a
Parse comments without recursion to avoid RangeError.
...
Fixes #993
2016-04-16 02:02:47 -04:00
kzc
a9d4a6291b
Do not produce let as a variable name in mangle.
...
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986 .
2016-03-15 11:20:32 -04:00
Anthony Van de Gejuchte
26641f3fb2
Allow operator names as getters/setters
...
Fixes #919
Fix provided by @kzc
2016-01-19 19:28:51 +01:00
Anthony Van de Gejuchte
6f3e35bb3f
Fix ch that could contain other newline characters
2015-12-27 22:24:37 +01:00
Anthony Van de Gejuchte
174404c0f3
Do not allow newlines in string literals
2015-12-26 15:08:37 +01:00
Anthony Van de Gejuchte
bd99b00413
Semicolon after do...while statement is optional
2015-12-17 23:02:35 +01:00
Mihai Bazon
08623aa6a7
Fix output for "use asm" code from SpiderMonkey AST
...
(will only work properly if the SM tree contains "raw" properties for
Literal number nodes)
2015-11-12 12:18:25 +02:00
Mihai Bazon
7691bebea5
Rework has_directive
...
It's now available during tree walking, i.e. walker.has_directive("use
asm"), rather than as part of the scope. It's thus no longer necessary
to call `figure_out_scope` before codegen. Added special bits in the
code generator to overcome the fact that it doesn't inherit from
TreeWalker.
Fix #861
2015-11-11 22:15:25 +02:00
Mihai Bazon
18d37ac761
Fix parsing invalid input
...
i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as
`x = 1`.
Ref #857
2015-11-09 13:15:20 +02:00
Richard van Velzen
63d35f8f6d
Prevent ReDoS by not using a regexp to verify floating point numbers
...
`parseFloat` will return `NaN` for invalid numbers anyway, which is the check used to throw the parse error.
Fixes #857
2015-11-09 11:28:27 +01:00
kzc
4d2f7d83af
Fix handling of "use asm" when no command line flags are passed to uglifyjs. SCOPE_IS_NEEDED is unconditionally true now. Refactored floating point literal parsing to be more in keeping with the AST class design.
2015-10-07 13:10:53 -04:00
kzc
593677d2ff
Add proper support for "use asm"; blocks. Disable -c optimization within "use asm"; sections and preserve floating point literals in their original form. Non-asm.js sections are optimized as before. Asm.js sections can still be mangled and minified of whitespace. No special command line flags are required.
2015-10-07 10:00:28 +02:00
Anthony Van de Gejuchte
c69294c449
Implement shebang support
2015-10-06 22:35: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
Chris Cowan
9854deb626
Re-use the caught exception's error message in the parse error call.
2015-07-29 15:06:52 +02:00