Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Import Assertions for re-export statement (#12249)
- Loading branch information
1 parent
f5bd9f2
commit faaebfe
Showing
33 changed files
with
763 additions
and
18 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
5 changes: 4 additions & 1 deletion
5
packages/babel-generator/test/fixtures/types/ImportAssertion/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 |
---|---|---|
@@ -1 +1,4 @@ | ||
import foo from "foo.json" assert { type: "json" }; | ||
import foo1 from "foo.json" assert { type: "json" }; | ||
export { foo2 } from "foo.json" assert { type: "json" }; | ||
export * from "foo.json" assert { type: "json" }; | ||
export * as foo3 from "foo.json" assert { type: "json" }; |
5 changes: 4 additions & 1 deletion
5
packages/babel-generator/test/fixtures/types/ImportAssertion/output.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 |
---|---|---|
@@ -1 +1,4 @@ | ||
import foo from "foo.json" assert { type: "json" }; | ||
import foo1 from "foo.json" assert { type: "json" }; | ||
export { foo2 } from "foo.json" assert { type: "json" }; | ||
export * from "foo.json" assert { type: "json" }; | ||
export * as foo3 from "foo.json" assert { type: "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
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
2 changes: 2 additions & 0 deletions
2
...ental/import-assertions/invalid-syntax-export-with-and-attributes-multiple-lines/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 { x } from "foo" assert | ||
{ type: "json" } |
63 changes: 63 additions & 0 deletions
63
...al/import-assertions/invalid-syntax-export-with-and-attributes-multiple-lines/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,63 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportNamedDeclaration", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, | ||
"specifiers": [ | ||
{ | ||
"type": "ExportSpecifier", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, | ||
"local": { | ||
"type": "Identifier", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"exported": { | ||
"type": "Identifier", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, | ||
"name": "x" | ||
} | ||
} | ||
], | ||
"source": { | ||
"type": "StringLiteral", | ||
"start":18,"end":23,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":23}}, | ||
"extra": { | ||
"rawValue": "foo", | ||
"raw": "\"foo\"" | ||
}, | ||
"value": "foo" | ||
}, | ||
"declaration": null, | ||
"assertions": [ | ||
{ | ||
"type": "ImportAttribute", | ||
"start":33,"end":45,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":14}}, | ||
"key": { | ||
"type": "Identifier", | ||
"start":33,"end":37,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":6},"identifierName":"type"}, | ||
"name": "type" | ||
}, | ||
"value": { | ||
"type": "StringLiteral", | ||
"start":39,"end":45,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":14}}, | ||
"extra": { | ||
"rawValue": "json", | ||
"raw": "\"json\"" | ||
}, | ||
"value": "json" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...perimental/import-assertions/invalid-syntax-export-without-attributes-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 { x } from "foo" assert; |
5 changes: 5 additions & 0 deletions
5
...mental/import-assertions/invalid-syntax-export-without-attributes-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,5 @@ | ||
{ | ||
"plugins": [["importAssertions"]], | ||
"sourceType": "module", | ||
"throws": "Unexpected token (1:30)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/import-assertions/string-literal/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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import foo from "foo.json" assert { for: "for" } | ||
export { foo } from "foo.json" assert { for: "for" } |
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/import-assertions/trailing-comma/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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import foo from "foo" assert { type: "json", } | ||
export { foo } from "foo" assert { type: "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
1 change: 1 addition & 0 deletions
1
...tures/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/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 * as foo from "foo.json" assert { type: "json" }; |
57 changes: 57 additions & 0 deletions
57
...es/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/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,57 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":56}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":56}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportNamedDeclaration", | ||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":56}}, | ||
"specifiers": [ | ||
{ | ||
"type": "ExportNamespaceSpecifier", | ||
"start":7,"end":15,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":15}}, | ||
"exported": { | ||
"type": "Identifier", | ||
"start":12,"end":15,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":15},"identifierName":"foo"}, | ||
"name": "foo" | ||
} | ||
} | ||
], | ||
"source": { | ||
"type": "StringLiteral", | ||
"start":21,"end":31,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":31}}, | ||
"extra": { | ||
"rawValue": "foo.json", | ||
"raw": "\"foo.json\"" | ||
}, | ||
"value": "foo.json" | ||
}, | ||
"assertions": [ | ||
{ | ||
"type": "ImportAttribute", | ||
"start":41,"end":53,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":53}}, | ||
"key": { | ||
"type": "Identifier", | ||
"start":41,"end":45,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":45},"identifierName":"type"}, | ||
"name": "type" | ||
}, | ||
"value": { | ||
"type": "StringLiteral", | ||
"start":47,"end":53,"loc":{"start":{"line":1,"column":47},"end":{"line":1,"column":53}}, | ||
"extra": { | ||
"rawValue": "json", | ||
"raw": "\"json\"" | ||
}, | ||
"value": "json" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
Oops, something went wrong.