Better error message for import.meta and import() without plugin (#6962)
The correct error was already thrown when they weren't in statement position.
This commit is contained in:
parent
ac72bfbd33
commit
62bbee97d7
@ -129,11 +129,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
return this.parseEmptyStatement(node);
|
||||
case tt._export:
|
||||
case tt._import: {
|
||||
if (
|
||||
(this.hasPlugin("dynamicImport") &&
|
||||
this.lookahead().type === tt.parenL) ||
|
||||
(this.hasPlugin("importMeta") && this.lookahead().type === tt.dot)
|
||||
) {
|
||||
const nextToken = this.lookahead();
|
||||
if (nextToken.type === tt.parenL || nextToken.type === tt.dot) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \"{\" (1:6)",
|
||||
"throws": "This experimental syntax requires enabling the parser plugin: 'dynamicImport' (1:0)",
|
||||
"plugins": []
|
||||
}
|
||||
|
||||
1
packages/babylon/test/fixtures/experimental/import-meta/without-plugin/actual.js
vendored
Normal file
1
packages/babylon/test/fixtures/experimental/import-meta/without-plugin/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
import.meta;
|
||||
4
packages/babylon/test/fixtures/experimental/import-meta/without-plugin/options.json
vendored
Normal file
4
packages/babylon/test/fixtures/experimental/import-meta/without-plugin/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "This experimental syntax requires enabling the parser plugin: 'importMeta' (1:7)",
|
||||
"plugins": []
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user