Content-Length: 417192 | pFad | https://github.com/babel/babel/pull/16480

6D Expose wether a module has TLA or not as `.extra.async` by nicolo-ribaudo · Pull Request #16480 · babel/babel · GitHub
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

Expose wether a module has TLA or not as .extra.async #16480

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented May 7, 2024

Q                       A
Fixed Issues? Fixes #16471
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The parser already has this info, and having to detect it by yourself is error prone (due to computed keys and decorators).

We can also use this to warn in the CJS transform when there is top-level await (in a follow-up).

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories pkg: parser labels May 7, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented May 7, 2024

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

@liuxingbaoyu
Copy link
Member

Would it be better to just use topLevelAwait as the name?
Can we put hasTopLevelAwait in BaseParser together with sawUnambiguousESM, which would save a place, since 1 << 11 is already there :)

@nicolo-ribaudo nicolo-ribaudo force-pushed the parser-module-async branch from 64070c7 to 0b4799c Compare May 7, 2024 07:57
@nicolo-ribaudo
Copy link
Member Author

Renamed to topLevelAwait. I prefer to keep this in .state.flags, because currently we have still 20 bits of space that are being "wasted" there :) If anything, I would move sawUnambiguousESM to there.

@nicolo-ribaudo nicolo-ribaudo force-pushed the parser-module-async branch from 5e72f56 to d3dd293 Compare May 7, 2024 09:36
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Can you add a test case for module expressions if there aren't such test? The current implementation should already work.

@nicolo-ribaudo nicolo-ribaudo added this to the v7.25.0 milestone May 14, 2024
@nicolo-ribaudo nicolo-ribaudo added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label May 16, 2024
@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 Oct 26, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
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: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[parser] Expose somehing like program.extra.async to easily know if a module uses top-level await
4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/babel/babel/pull/16480

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy