Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create parser plugin "topLevelAwait"
- Loading branch information
1 parent
25b3526
commit 803d331
Showing
22 changed files
with
489 additions
and
5 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
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/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 await 0; |
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/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": ["topLevelAwait"], | ||
"sourceType": "module" | ||
} |
85 changes: 85 additions & 0 deletions
85
packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/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,85 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 23, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 23 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 23, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 23 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start": 0, | ||
"end": 23, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 23 | ||
} | ||
}, | ||
"declaration": { | ||
"type": "AwaitExpression", | ||
"start": 15, | ||
"end": 22, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 15 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 22 | ||
} | ||
}, | ||
"argument": { | ||
"type": "NumericLiteral", | ||
"start": 21, | ||
"end": 22, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 21 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 22 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": 0, | ||
"raw": "0" | ||
}, | ||
"value": 0 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/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 @@ | ||
for await (const a of b); |
4 changes: 4 additions & 0 deletions
4
...ges/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/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": ["topLevelAwait"], | ||
"sourceType": "module" | ||
} |
134 changes: 134 additions & 0 deletions
134
...ages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/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,134 @@ | ||
{ | ||
"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": "ForOfStatement", | ||
"start": 0, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
}, | ||
"await": true, | ||
"left": { | ||
"type": "VariableDeclaration", | ||
"start": 11, | ||
"end": 18, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 11 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 18 | ||
} | ||
}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start": 17, | ||
"end": 18, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 17 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 18 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 17, | ||
"end": 18, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 17 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 18 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "const" | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start": 22, | ||
"end": 23, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 22 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 23 | ||
}, | ||
"identifierName": "b" | ||
}, | ||
"name": "b" | ||
}, | ||
"body": { | ||
"type": "EmptyStatement", | ||
"start": 24, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 24 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/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 @@ | ||
for await (const a of b); |
5 changes: 5 additions & 0 deletions
5
...ges/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/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,5 @@ | ||
{ | ||
"plugins": ["topLevelAwait"], | ||
"sourceType": "script", | ||
"throws": "Unexpected token, expected \"(\" (1:4)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/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 @@ | ||
() => await 0; |
5 changes: 5 additions & 0 deletions
5
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/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,5 @@ | ||
{ | ||
"plugins": ["topLevelAwait"], | ||
"sourceType": "module", | ||
"throws": "Can not use keyword 'await' outside an async function (1:6)" | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/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,3 @@ | ||
if (true) { | ||
await 0; | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/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": ["topLevelAwait"], | ||
"sourceType": "module" | ||
} |
Oops, something went wrong.