New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse import-assertions #12139
Merged
nicolo-ribaudo
merged 10 commits into
main
from
sven/rename-module-attributes-to-import-assertions
Oct 14, 2020
Merged
Parse import-assertions #12139
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
452000c
Rename module-attributes to import-assertions
xtuc 93b5831
Update packages/babel-parser/src/parser/statement.js
xtuc b081457
Rename module-attributes to import-assertions
xtuc a093f33
Update packages/babel-core/src/parser/util/missing-plugin-helper.js
xtuc eb8f418
fix: restore moduleAttributes support
JLHwung 7662634
Update packages/babel-generator/src/generators/modules.js
JLHwung ba35624
remove `version` of `import-assertions`
JLHwung 8bebffc
move import-assertions to stage 3
JLHwung b0601b1
remove "version" options from syntax-import-assertions
JLHwung 39838f0
update test fixtures
JLHwung File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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-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 |
---|---|---|
@@ -0,0 +1 @@ | ||
import foo from "foo.json" assert { type: "json" }; |
8 changes: 8 additions & 0 deletions
8
packages/babel-generator/test/fixtures/types/ImportAssertion/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,8 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"importAssertions" | ||
] | ||
], | ||
"sourceType": "module" | ||
} |
1 change: 1 addition & 0 deletions
1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
import foo from "foo.json" assert { type: "json" }; |
1 change: 0 additions & 1 deletion
1
packages/babel-generator/test/fixtures/types/ImportAttribute/input.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/babel-generator/test/fixtures/types/ImportAttribute/options.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/babel-generator/test/fixtures/types/ImportAttribute/output.js
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...ator/test/fixtures/types/Import2/input.js → .../fixtures/types/ModuleAttributes/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,3 @@ | ||
import "foo.json" with type: "json"; | ||
import("foo.json", { with: { type: "json" } },); | ||
|
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...tor/test/fixtures/types/Import2/output.js → ...fixtures/types/ModuleAttributes/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,3 +1,4 @@ | ||
import "foo.json" with type: "json"; | ||
import("foo.json", { | ||
with: { | ||
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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...in/module-attributes-dynamic/options.json → ...in/import-assertions-dynamic/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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleAttributes' (1:24)", | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'importAssertions' (1:24)", | ||
"sourceType": "module", | ||
"plugins": [] | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/experimental/_no-plugin/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 foo from "foo.json" assert { type: "json" }; |
5 changes: 5 additions & 0 deletions
5
packages/babel-parser/test/fixtures/experimental/_no-plugin/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,5 @@ | ||
{ | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'importAssertions' (1:27)", | ||
"sourceType": "module", | ||
"plugins": [] | ||
} |
6 changes: 2 additions & 4 deletions
6
packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{ | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleAttributes' (1:27)", | ||
"sourceType": "module", | ||
"plugins": [] | ||
} | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleAttributes' (1:27)" | ||
} |
1 change: 1 addition & 0 deletions
1
...er/test/fixtures/experimental/import-assertions/dynamic-import-with-valid-syntax/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("foo.json", { assert: { type: "json" } }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It seems that
import foo from "foo.json" assert {}
are now generated asimport foo from "foo.json"
. Although it is semantically equivalent. I slightly prefer to reserveasserts {}
ifnode.assertions
is not nullish.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that current AST design does not differentiate between
import foo from "foo.json" assert {}
andimport foo from "foo.json"
. Both of them haveassertions
set to[]
.