Comparing version 5.31.6 to 5.32.0
# Changelog | ||
## v5.32.0 | ||
- `import("module")` can now be input and output from ESTree AST (#1557) | ||
- `BigInt` literals can now be input and output from ESTree AST (#1555) | ||
- `typeof` an object or array (`typeof {}` and `typeof []`) can now be statically evaluated. (#1546) | ||
## v5.31.6 | ||
@@ -4,0 +10,0 @@ - Retain side effects in a `case` when the expression is a sequence (comma) expression |
@@ -221,10 +221,21 @@ /*********************************************************************** | ||
var e = this.expression; | ||
// Function would be evaluated to an array and so typeof would | ||
// incorrectly return 'object'. Hence making is a special case. | ||
if (compressor.option("typeofs") | ||
&& this.operator == "typeof" | ||
&& (e instanceof AST_Lambda | ||
&& this.operator == "typeof") { | ||
// Function would be evaluated to an array and so typeof would | ||
// incorrectly return 'object'. Hence making is a special case. | ||
if (e instanceof AST_Lambda | ||
|| e instanceof AST_SymbolRef | ||
&& e.fixed_value() instanceof AST_Lambda)) { | ||
return typeof function () { }; | ||
&& e.fixed_value() instanceof AST_Lambda) { | ||
return typeof function () { }; | ||
} | ||
if ( | ||
(e instanceof AST_Object | ||
|| e instanceof AST_Array | ||
|| (e instanceof AST_SymbolRef | ||
&& (e.fixed_value() instanceof AST_Object | ||
|| e.fixed_value() instanceof AST_Array))) | ||
&& !e.has_side_effects(compressor) | ||
) { | ||
return typeof {}; | ||
} | ||
} | ||
@@ -231,0 +242,0 @@ if (!non_converting_unary.has(this.operator)) |
@@ -598,2 +598,15 @@ /*********************************************************************** | ||
ImportExpression: function(M) { | ||
return new AST_Call({ | ||
start: my_start_token(M), | ||
end: my_end_token(M), | ||
expression: from_moz({ | ||
type: "Identifier", | ||
name: "import" | ||
}), | ||
optional: false, | ||
args: [from_moz(M.source)] | ||
}); | ||
}, | ||
ExportAllDeclaration: function(M) { | ||
@@ -666,2 +679,7 @@ var foreign_name = M.exported == null ? | ||
} | ||
const bi = typeof M.value === "bigint" ? M.value.toString() : M.bigint; | ||
if (typeof bi === "string") { | ||
args.value = bi; | ||
return new AST_BigInt(args); | ||
} | ||
if (val === null) return new AST_Null(args); | ||
@@ -734,10 +752,2 @@ switch (typeof val) { | ||
BigIntLiteral(M) { | ||
return new AST_BigInt({ | ||
start : my_start_token(M), | ||
end : my_end_token(M), | ||
value : M.value | ||
}); | ||
}, | ||
EmptyStatement: function(M) { | ||
@@ -1215,2 +1225,10 @@ return new AST_EmptyStatement({ | ||
def_to_moz(AST_Call, function To_Moz_CallExpression(M) { | ||
if (M.expression instanceof AST_SymbolRef && M.expression.name === "import") { | ||
const [source] = M.args.map(to_moz); | ||
return { | ||
type: "ImportExpression", | ||
source, | ||
}; | ||
} | ||
return { | ||
@@ -1761,4 +1779,9 @@ type: "CallExpression", | ||
def_to_moz(AST_BigInt, M => ({ | ||
type: "BigIntLiteral", | ||
value: M.value | ||
type: "Literal", | ||
// value cannot be represented natively | ||
// see: https://github.com/estree/estree/blob/master/es2020.md#bigintliteral | ||
value: null, | ||
// `M.value` is a string that may be a hex number representation. | ||
// but "bigint" property should have only decimal digits | ||
bigint: typeof BigInt === "function" ? BigInt(M.value).toString() : M.value, | ||
})); | ||
@@ -1765,0 +1788,0 @@ |
@@ -7,3 +7,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "5.31.6", | ||
"version": "5.32.0", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=10" |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2197101
62747