[parser] Enable "exportNamespaceFrom" by default (#10521)
This commit is contained in:
parent
d248e2d188
commit
4cd93ab5f3
@ -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,
|
||||
|
||||
3
packages/babel-parser/test/fixtures/es2020/export-ns-from/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/es2020/export-ns-from/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceType": "module"
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)",
|
||||
"plugins": []
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["exportDefaultFrom", "exportNamespaceFrom"],
|
||||
"plugins": ["exportDefaultFrom"],
|
||||
"sourceType": "module"
|
||||
}
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": ["exportNamespaceFrom"]
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["exportNamespaceFrom"],
|
||||
"sourceType": "module"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
export * as A from 'test';
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["exportNamespaceFrom"],
|
||||
"sourceType": "module"
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
|
||||
120
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/output.json
vendored
Normal file
120
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/output.json
vendored
Normal file
@ -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"
|
||||
}
|
||||
|
||||
133
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/output.json
vendored
Normal file
133
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/output.json
vendored
Normal file
@ -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": []
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ export type ParserPlugin =
|
||||
'dynamicImport' |
|
||||
'estree' |
|
||||
'exportDefaultFrom' |
|
||||
'exportNamespaceFrom' |
|
||||
'exportNamespaceFrom' | // deprecated
|
||||
'flow' |
|
||||
'flowComments' |
|
||||
'functionBind' |
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user