Skip to content

Relax import assertion key-is-type constraint#13409

Merged
JLHwung merged 4 commits intobabel:mainfrom
JLHwung:relax-import-assertion-type-key
Jun 2, 2021
Merged

Relax import assertion key-is-type constraint#13409
JLHwung merged 4 commits intobabel:mainfrom
JLHwung:relax-import-assertion-type-key

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Jun 1, 2021

Q                       A
Fixed Issues? #13347 (comment)
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

This PR relaxes previously implemented constraint that the AssertionKey must be of string value "type". Note that babel parser also supports moduleAttributes, a legacy version of importAssertions which shares similar behaviour. The behaviour in moduleAttributes is not changed as the plugin is deprecated and will be removed in Babel 8.

/cc @xtuc

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories pkg: parser labels Jun 1, 2021
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Jun 1, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46622/

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Jun 1, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 752602e:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

if (keyName !== "type") {
this.raise(
node.key.start,
Errors.ModuleAttributeDifferentFromType,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we can not remove ModuleAttributeDifferentFromType from Error templates because it is still used in parseModuleAttributes.

nicolo-ribaudo
nicolo-ribaudo previously approved these changes Jun 2, 2021
@nicolo-ribaudo nicolo-ribaudo dismissed their stale review June 2, 2021 00:21

Whops, I looked at the code without looking at CI

@JLHwung JLHwung force-pushed the relax-import-assertion-type-key branch from 39a0c52 to 752602e Compare June 2, 2021 00:41
@JLHwung JLHwung merged commit b8175ec into babel:main Jun 2, 2021
@JLHwung JLHwung deleted the relax-import-assertion-type-key branch June 2, 2021 11:51
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants