Commit Graph

1196 Commits

Author SHA1 Message Date
Ashley (Scirra) 2a9989dd18 Add --mangle-props-debug and fix --mangle-props=unquoted collision
Patch by @AshleyScirra

Based on: PR #1316

Renamed the CLI debug option to --mangle-props-debug

Fixes: #1321 name collision in --mangle-props=unquoted
2016-11-29 20:25:39 +01:00
Anthony Van de Gejuchte 79b98a9fe8 Do not overwrite options.comments + cleanup 2016-11-29 20:24:08 +01:00
Anthony Van de Gejuchte c2112d5886 Fix case where a lonely var is used as computed property 2016-11-29 20:19:01 +01:00
Anthony Van de Gejuchte 5f6825f9ec Introduce is_block_scope to AST_Node to determine block scope.
Will return false if AST_Node is instance of AST_Scope for now.
2016-10-24 21:28:32 +02:00
Anthony Van de Gejuchte 7e80a979a7 Remove AST_ObjectComputedKeyVal 2016-10-23 22:12:30 +02:00
Richard van Velzen b7bb706150 Merge branch 'master' into harmony 2016-10-23 22:11:27 +02:00
Anthony Van de Gejuchte 8d74f34373 Don't filter shebangs when using the 'some' comment filter
Also clarify documentation a bit more about using regexp as filter
2016-10-23 21:31:03 +02:00
Jann Horn 266ddd9639 fix uses_arguments handling (broken since 6605d15783)
Using the symbol declaration tracking of UglifyJS doesn't make sense here
anyway, `arguments` always comes from something in the current scope.

fixes #1299
2016-10-23 21:29:18 +02:00
Anthony Van de Gejuchte 32c2cc33bb Improve binding patterns for arrow functions 2016-10-23 21:13:12 +02:00
Anthony Van de Gejuchte 947b8750e8 Make classes implicitly strict mode 2016-10-17 20:24:38 +02:00
Richard van Velzen 6389e52305 Remove console.log and add extra test case 2016-10-06 14:11:32 +02:00
Richard van Velzen e05510f3bc Add an option to wrap IIFEs in parenthesis
For #1307.
2016-10-06 14:11:32 +02:00
kzc fc9804b909 Fix (typeof side_effect()) in boolean context
Fixes #1289 with suggestion by @rvanvelzen
2016-10-06 13:50:11 +02:00
alexlamsl 4761d07e0b Optimize unmodified variables 2016-10-01 11:36:11 +02:00
kzc 88f6ff38d1 [ES6] fix template string escaping of \${...} 2016-10-01 11:32:36 +02:00
kzc 4198095a9c [ES6] fix parsing spread arguments that are expressions 2016-09-29 13:34:22 -04:00
Anthony Van de Gejuchte 0111497fc9 Make all comment options in cli available in js api
Also removing more code within "loop" while at it.
2016-09-06 17:54:45 +02:00
Anthony Van de Gejuchte 13ed445607 Improve support for binding pattern
Including improvements for parameters, variable assignment and
catch parameter.
2016-09-05 17:48:48 +02:00
Richard van Velzen 1db50c3b16 Don't parenthesize arrow functions in parameter lists 2016-09-02 09:35:31 +02:00
kzc 25fc02743a Account for side effects in string + expr optimization 2016-09-01 09:24:56 -04:00
Richard van Velzen 7f6b5d662b Merge branch 'master' into harmony 2016-08-30 15:16:23 +02:00
kzc 0bd8053524 implement optimization: (x = 2 * x) ---> (x *= 2) 2016-08-30 08:43:02 -04:00
Anthony Van de Gejuchte 1c15d0db45 Fix quoting of properties
- Make AST_ConciseMethod child of AST_ObjectProperty.
- Fix some typos.
2016-08-26 15:06:24 +02:00
Richard van Velzen 45d81f881b Merge branch 'master' into harmony 2016-08-17 20:21:38 +02:00
Richard van Velzen 8430123e9d Fix negate_iife transform to return a correct tree for nested IIFEs
Fix for #1256, partially reverts d854523783
2016-08-17 11:55:59 +02:00
Richard van Velzen 8c7d23dfb1 Merge branch 'master' into harmony 2016-08-17 08:50:31 +02:00
kzc d854523783 Fix negate_iife regression #1254 2016-08-17 01:29:34 -04:00
Richard van Velzen c644c1292d Merge branch 'master' into harmony 2016-08-15 09:09:04 +02:00
kzc de619ae5a6 Fix --mangle-props and --mangle-props=unquoted
Fixes: #1247

Fix --mangle-props and --name-cache inconsistency.
AST_Dot and AST_Sub properties are now mangled by --mangle-props
without regard to being used in an assignment statement.

Note: if --mangle-props is used then *all* javascript files used must
be uglified with the same mangle options.

