Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly parse
export default from
when exportDefaultFrom
is not …
…enabled (#11676) Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
3874470
commit 71d3527
Showing
22 changed files
with
279 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...t/fixtures/esprima/es2015-export-declaration/export-default-from-as-identifier-2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from (bar); |
33 changes: 33 additions & 0 deletions
33
...ixtures/esprima/es2015-export-declaration/export-default-from-as-identifier-2/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"declaration": { | ||
"type": "CallExpression", | ||
"start":15,"end":25,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":25}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19},"identifierName":"from"}, | ||
"name": "from" | ||
}, | ||
"arguments": [ | ||
{ | ||
"type": "Identifier", | ||
"start":21,"end":24,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":24},"identifierName":"bar"}, | ||
"name": "bar" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...t/fixtures/esprima/es2015-export-declaration/export-default-from-as-identifier-3/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from ?? 42; |
36 changes: 36 additions & 0 deletions
36
...ixtures/esprima/es2015-export-declaration/export-default-from-as-identifier-3/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"declaration": { | ||
"type": "LogicalExpression", | ||
"start":15,"end":25,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":25}}, | ||
"left": { | ||
"type": "Identifier", | ||
"start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19},"identifierName":"from"}, | ||
"name": "from" | ||
}, | ||
"operator": "??", | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}}, | ||
"extra": { | ||
"rawValue": 42, | ||
"raw": "42" | ||
}, | ||
"value": 42 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...est/fixtures/esprima/es2015-export-declaration/export-default-from-as-identifier/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from; |
22 changes: 22 additions & 0 deletions
22
.../fixtures/esprima/es2015-export-declaration/export-default-from-as-identifier/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"declaration": { | ||
"type": "Identifier", | ||
"start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19},"identifierName":"from"}, | ||
"name": "from" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...es/babel-parser/test/fixtures/experimental/export-extensions/default-default-asi/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export default from | ||
"bar"; |
4 changes: 4 additions & 0 deletions
4
...abel-parser/test/fixtures/experimental/export-extensions/default-default-asi/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": ["exportDefaultFrom"] | ||
} |
37 changes: 37 additions & 0 deletions
37
...babel-parser/test/fixtures/experimental/export-extensions/default-default-asi/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":6}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":6}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportNamedDeclaration", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":6}}, | ||
"specifiers": [ | ||
{ | ||
"type": "ExportDefaultSpecifier", | ||
"start":7,"end":14,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}, | ||
"exported": { | ||
"type": "Identifier", | ||
"start":7,"end":14,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14},"identifierName":"default"}, | ||
"name": "default" | ||
} | ||
} | ||
], | ||
"source": { | ||
"type": "StringLiteral", | ||
"start":20,"end":25,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":5}}, | ||
"extra": { | ||
"rawValue": "bar", | ||
"raw": "\"bar\"" | ||
}, | ||
"value": "bar" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ser/test/fixtures/experimental/export-extensions/default-from-identifier-escaped/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default \u{66}rom; |
4 changes: 4 additions & 0 deletions
4
...test/fixtures/experimental/export-extensions/default-from-identifier-escaped/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": ["exportDefaultFrom"], | ||
"sourceType": "module" | ||
} |
22 changes: 22 additions & 0 deletions
22
.../test/fixtures/experimental/export-extensions/default-from-identifier-escaped/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, | ||
"declaration": { | ||
"type": "Identifier", | ||
"start":15,"end":24,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":24},"identifierName":"from"}, | ||
"name": "from" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...st/fixtures/experimental/export-extensions/default-from-identifier-parenthesized/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default (from); |
4 changes: 4 additions & 0 deletions
4
...ixtures/experimental/export-extensions/default-from-identifier-parenthesized/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": ["exportDefaultFrom"], | ||
"sourceType": "module" | ||
} |
26 changes: 26 additions & 0 deletions
26
...fixtures/experimental/export-extensions/default-from-identifier-parenthesized/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"declaration": { | ||
"type": "Identifier", | ||
"start":16,"end":20,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":20},"identifierName":"from"}, | ||
"name": "from", | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 15 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ser/test/fixtures/experimental/export-extensions/invalid-default-from-identifier/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from; |
4 changes: 4 additions & 0 deletions
4
...test/fixtures/experimental/export-extensions/invalid-default-from-identifier/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": ["exportDefaultFrom"], | ||
"sourceType": "module" | ||
} |
25 changes: 25 additions & 0 deletions
25
.../test/fixtures/experimental/export-extensions/invalid-default-from-identifier/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"errors": [ | ||
"SyntaxError: 'from' is not allowed as an identifier after 'export default' (1:15)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"declaration": { | ||
"type": "Identifier", | ||
"start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19},"identifierName":"from"}, | ||
"name": "from" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |