Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parser] Enable "exportNamespaceFrom" by default #10521

Merged
merged 1 commit into from Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -1712,7 +1712,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if a /** @deprecated */ annotation preceding the literal would work, or if it only works with enums

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check 👍

'flow' |
'flowComments' |
'functionBind' |
Expand Down