Make the unambiguous grammar select module when import.meta is used.
This commit is contained in:
parent
958551fd89
commit
3c8e9acd4a
@ -957,6 +957,8 @@ export default class ExpressionParser extends LValParser {
|
||||
{ code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" },
|
||||
);
|
||||
}
|
||||
this.sawUnambiguousESM = true;
|
||||
|
||||
return this.parseMetaProperty(node, id, "meta");
|
||||
}
|
||||
|
||||
|
||||
1
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/input.js
vendored
Normal file
1
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log(import.meta);
|
||||
4
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/options.json
vendored
Normal file
4
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"sourceType": "unambiguous",
|
||||
"plugins": ["importMeta"]
|
||||
}
|
||||
165
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/output.json
vendored
Normal file
165
packages/babylon/test/fixtures/core/sourcetype-unambiguous/import-meta/output.json
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 0,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 0,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start": 0,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "console"
|
||||
},
|
||||
"name": "console"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "log"
|
||||
},
|
||||
"name": "log"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "MetaProperty",
|
||||
"start": 12,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "import"
|
||||
},
|
||||
"name": "import"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"identifierName": "meta"
|
||||
},
|
||||
"name": "meta"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user