Skip to content
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

JS: Support import attributes #14484

Merged
merged 10 commits into from
Oct 16, 2023
Merged

JS: Support import attributes #14484

merged 10 commits into from
Oct 16, 2023

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Oct 12, 2023

Adds support for import attributes, an evolution of import assertions. For example:

import * as foo from 'foo' with { type: 'json' }

When implementing #12382, we thought the syntax of import assertions was unlikely to change. However, it did. The only difference is that instead of assert they now use with. The old syntax is still allowed but deprecated.

In the QL library:

  • the getImportAssertion() predicates are deprecated, their new name is getImportAttributes()
  • DynamicImportExpr::getImportAttributes() is deprecated and renamed to getImportOptions()

Evaluation was uneventful.

Commit-by-commit review recommended.

@aibaars aibaars changed the title Ts53 js JS: Support import attributes Oct 12, 2023
@aibaars aibaars marked this pull request as ready for review October 12, 2023 11:33
@aibaars aibaars requested a review from a team as a code owner October 12, 2023 11:33
Copy link
Contributor

@asgerf asgerf left a comment

Choose a reason for hiding this comment

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

LGTM assuming the evaluation looks good 👍

@erik-krogh
Copy link
Contributor

The evaluations could be on a bigger set of sources.
I usually use nightly-old (50 sources) or default (100).

@aibaars
Copy link
Contributor Author

aibaars commented Oct 16, 2023

The evaluations look good. The only interesting results were syntax that changed locations reported on tests in babel/babel on files like https://github.com/babel/babel/blob/main/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes/input.js

import foo from "foo.json" with type: "json";

The tests use the with syntax but lack the { } around the attributes. So instead of complaining about an unexpected with the parser now complains about missing {.

@aibaars aibaars merged commit 0e3369f into github:main Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants