fix handling of MetaProperty

fixes #12339
This commit is contained in:
Tobias Koppers 2021-01-05 21:26:28 +01:00
parent 84720287e1
commit ae15a701a4
4 changed files with 17 additions and 1 deletions

View File

@ -158,6 +158,8 @@ class ImportMetaPlugin {
const expr = /** @type {MemberExpression} */ (expression);
if (
expr.object.type === "MetaProperty" &&
expr.object.meta.name === "import" &&
expr.object.property.name === "meta" &&
expr.property.type ===
(expr.computed ? "Literal" : "Identifier")
) {

View File

@ -51,6 +51,7 @@ class URLPlugin {
if (
chain.members.length !== 1 ||
chain.object.type !== "MetaProperty" ||
chain.object.meta.name !== "import" ||
chain.object.property.name !== "meta" ||
chain.members[0] !== "url"
)

View File

@ -802,7 +802,7 @@ class JavascriptParser extends Parser {
case "MetaProperty": {
const res = this.callHooksForName(
this.hooks.evaluateTypeof,
"import.meta",
getRootName(expr.argument),
expr
);
if (res !== undefined) return res;

View File

@ -5,7 +5,20 @@ class A {
} else {
this.val = 1;
}
if (typeof new.target !== "function") {
this.val = 0;
}
if (typeof new.target.value !== "function") {
this.val = 0;
}
if (typeof new.target.unknown !== "undefined") {
this.val = 0;
}
if (!new.target.value) {
this.val = 0;
}
}
static value() {}
}
class B extends A {}