Fix the ignore_quoted=true mangle option, also known as
`--mangle-props=unquoted`.  If a given property is quoted anywhere
it will not be mangled in any quoted or non-quoted context.
2016-08-14 21:51:25 +02:00
kzc d224d71b8d [ES6] Fix handling of semicolons in export parse. 2016-08-14 21:43:24 +02:00
kzc fb049d3a81 Fix unneeded parens around unary args in new expression. 2016-08-14 21:38:38 +02:00
Anthony Van de Gejuchte 27d3669800 Don't allow escaped surrogated identifiers + introduce ascii_identifiers
Don't use 2 characters for surrogates in identifiers because there is
support for the \u{} syntax when escaped identifiers were introduced.

Also catch eof errors while reading identifier names

Introduce ascii_identifiers:

By setting ascii_identifiers to undefined (default value),
ascii_identifiers will print identifiers using the same setting as
ascii_only within the limits of the ecmascript 6 grammar.

ascii_identifiers accept true and false, allowing identifiers to be
printed under different settings than strings with the ascii_only setting.
2016-08-14 21:36:06 +02:00
Anthony Van de Gejuchte 110a1ac885 Make distinction between * method and * operator
Also add quotes to properties when necessary,
this might be the case if the name isn't a valid
identifier
2016-07-29 21:31:08 +02:00
Anthony Van de Gejuchte 3f8fc3a316 Fix computed getters + cleanup AST 2016-07-21 18:21:46 +02:00
Anthony Van de Gejuchte 88384cf351 Add more globals, whereof most defined after es5.1
Also do not pollute env with mocks replacing standard globals
2016-07-21 16:52:04 +02:00
Anthony Van de Gejuchte 72a9d799b6 Various property fixes
* Implement getter/setter with computed value
* Fix parsing getter/setter after static or generator token
* Allow storing expressions for computed expression in AST_SymbolMethod
* Allow get and set in shorthand properties in object literals

Fixes #1094, #1146 and #1221
2016-07-21 16:50:32 +02:00
Anthony Van de Gejuchte 642273c290 Legacy octal integer strict mode fixes 2016-07-21 14:42:16 +02:00
Anthony Van de Gejuchte 766fafda8b Don't remove empty generators passed as parameter 2016-07-19 18:13:07 +02:00
kzc 842ac27efb [ES6] Get compress and global_defs working for AST_Class 2016-07-17 19:56:02 +02:00
Lauri Pokka 41a9329409 lib/sourcemap.js: Copy sourceContent from old souce-map to the new source-map. Should fix #882 2016-07-17 19:36:15 +02:00
Anthony Van de Gejuchte 0af42d1831 Template fixes
* Fixes #1147: template strings not obeying -b ascii_only true
* Allow evaluation of template expressions by adding optimizers and
  walkers
* Make sure tagged templates are never changed
* Remove template tokenizer in parser, add template tokenizer in
  tokenizer. It is using a brace counter to track brace position of
  templates
* Add tokens `template_head` and `template_substitution` but parsing
  tokens stays mostly the same
* Do not output strings anymore in AST_TemplateString, instead use
  AST_TemplateSegment
* Fix parsing tagged templates, allowing multiple templates behind
  as spec allows this

These changes don't influence tagged templates because raw content
may influence code execution, however they are safe to do in normal
templates:
* Allow basic string concatenation of templates where possible
* Allow custom character escape style similar to strings, except in
  tagged templates

Note that expressions are still compressed in tagged templates.

Optional things that may be improved later:
* Custom quote style for templates if it doesn't have expressions.
  Making it obey the quote_style option if this is the case.
2016-07-17 00:36:42 +02:00
Anthony Van de Gejuchte 7eb52d2837 Keep const in own scope while compressing
- Fixes #1205
- Fix provided by @kzc
2016-07-15 13:20:52 +02:00
kzc eb63fece2f Fix mangle with option keep_fnames=true for Safari.
Fixes: #1202
2016-07-15 13:18:14 +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 ff7f6139ba Improve multi-line comment parsing
* Make sure comments are skipped correctly with surrogates
* Fix regression in multiline comments with nlb
2016-07-12 00:08:35 +02:00
Richard van Velzen 0db7caf13b Merge branch 'master' into harmony 2016-07-03 21:39:00 +02:00
Anthony Van de Gejuchte d9bc6f303c Fix output arrow function with 1 param with default value
Fixes #1090
2016-07-03 21:37:53 +02:00
Anthony Van de Gejuchte 6fd9b338dd Merge branch 'master' into harmony 2016-07-03 21:35:00 +02:00
Anthony Van de Gejuchte 698705a820 Don't convert all strings to directives from moz-ast 2016-07-03 12:36:57 +02:00
Anthony Van de Gejuchte d8d4e71b9e Fix uses_with/uses_eval/directives state in block scope 2016-07-01 15:43:17 +02:00