Default importAttributesKeyword to with#16977
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58359 |
65843c4 to
1d2a877
Compare
| @@ -1,4 +1,3 @@ | |||
| { | |||
| "BABEL_8_BREAKING": true, | |||
There was a problem hiding this comment.
The attributes-with-to-default is merged with this case now that we output the standard syntax by default.
| @@ -1 +1 @@ | |||
| import "a" with type: "json"; No newline at end of file | |||
| import "a" with { type: "json" }; No newline at end of file | |||
There was a problem hiding this comment.
We output the standard syntax on input import "a" with { type: "json" }; and options
{
"BABEL_8_BREAKING": false,
"plugins": ["importAssertions"]
}| @@ -1 +1 @@ | |||
| import "a" with type: "json"; No newline at end of file | |||
| import "a" with { type: "json" }; No newline at end of file | |||
There was a problem hiding this comment.
We output the standard syntax on input import "a" assert { type: "json" }; and options
{
"BABEL_8_BREAKING": true,
"plugins": ["deprecatedImportAssert"]
}f57dd7f to
e1fed8c
Compare
| { | ||
| "BABEL_8_BREAKING": false, | ||
| "plugins": ["importAssertions"], | ||
| "warns": "You are using import attributes, without specifying the desired output syntax.", |
There was a problem hiding this comment.
The input is already valid: import "a" with { type: "json" };
From what I understand we already avoid this with
Perhaps we could add |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I have a light preference for doing the opposite: for Babel 7, we store on .extra that the user is using the new syntax.
However, it's more out of a purity semver point of view, and I agree that it's very likely that this wouldn't break anybody. https://www.npmjs.com/package/@babel/plugin-syntax-module-attributes has been deprecated for ages, and it has basically no downloads.
|
If we add Like Nicolò has mentioned, there is basically no downloads for the long deprecated syntax, I would prefer to promote the ES2025 syntax and hide the IAK option: This option has served its purpose well and it's time to move on. |
|
Wdyt about doing this in a minor release, so we can at least mention it in the blog post? |
* fix: default importAttributesKeyword to with * feat: mark module attributes with deprecated syntax meta * polish: print missing IAK warning when using non-standard syntax * fix: default to with-legacy if deprecatedWithLegacySyntax * revert some test changes * test: update the first thrown fixture
In this PR we defaults the Babel 7 generator option
importAttributesKeyword(IAK) towithand prints the missing IAK warning only when users are using a non-standard import attributes syntax, e.g.assert { type: "json" }orwith type: "json".Given that the import attributes proposal has reached stage 4, I think such a change should be considered spec compliance: Babel should output valid JS syntax by default and we should not nudge users for the
importAttributesKeywordoption unless they are actually using the out-dated syntax.Caveat: it could be a breaking change for users when these conditions are both satisfied:
with type: "json"@babel/parserbut chooses to update@babel/generatorto the latest version