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

Implement new transform-runtime protocol for runtime package name #160

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 30, 2023

The goal of this new API is that any polyfill provider can specify their own polyfilled version of @babel/runtime (such as @babel/runtime-corejs3), instead of hard-coding @babel/runtime, @babel/runtime-corejs2 and @babel/runtime-corejs3 in @babel/plugin-transform-runtime.

This is done by returning a runtimeName: string property in the polyfill provider result object, which will be picked up by @babel/plugin-transform-runtime when injecting helpers.

See babel/babel#15531 for the other part of this change. This PR needs to land first.

@@ -22,7 +24,7 @@ type Options = {
entryInjectRegenerator: boolean;
};
"#__secret_key__@babel/runtime__compatibility": void | {
useBabelRuntime: string;
useBabelRuntime: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a breaking change? If so this PR should be landed in a new major.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but these packages are still at 0.x (so breaking changes are in minor releases)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, 0.x -> 0.x+1 is what I mean for a new major.

file.get("runtimeHelpersModuleName") !== runtimeName
) {
console.warn(
`Two different polyfill providers are trying to define two` +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can runtimeHelpersModuleName also record who defined it? So we can simply say that the current provider babel-plugin-polyfill-foo conflicts with another provider babel-plugin-polyfill-bar, please remove one of them. Otherwise users have to dive into the implementation detail and dig about who defined runtimeHelpersModuleName, which could be very frustrating.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@nicolo-ribaudo
Copy link
Member Author

@JLHwung @liuxingbaoyu Any opinion regarding this?

Copy link
Collaborator

@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.

I don't have further comments, the changes look good to me.

@nicolo-ribaudo nicolo-ribaudo merged commit 185c51f into babel:main May 10, 2023
7 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the new-babel-runtime-integration-api branch May 10, 2023 10:07
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

2 participants