Add plugin for import.meta proposal (#544)

* Add plugin for import.meta proposal

Fixes https://github.com/babel/babylon/issues/539

* Tests for assignment/mutation of import.meta

* Use correct identifier in failure message

* Simpler & more consistent script errors for import.meta
This commit is contained in:
Jan Olaf Krems
2017-05-30 16:28:51 -07:00
committed by Henry Zhu
parent 2f5d146d54
commit d4e842d4eb
15 changed files with 1164 additions and 2 deletions

View File

@@ -106,7 +106,8 @@ export default class StatementParser extends ExpressionParser {
case tt.semi: return this.parseEmptyStatement(node);
case tt._export:
case tt._import:
if (this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL) break;
if ((this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL) ||
(this.hasPlugin("importMeta") && this.lookahead().type === tt.dot)) break;
if (!this.options.allowImportExportEverywhere) {
if (!topLevel) {