Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse attributes of import expression with estree plugin (#13284)
* Parse attributes of import expression with estree plugin * Add tests * Update packages/babel-parser/src/types.js Co-authored-by: Hu谩ng J霉nli脿ng <jlhwung@gmail.com> Co-authored-by: Hu谩ng J霉nli脿ng <jlhwung@gmail.com>
- Loading branch information
1 parent
e74b3fb
commit 1d54419
Showing
8 changed files
with
110 additions
and
0 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/estree/dynamic-import/import-assertions-null/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 @@ | ||
import("module"); |
3 changes: 3 additions & 0 deletions
3
...ages/babel-parser/test/fixtures/estree/dynamic-import/import-assertions-null/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,3 @@ | ||
{ | ||
"plugins": ["estree", "importAssertions"] | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/babel-parser/test/fixtures/estree/dynamic-import/import-assertions-null/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,27 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"expression": { | ||
"type": "ImportExpression", | ||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, | ||
"source": { | ||
"type": "Literal", | ||
"start":7,"end":15,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":15}}, | ||
"value": "module", | ||
"raw": "\"module\"" | ||
}, | ||
"attributes": null | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/estree/dynamic-import/import-assertions/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 @@ | ||
import("module", { assert: { type: "json" } }); |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/estree/dynamic-import/import-assertions/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,3 @@ | ||
{ | ||
"plugins": ["estree", "importAssertions"] | ||
} |
70 changes: 70 additions & 0 deletions
70
packages/babel-parser/test/fixtures/estree/dynamic-import/import-assertions/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,70 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":47}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":47}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":47}}, | ||
"expression": { | ||
"type": "ImportExpression", | ||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}}, | ||
"source": { | ||
"type": "Literal", | ||
"start":7,"end":15,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":15}}, | ||
"value": "module", | ||
"raw": "\"module\"" | ||
}, | ||
"attributes": { | ||
"type": "ObjectExpression", | ||
"start":17,"end":45,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":45}}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":19,"end":43,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":43}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":19,"end":25,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":25},"identifierName":"assert"}, | ||
"name": "assert" | ||
}, | ||
"computed": false, | ||
"shorthand": false, | ||
"value": { | ||
"type": "ObjectExpression", | ||
"start":27,"end":43,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":43}}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":29,"end":41,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":41}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":29,"end":33,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":33},"identifierName":"type"}, | ||
"name": "type" | ||
}, | ||
"computed": false, | ||
"shorthand": false, | ||
"value": { | ||
"type": "Literal", | ||
"start":35,"end":41,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":41}}, | ||
"value": "json", | ||
"raw": "\"json\"" | ||
}, | ||
"kind": "init" | ||
} | ||
] | ||
}, | ||
"kind": "init" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |