Skip to content

Commit

Permalink
Enable import.meta by default in @babel/parser (#11406)
Browse files Browse the repository at this point in the history
  • Loading branch information
kik-o committed May 24, 2020
1 parent 75a6530 commit 5dd7f43
Show file tree
Hide file tree
Showing 26 changed files with 10 additions and 207 deletions.
4 changes: 0 additions & 4 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1227,8 +1227,6 @@ export default class ExpressionParser extends LValParser {
this.expect(tt.dot);

if (this.isContextual("meta")) {
this.expectPlugin("importMeta");

if (!this.inModule) {
this.raiseWithData(
id.start,
Expand All @@ -1237,8 +1235,6 @@ export default class ExpressionParser extends LValParser {
);
}
this.sawUnambiguousESM = true;
} else if (!this.hasPlugin("importMeta")) {
this.raise(id.start, Errors.ImportCallArityLtOne);
}

return this.parseMetaProperty(node, id, "meta");
Expand Down
1 change: 0 additions & 1 deletion packages/babel-parser/src/parser/location.js
Expand Up @@ -68,7 +68,6 @@ export const Errors = Object.freeze({
ImportCallArgumentTrailingComma:
"Trailing comma is disallowed inside import(...) arguments",
ImportCallArity: "import() requires exactly one argument",
ImportCallArityLtOne: "Dynamic imports require a parameter: import('a.js')",
ImportCallNotNewExpression: "Cannot use new with import(...)",
ImportCallSpreadArgument: "... is not allowed in import()",
ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`,
Expand Down
Expand Up @@ -49,4 +49,4 @@
],
"directives": []
}
}
}
Expand Up @@ -2,7 +2,6 @@
"type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Dynamic imports require a parameter: import('a.js') (2:9)",
"SyntaxError: The only valid meta property for import is import.meta (2:16)"
],
"program": {
Expand Down
@@ -1,4 +1,3 @@
{
"plugins": ["importMeta"],
"sourceType": "script"
}
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 5dd7f43

Please sign in to comment.