Skip to content

Commit

Permalink
[parser] Enable "exportNamespaceFrom" by default (#10521)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 29, 2019
1 parent d248e2d commit 4cd93ab
Show file tree
Hide file tree
Showing 22 changed files with 263 additions and 27 deletions.
1 change: 0 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -1719,7 +1719,6 @@ export default class StatementParser extends ExpressionParser {
maybeParseExportNamespaceSpecifier(node: N.Node): boolean {
if (this.isContextual("as")) {
if (!node.specifiers) node.specifiers = [];
this.expectPlugin("exportNamespaceFrom");

const specifier = this.startNodeAt(
this.state.lastTokStart,
Expand Down
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}

This file was deleted.

@@ -1,4 +1,4 @@
{
"plugins": ["exportDefaultFrom", "exportNamespaceFrom"],
"plugins": ["exportDefaultFrom"],
"sourceType": "module"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,3 +1,3 @@
{
"plugins": ["jsx", "flow", "exportNamespaceFrom"]
"plugins": ["jsx", "flow"]
}
@@ -1,5 +1,5 @@
{
"sourceType": "module",
"plugins": ["flow", "exportNamespaceFrom"],
"plugins": ["flow"],
"throws": "Unexpected token (1:14)"
}
@@ -1,4 +1,4 @@
{
"plugins": ["placeholders", "exportDefaultFrom", "exportNamespaceFrom"],
"plugins": ["placeholders", "exportDefaultFrom"],
"sourceType": "module"
}
@@ -1,5 +1,4 @@
{
"plugins": ["placeholders"],
"sourceType": "module",
"throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)"
"sourceType": "module"
}
@@ -0,0 +1,120 @@
{
"type": "File",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"specifiers": [
{
"type": "ExportNamespaceSpecifier",
"start": 7,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 20
}
},
"exported": {
"type": "Placeholder",
"start": 12,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 20
}
},
"name": {
"type": "Identifier",
"start": 14,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "STAR"
},
"name": "STAR"
},
"expectedNode": "Identifier"
}
}
],
"source": {
"type": "StringLiteral",
"start": 26,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 32
}
},
"extra": {
"rawValue": "file",
"raw": "\"file\""
},
"value": "file"
}
}
],
"directives": []
}
}
@@ -1,5 +1,4 @@
{
"plugins": ["placeholders"],
"sourceType": "module",
"throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)"
"sourceType": "module"
}
@@ -0,0 +1,133 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"specifiers": [
{
"type": "ExportNamespaceSpecifier",
"start": 7,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 20
}
},
"exported": {
"type": "Placeholder",
"start": 12,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 20
}
},
"name": {
"type": "Identifier",
"start": 14,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "STAR"
},
"name": "STAR"
},
"expectedNode": "Identifier"
}
}
],
"source": {
"type": "Placeholder",
"start": 26,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 34
}
},
"name": {
"type": "Identifier",
"start": 28,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 32
},
"identifierName": "FILE"
},
"name": "FILE"
},
"expectedNode": "StringLiteral"
}
}
],
"directives": []
}
}
2 changes: 1 addition & 1 deletion packages/babel-parser/typings/babel-parser.d.ts
Expand Up @@ -106,7 +106,7 @@ export type ParserPlugin =
'dynamicImport' |
'estree' |
'exportDefaultFrom' |
'exportNamespaceFrom' |
'exportNamespaceFrom' | // deprecated
'flow' |
'flowComments' |
'functionBind' |
Expand Down

0 comments on commit 4cd93ab

Please sign in to comment.