terser 5.39.2 → 5.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/bundle.min.js +55 -47
- package/lib/mozilla-ast.js +54 -41
- package/lib/parse.js +1 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.40.0
|
4
|
+
|
5
|
+
- Fix exporting AssignmentExpression (default assign pattern) to ESTree
|
6
|
+
- Fix ESTree output of object keys with quotes
|
7
|
+
- Fix handling of an ESTree empty `export {}` (#1601)
|
8
|
+
- Fix some `const` and `let` resulting from ESTree input (#1599)
|
9
|
+
|
3
10
|
## v5.39.2
|
4
11
|
|
5
12
|
- Fix crash when parsing bare `yield` inside a template string.
|
package/dist/bundle.min.js
CHANGED
@@ -1685,14 +1685,9 @@ function parse($TEXT, options) {
|
|
1685
1685
|
|
1686
1686
|
var body = _function_body(is("punc", "{"), false, is_async);
|
1687
1687
|
|
1688
|
-
var end =
|
1689
|
-
body instanceof Array && body.length ? body[body.length - 1].end :
|
1690
|
-
body instanceof Array ? start :
|
1691
|
-
body.end;
|
1692
|
-
|
1693
1688
|
return new AST_Arrow({
|
1694
1689
|
start : start,
|
1695
|
-
end : end,
|
1690
|
+
end : body.end,
|
1696
1691
|
async : is_async,
|
1697
1692
|
argnames : argnames,
|
1698
1693
|
body : body
|
@@ -7358,6 +7353,9 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7358
7353
|
start : my_start_token(key || M.value),
|
7359
7354
|
end : my_end_token(M.value),
|
7360
7355
|
key : key.type == "Identifier" ? key.name : key.value,
|
7356
|
+
quote : !key.computed && key.type === "Literal" && typeof key.value === "string"
|
7357
|
+
? '"'
|
7358
|
+
: null,
|
7361
7359
|
value : from_moz(M.value)
|
7362
7360
|
};
|
7363
7361
|
if (M.computed) {
|
@@ -7390,7 +7388,6 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7390
7388
|
if (M.kind == "method") {
|
7391
7389
|
args.async = M.value.async;
|
7392
7390
|
args.is_generator = M.value.generator;
|
7393
|
-
args.quote = M.computed ? "\"" : null;
|
7394
7391
|
return new AST_ConciseMethod(args);
|
7395
7392
|
}
|
7396
7393
|
},
|
@@ -7634,14 +7631,26 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7634
7631
|
},
|
7635
7632
|
|
7636
7633
|
ExportNamedDeclaration: function(M) {
|
7637
|
-
|
7638
|
-
|
7639
|
-
|
7640
|
-
|
7641
|
-
|
7642
|
-
|
7643
|
-
|
7644
|
-
|
7634
|
+
if (M.declaration) {
|
7635
|
+
// export const, export function, ...
|
7636
|
+
return new AST_Export({
|
7637
|
+
start: my_start_token(M),
|
7638
|
+
end: my_end_token(M),
|
7639
|
+
exported_definition: from_moz(M.declaration),
|
7640
|
+
exported_names: null,
|
7641
|
+
module_name: null,
|
7642
|
+
attributes: null,
|
7643
|
+
});
|
7644
|
+
} else {
|
7645
|
+
return new AST_Export({
|
7646
|
+
start: my_start_token(M),
|
7647
|
+
end: my_end_token(M),
|
7648
|
+
exported_definition: null,
|
7649
|
+
exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : [],
|
7650
|
+
module_name: from_moz(M.source),
|
7651
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions),
|
7652
|
+
});
|
7653
|
+
}
|
7645
7654
|
},
|
7646
7655
|
|
7647
7656
|
ExportDefaultDeclaration: function(M) {
|
@@ -7733,8 +7742,9 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
7733
7742
|
|
7734
7743
|
Identifier: function(M) {
|
7735
7744
|
var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
|
7745
|
+
var q = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 3];
|
7736
7746
|
return new ( p.type == "LabeledStatement" ? AST_Label
|
7737
|
-
: p.type == "VariableDeclarator" && p.id === M ? (
|
7747
|
+
: p.type == "VariableDeclarator" && p.id === M ? (q.kind == "const" ? AST_SymbolConst : q.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
|
7738
7748
|
: /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
|
7739
7749
|
: p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
|
7740
7750
|
: p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
|
@@ -8186,30 +8196,6 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8186
8196
|
type: "Super"
|
8187
8197
|
};
|
8188
8198
|
});
|
8189
|
-
def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
|
8190
|
-
return {
|
8191
|
-
type: "BinaryExpression",
|
8192
|
-
operator: M.operator,
|
8193
|
-
left: to_moz(M.left),
|
8194
|
-
right: to_moz(M.right)
|
8195
|
-
};
|
8196
|
-
});
|
8197
|
-
def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
|
8198
|
-
return {
|
8199
|
-
type: "LogicalExpression",
|
8200
|
-
operator: M.operator,
|
8201
|
-
left: to_moz(M.left),
|
8202
|
-
right: to_moz(M.right)
|
8203
|
-
};
|
8204
|
-
});
|
8205
|
-
def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
|
8206
|
-
return {
|
8207
|
-
type: "AssignmentExpression",
|
8208
|
-
operator: M.operator,
|
8209
|
-
left: to_moz(M.left),
|
8210
|
-
right: to_moz(M.right)
|
8211
|
-
};
|
8212
|
-
});
|
8213
8199
|
def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
|
8214
8200
|
return {
|
8215
8201
|
type: "ConditionalExpression",
|
@@ -8336,6 +8322,14 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8336
8322
|
};
|
8337
8323
|
});
|
8338
8324
|
|
8325
|
+
def_to_moz(AST_DefaultAssign, function To_Moz_AssignmentExpression(M) {
|
8326
|
+
return {
|
8327
|
+
type: "AssignmentPattern",
|
8328
|
+
left: to_moz(M.left),
|
8329
|
+
right: to_moz(M.right),
|
8330
|
+
};
|
8331
|
+
});
|
8332
|
+
|
8339
8333
|
def_to_moz(AST_Directive, function To_Moz_Directive(M) {
|
8340
8334
|
return {
|
8341
8335
|
type: "ExpressionStatement",
|
@@ -8412,8 +8406,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8412
8406
|
def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
|
8413
8407
|
if (M.exported_names) {
|
8414
8408
|
var first_exported = M.exported_names[0];
|
8415
|
-
|
8416
|
-
if (first_exported_name.name === "*" && !first_exported_name.quote) {
|
8409
|
+
if (first_exported && first_exported.name.name === "*" && !first_exported.name.quote) {
|
8417
8410
|
var foreign_name = first_exported.foreign_name;
|
8418
8411
|
var exported = foreign_name.name === "*" && !foreign_name.quote
|
8419
8412
|
? null
|
@@ -8560,6 +8553,15 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8560
8553
|
};
|
8561
8554
|
});
|
8562
8555
|
|
8556
|
+
def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
|
8557
|
+
return {
|
8558
|
+
type: "AssignmentExpression",
|
8559
|
+
operator: M.operator,
|
8560
|
+
left: to_moz(M.left),
|
8561
|
+
right: to_moz(M.right)
|
8562
|
+
};
|
8563
|
+
});
|
8564
|
+
|
8563
8565
|
def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
|
8564
8566
|
return {
|
8565
8567
|
type: "BinaryExpression",
|
@@ -8586,7 +8588,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8586
8588
|
def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
|
8587
8589
|
var key = M.key instanceof AST_Node ? to_moz(M.key) : {
|
8588
8590
|
type: "Identifier",
|
8589
|
-
value: M.key
|
8591
|
+
value: M.key,
|
8590
8592
|
};
|
8591
8593
|
if (typeof M.key === "number") {
|
8592
8594
|
key = {
|
@@ -8595,10 +8597,16 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
|
|
8595
8597
|
};
|
8596
8598
|
}
|
8597
8599
|
if (typeof M.key === "string") {
|
8598
|
-
key =
|
8599
|
-
|
8600
|
-
|
8601
|
-
|
8600
|
+
key = M.quote
|
8601
|
+
? {
|
8602
|
+
type: "Literal",
|
8603
|
+
value: M.key,
|
8604
|
+
raw: JSON.stringify(M.key),
|
8605
|
+
}
|
8606
|
+
: {
|
8607
|
+
type: "Identifier",
|
8608
|
+
name: M.key,
|
8609
|
+
};
|
8602
8610
|
}
|
8603
8611
|
var kind;
|
8604
8612
|
var string_or_num = typeof M.key === "string" || typeof M.key === "number";
|
package/lib/mozilla-ast.js
CHANGED
@@ -355,6 +355,9 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
355
355
|
start : my_start_token(key || M.value),
|
356
356
|
end : my_end_token(M.value),
|
357
357
|
key : key.type == "Identifier" ? key.name : key.value,
|
358
|
+
quote : !key.computed && key.type === "Literal" && typeof key.value === "string"
|
359
|
+
? '"'
|
360
|
+
: null,
|
358
361
|
value : from_moz(M.value)
|
359
362
|
};
|
360
363
|
if (M.computed) {
|
@@ -387,7 +390,6 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
387
390
|
if (M.kind == "method") {
|
388
391
|
args.async = M.value.async;
|
389
392
|
args.is_generator = M.value.generator;
|
390
|
-
args.quote = M.computed ? "\"" : null;
|
391
393
|
return new AST_ConciseMethod(args);
|
392
394
|
}
|
393
395
|
},
|
@@ -631,14 +633,26 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
631
633
|
},
|
632
634
|
|
633
635
|
ExportNamedDeclaration: function(M) {
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
636
|
+
if (M.declaration) {
|
637
|
+
// export const, export function, ...
|
638
|
+
return new AST_Export({
|
639
|
+
start: my_start_token(M),
|
640
|
+
end: my_end_token(M),
|
641
|
+
exported_definition: from_moz(M.declaration),
|
642
|
+
exported_names: null,
|
643
|
+
module_name: null,
|
644
|
+
attributes: null,
|
645
|
+
});
|
646
|
+
} else {
|
647
|
+
return new AST_Export({
|
648
|
+
start: my_start_token(M),
|
649
|
+
end: my_end_token(M),
|
650
|
+
exported_definition: null,
|
651
|
+
exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : [],
|
652
|
+
module_name: from_moz(M.source),
|
653
|
+
attributes: import_attributes_from_moz(M.attributes || M.assertions),
|
654
|
+
});
|
655
|
+
}
|
642
656
|
},
|
643
657
|
|
644
658
|
ExportDefaultDeclaration: function(M) {
|
@@ -730,8 +744,9 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
730
744
|
|
731
745
|
Identifier: function(M) {
|
732
746
|
var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
|
747
|
+
var q = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 3];
|
733
748
|
return new ( p.type == "LabeledStatement" ? AST_Label
|
734
|
-
: p.type == "VariableDeclarator" && p.id === M ? (
|
749
|
+
: p.type == "VariableDeclarator" && p.id === M ? (q.kind == "const" ? AST_SymbolConst : q.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
|
735
750
|
: /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
|
736
751
|
: p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
|
737
752
|
: p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
|
@@ -1183,30 +1198,6 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1183
1198
|
type: "Super"
|
1184
1199
|
};
|
1185
1200
|
});
|
1186
|
-
def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
|
1187
|
-
return {
|
1188
|
-
type: "BinaryExpression",
|
1189
|
-
operator: M.operator,
|
1190
|
-
left: to_moz(M.left),
|
1191
|
-
right: to_moz(M.right)
|
1192
|
-
};
|
1193
|
-
});
|
1194
|
-
def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
|
1195
|
-
return {
|
1196
|
-
type: "LogicalExpression",
|
1197
|
-
operator: M.operator,
|
1198
|
-
left: to_moz(M.left),
|
1199
|
-
right: to_moz(M.right)
|
1200
|
-
};
|
1201
|
-
});
|
1202
|
-
def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
|
1203
|
-
return {
|
1204
|
-
type: "AssignmentExpression",
|
1205
|
-
operator: M.operator,
|
1206
|
-
left: to_moz(M.left),
|
1207
|
-
right: to_moz(M.right)
|
1208
|
-
};
|
1209
|
-
});
|
1210
1201
|
def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
|
1211
1202
|
return {
|
1212
1203
|
type: "ConditionalExpression",
|
@@ -1333,6 +1324,14 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1333
1324
|
};
|
1334
1325
|
});
|
1335
1326
|
|
1327
|
+
def_to_moz(AST_DefaultAssign, function To_Moz_AssignmentExpression(M) {
|
1328
|
+
return {
|
1329
|
+
type: "AssignmentPattern",
|
1330
|
+
left: to_moz(M.left),
|
1331
|
+
right: to_moz(M.right),
|
1332
|
+
};
|
1333
|
+
});
|
1334
|
+
|
1336
1335
|
def_to_moz(AST_Directive, function To_Moz_Directive(M) {
|
1337
1336
|
return {
|
1338
1337
|
type: "ExpressionStatement",
|
@@ -1409,8 +1408,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1409
1408
|
def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
|
1410
1409
|
if (M.exported_names) {
|
1411
1410
|
var first_exported = M.exported_names[0];
|
1412
|
-
|
1413
|
-
if (first_exported_name.name === "*" && !first_exported_name.quote) {
|
1411
|
+
if (first_exported && first_exported.name.name === "*" && !first_exported.name.quote) {
|
1414
1412
|
var foreign_name = first_exported.foreign_name;
|
1415
1413
|
var exported = foreign_name.name === "*" && !foreign_name.quote
|
1416
1414
|
? null
|
@@ -1557,6 +1555,15 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1557
1555
|
};
|
1558
1556
|
});
|
1559
1557
|
|
1558
|
+
def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
|
1559
|
+
return {
|
1560
|
+
type: "AssignmentExpression",
|
1561
|
+
operator: M.operator,
|
1562
|
+
left: to_moz(M.left),
|
1563
|
+
right: to_moz(M.right)
|
1564
|
+
};
|
1565
|
+
});
|
1566
|
+
|
1560
1567
|
def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
|
1561
1568
|
return {
|
1562
1569
|
type: "BinaryExpression",
|
@@ -1583,7 +1590,7 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1583
1590
|
def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
|
1584
1591
|
var key = M.key instanceof AST_Node ? to_moz(M.key) : {
|
1585
1592
|
type: "Identifier",
|
1586
|
-
value: M.key
|
1593
|
+
value: M.key,
|
1587
1594
|
};
|
1588
1595
|
if (typeof M.key === "number") {
|
1589
1596
|
key = {
|
@@ -1592,10 +1599,16 @@ import { is_basic_identifier_string } from "./parse.js";
|
|
1592
1599
|
};
|
1593
1600
|
}
|
1594
1601
|
if (typeof M.key === "string") {
|
1595
|
-
key =
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1602
|
+
key = M.quote
|
1603
|
+
? {
|
1604
|
+
type: "Literal",
|
1605
|
+
value: M.key,
|
1606
|
+
raw: JSON.stringify(M.key),
|
1607
|
+
}
|
1608
|
+
: {
|
1609
|
+
type: "Identifier",
|
1610
|
+
name: M.key,
|
1611
|
+
};
|
1599
1612
|
}
|
1600
1613
|
var kind;
|
1601
1614
|
var string_or_num = typeof M.key === "string" || typeof M.key === "number";
|
package/lib/parse.js
CHANGED
@@ -1540,14 +1540,9 @@ function parse($TEXT, options) {
|
|
1540
1540
|
|
1541
1541
|
var body = _function_body(is("punc", "{"), false, is_async);
|
1542
1542
|
|
1543
|
-
var end =
|
1544
|
-
body instanceof Array && body.length ? body[body.length - 1].end :
|
1545
|
-
body instanceof Array ? start :
|
1546
|
-
body.end;
|
1547
|
-
|
1548
1543
|
return new AST_Arrow({
|
1549
1544
|
start : start,
|
1550
|
-
end : end,
|
1545
|
+
end : body.end,
|
1551
1546
|
async : is_async,
|
1552
1547
|
argnames : argnames,
|
1553
1548
|
body : body
|