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

Allow parsing the with keyword for import attributes #21

Merged
merged 1 commit into from May 12, 2023

Conversation

nicolo-ribaudo
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo commented May 10, 2023

This PR adds support for the with keyword, given that the proposal has recently been changed to https://github.com/tc39/proposal-import-attributes.

My goal is to have as few changes as possible (no new package, no AST changes, no major release), so that it will be transparently supported by the rest of the ecosystem:

Releasing this PR as version 1.9.0 will retroactively add support for import attributes to Webpack and Rollup, helping the community to migrate.

(Btw, where is the code for 1.8.0? It's on npm but not on GitHub)

cc @lukastaegert @TheLarkInn

},
"assertions": [
{
"type": "ImportAttribute",
Copy link
Owner

Choose a reason for hiding this comment

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

Just a though. We could preserve the with/assert keyword used in the ImportAttribute node, tooling could warn users to migrate.

Copy link
Owner

@xtuc xtuc left a comment

Choose a reason for hiding this comment

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

@xtuc xtuc merged commit 91d68da into xtuc:main May 12, 2023
3 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the import-attributes branch May 12, 2023 13:08
"value": "./foo.json",
"raw": "\"./foo.json\""
},
"assertions": [
Copy link

Choose a reason for hiding this comment

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

Looking at (the consensus?) https://github.com/estree/estree/blob/master/experimental/import-attributes.md, shouldn't this be changed to attributes? Any interest in pursuing this? From Rollup side, I would much prefer to go with the spec, even if it means we need to do some code changes. At that point, one could also see that in the absence of attributes, attributes is an empty array (in previous versions, assertions was undefined, which deviates both from ESTree and the behavior of other acorn nodes, cf #15).

Choose a reason for hiding this comment

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

Sorry for being a little late on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes :) I think we should publish that as a new acorn-import-attributes package that properly supports this feature.

My goal with this PR was to quickly get it supported in all the tools that currently use this package, in the most frictionless way.I didn't realize this doesn't work for Rollup because it bundles its dependencies, but in other tools now with already "just works".

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, i'm planning to rename all assertions references to attributes, under the new attribute npm package.

Copy link
Owner

Choose a reason for hiding this comment

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

Published acorn-import-attributes@1.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants