From f794e360f09b5580ab661a12e230de629771d4d2 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 30 Mar 2015 03:38:14 +1100 Subject: [PATCH] add support for export extensions https://github.com/leebyron/ecmascript-more-export-from - closes #1091 --- src/statement.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/statement.js b/src/statement.js index 9ca10174b9..be8e33786f 100755 --- a/src/statement.js +++ b/src/statement.js @@ -559,10 +559,10 @@ pp.parseExport = function(node) { this.next() // export * from '...' if (this.eat(tt.star)) { - this.expectContextual("from") - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() - this.semicolon() - this.checkExport(node) + if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) { + node.exported = this.parseIdent() + } + this.parseExportFrom(node) return this.finishNode(node, "ExportAllDeclaration") } if (this.eat(tt._default)) { // export default ... @@ -587,6 +587,10 @@ pp.parseExport = function(node) { node.declaration = this.parseStatement(true) node.specifiers = [] node.source = null + } else if (this.type === tt.name) { + node.exported = this.parseIdent() + this.parseExportFrom(node) + return this.finishNode(node, "ExportNamespaceDeclaration") } else { // export { x, y as z } [from '...'] node.declaration = null node.specifiers = this.parseExportSpecifiers() @@ -601,6 +605,13 @@ pp.parseExport = function(node) { return this.finishNode(node, "ExportNamedDeclaration") } +pp.parseExportFrom = function(node) { + this.expectContextual("from") + node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + this.semicolon() + this.checkExport(node) +} + pp.shouldParseExportDeclaration = function() { return this.options.features["es7.asyncFunctions"] && this.isContextual("async") }