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

Fix backward compat for semver checks in class&regexp feat plugins #15605

Merged
merged 1 commit into from May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -96,6 +96,15 @@ export function createClassFeaturePlugin({
pre(file) {
enableFeature(file, feature, loose);

if (!process.env.BABEL_8_BREAKING) {
// Until 7.21.4, we used to encode the version as a number.
// If file.get(versionKey) is a number, it has thus been
// set by an older version of this plugin.
if (typeof file.get(versionKey) === "number") {
file.set(versionKey, PACKAGE_JSON.version);
return;
}
}
if (
!file.get(versionKey) ||
semver.lt(file.get(versionKey), PACKAGE_JSON.version)
Expand Down
11 changes: 10 additions & 1 deletion packages/babel-helper-create-regexp-features-plugin/src/index.ts
Expand Up @@ -82,8 +82,17 @@ export function createRegExpFeaturePlugin({
}
}

if (!process.env.BABEL_8_BREAKING) {
// Until 7.21.4, we used to encode the version as a number.
// If file.get(versionKey) is a number, it has thus been
// set by an older version of this plugin.
if (typeof file.get(versionKey) === "number") {
file.set(versionKey, PACKAGE_JSON.version);
return;
}
}
if (
!file.has(versionKey) ||
!file.get(versionKey) ||
semver.lt(file.get(versionKey), PACKAGE_JSON.version)
) {
file.set(versionKey, PACKAGE_JSON.version);
Expand Down