Support Import Assertions for re-export statement (#12249)
This commit is contained in:
parent
f5bd9f2013
commit
faaebfe91f
@ -53,6 +53,7 @@ export function ExportAllDeclaration(node: Object) {
|
|||||||
this.word("from");
|
this.word("from");
|
||||||
this.space();
|
this.space();
|
||||||
this.print(node.source, node);
|
this.print(node.source, node);
|
||||||
|
this.printAssertions(node);
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ function ExportDeclaration(node: Object) {
|
|||||||
this.word("from");
|
this.word("from");
|
||||||
this.space();
|
this.space();
|
||||||
this.print(node.source, node);
|
this.print(node.source, node);
|
||||||
|
this.printAssertions(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
@ -180,19 +182,10 @@ export function ImportDeclaration(node: Object) {
|
|||||||
|
|
||||||
this.print(node.source, node);
|
this.print(node.source, node);
|
||||||
|
|
||||||
if (node.assertions?.length) {
|
this.printAssertions(node);
|
||||||
this.space();
|
|
||||||
this.word("assert");
|
|
||||||
this.space();
|
|
||||||
this.token("{");
|
|
||||||
this.space();
|
|
||||||
this.printList(node.assertions, node);
|
|
||||||
this.space();
|
|
||||||
this.token("}");
|
|
||||||
}
|
|
||||||
// todo(Babel 8): remove this if branch
|
// todo(Babel 8): remove this if branch
|
||||||
// `module-attributes` support is discontinued, use `import-assertions` instead.
|
// `module-attributes` support is discontinued, use `import-assertions` instead.
|
||||||
else if (node.attributes?.length) {
|
if (node.attributes?.length) {
|
||||||
this.space();
|
this.space();
|
||||||
this.word("with");
|
this.word("with");
|
||||||
this.space();
|
this.space();
|
||||||
|
|||||||
@ -646,6 +646,19 @@ export default class Printer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printAssertions(node: Node) {
|
||||||
|
if (node.assertions?.length) {
|
||||||
|
this.space();
|
||||||
|
this.word("assert");
|
||||||
|
this.space();
|
||||||
|
this.token("{");
|
||||||
|
this.space();
|
||||||
|
this.printList(node.assertions, node);
|
||||||
|
this.space();
|
||||||
|
this.token("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose the node type functions and helpers on the prototype for easy usage.
|
// Expose the node type functions and helpers on the prototype for easy usage.
|
||||||
|
|||||||
@ -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" };
|
||||||
|
|||||||
@ -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" };
|
||||||
@ -1364,6 +1364,7 @@ interface ExportNamedDeclaration <: ModuleDeclaration {
|
|||||||
declaration: Declaration | null;
|
declaration: Declaration | null;
|
||||||
specifiers: [ ExportSpecifier ];
|
specifiers: [ ExportSpecifier ];
|
||||||
source: StringLiteral | null;
|
source: StringLiteral | null;
|
||||||
|
assertions?: [ ImportAttribute ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1924,6 +1924,11 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const assertions = this.maybeParseImportAssertions();
|
||||||
|
if (assertions) {
|
||||||
|
node.assertions = assertions;
|
||||||
|
}
|
||||||
|
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -360,6 +360,12 @@ export type Directive = NodeBase & {
|
|||||||
|
|
||||||
export type DirectiveLiteral = StringLiteral & { type: "DirectiveLiteral" };
|
export type DirectiveLiteral = StringLiteral & { type: "DirectiveLiteral" };
|
||||||
|
|
||||||
|
export type ImportAttribute = NodeBase & {
|
||||||
|
type: "ImportAttribute",
|
||||||
|
key: Identifier | StringLiteral,
|
||||||
|
value: StringLiteral,
|
||||||
|
};
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
|
|
||||||
export type Super = NodeBase & { type: "Super" };
|
export type Super = NodeBase & { type: "Super" };
|
||||||
@ -867,6 +873,8 @@ export type ExportNamedDeclaration = NodeBase & {
|
|||||||
source: ?Literal,
|
source: ?Literal,
|
||||||
|
|
||||||
exportKind?: "type" | "value", // TODO: Not in spec
|
exportKind?: "type" | "value", // TODO: Not in spec
|
||||||
|
|
||||||
|
assertions?: $ReadOnlyArray<ImportAttribute>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ExportSpecifier = NodeBase & {
|
export type ExportSpecifier = NodeBase & {
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
export { x } from "foo" assert
|
||||||
|
{ type: "json" }
|
||||||
@ -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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { x } from "foo" assert;
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"plugins": [["importAssertions"]],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "Unexpected token (1:30)"
|
||||||
|
}
|
||||||
@ -1 +1,2 @@
|
|||||||
import foo from "foo.json" assert { for: "for" }
|
import foo from "foo.json" assert { for: "for" }
|
||||||
|
export { foo } from "foo.json" assert { for: "for" }
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},
|
"start":0,"end":101,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":52}},
|
||||||
"errors": [
|
"errors": [
|
||||||
"SyntaxError: The only accepted module attribute is `type` (1:36)"
|
"SyntaxError: The only accepted module attribute is `type` (1:36)",
|
||||||
|
"SyntaxError: The only accepted module attribute is `type` (2:40)"
|
||||||
],
|
],
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},
|
"start":0,"end":101,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":52}},
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"interpreter": null,
|
"interpreter": null,
|
||||||
"body": [
|
"body": [
|
||||||
@ -53,6 +54,56 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":49,"end":101,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":52}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":58,"end":61,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":58,"end":61,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":58,"end":61,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":69,"end":79,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":89,"end":99,"loc":{"start":{"line":2,"column":40},"end":{"line":2,"column":50}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":89,"end":92,"loc":{"start":{"line":2,"column":40},"end":{"line":2,"column":43},"identifierName":"for"},
|
||||||
|
"name": "for"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":94,"end":99,"loc":{"start":{"line":2,"column":45},"end":{"line":2,"column":50}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "for",
|
||||||
|
"raw": "\"for\""
|
||||||
|
},
|
||||||
|
"value": "for"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
import foo from "foo" assert { type: "json", }
|
import foo from "foo" assert { type: "json", }
|
||||||
|
export { foo } from "foo" assert { type: "json", }
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
"start":0,"end":97,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":50}},
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
"start":0,"end":97,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":50}},
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"interpreter": null,
|
"interpreter": null,
|
||||||
"body": [
|
"body": [
|
||||||
@ -50,6 +50,56 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":47,"end":97,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":50}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":56,"end":59,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":56,"end":59,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":56,"end":59,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":67,"end":72,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":25}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo",
|
||||||
|
"raw": "\"foo\""
|
||||||
|
},
|
||||||
|
"value": "foo"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":82,"end":94,"loc":{"start":{"line":2,"column":35},"end":{"line":2,"column":47}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":82,"end":86,"loc":{"start":{"line":2,"column":35},"end":{"line":2,"column":39},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":88,"end":94,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":47}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
export * as foo from "foo.json" assert { type: "json" };
|
||||||
@ -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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export * from "foo.json" assert { type: "json" };
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportAllDeclaration",
|
||||||
|
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":14,"end":24,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":24}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":34,"end":46,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":46}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":34,"end":38,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":38},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":40,"end":46,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":46}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
export { x } from "foo" assert { type: "json" }
|
||||||
|
[0]
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":3}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":3}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":47}},
|
||||||
|
"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":1,"column":33},"end":{"line":1,"column":45}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":33,"end":37,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":37},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":39,"end":45,"loc":{"start":{"line":1,"column":39},"end":{"line":1,"column":45}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":48,"end":51,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":3}},
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrayExpression",
|
||||||
|
"start":48,"end":51,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":3}},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":49,"end":50,"loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":2}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 0,
|
||||||
|
"raw": "0"
|
||||||
|
},
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json" assert { type: "json" };
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":20,"end":30,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":40,"end":52,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":52}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":40,"end":44,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":44},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":46,"end":52,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":52}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 };
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"importAssertions"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "Only string literals are allowed as module attribute values (1:60)"
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json" assert { lazy: "true" };
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: The only accepted module attribute is `type` (1:40)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":55}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":20,"end":30,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":40,"end":52,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":52}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":40,"end":44,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":44},"identifierName":"lazy"},
|
||||||
|
"name": "lazy"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":46,"end":52,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":52}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "true",
|
||||||
|
"raw": "\"true\""
|
||||||
|
},
|
||||||
|
"value": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json" assert { type: "json", hasOwnProperty: "true" };
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":79,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":79}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: The only accepted module attribute is `type` (1:54)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":79,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":79}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":79,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":79}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":20,"end":30,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":40,"end":52,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":52}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":40,"end":44,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":44},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":46,"end":52,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":52}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":54,"end":76,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":76}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":54,"end":68,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":68},"identifierName":"hasOwnProperty"},
|
||||||
|
"name": "hasOwnProperty"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":70,"end":76,"loc":{"start":{"line":1,"column":70},"end":{"line":1,"column":76}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "true",
|
||||||
|
"raw": "\"true\""
|
||||||
|
},
|
||||||
|
"value": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json" assert { type: "json", type: "html" };
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":69,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":69}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Duplicate key \"type\" is not allowed in module attributes (1:54)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":69,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":69}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":69,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":69}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":20,"end":30,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": [
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":40,"end":52,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":52}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":40,"end":44,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":44},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":46,"end":52,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":52}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "json",
|
||||||
|
"raw": "\"json\""
|
||||||
|
},
|
||||||
|
"value": "json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportAttribute",
|
||||||
|
"start":54,"end":66,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":66}},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":54,"end":58,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":58},"identifierName":"type"},
|
||||||
|
"name": "type"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":60,"end":66,"loc":{"start":{"line":1,"column":60},"end":{"line":1,"column":66}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "html",
|
||||||
|
"raw": "\"html\""
|
||||||
|
},
|
||||||
|
"value": "html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { foo } from "foo.json";
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":20,"end":30,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":30}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "foo.json",
|
||||||
|
"raw": "\"foo.json\""
|
||||||
|
},
|
||||||
|
"value": "foo.json"
|
||||||
|
},
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user