From 1e151654a7fa32065e2085de0b645e5279e52bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 13 Oct 2023 17:41:10 +0900 Subject: [PATCH] Require exact Babel 8 version in `assertVersion` (#15955) --- eslint/babel-eslint-parser/src/parse.cjs | 9 ++++----- packages/babel-core/src/config/helpers/config-api.ts | 4 ---- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-external-helpers/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-proposal-decorators/src/index.ts | 12 ++++++++++-- .../src/transformer-2023-05.ts | 2 +- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-proposal-function-bind/src/index.ts | 6 +++++- .../babel-plugin-proposal-function-sent/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-syntax-decimal/src/index.ts | 6 +++++- packages/babel-plugin-syntax-decorators/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-syntax-do-expressions/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-syntax-flow/src/index.ts | 6 +++++- .../babel-plugin-syntax-function-bind/src/index.ts | 6 +++++- .../babel-plugin-syntax-function-sent/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-syntax-jsx/src/index.ts | 6 +++++- .../babel-plugin-syntax-module-blocks/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-syntax-typescript/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-transform-classes/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-dotall-regex/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-transform-for-of/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-instanceof/src/index.ts | 6 +++++- packages/babel-plugin-transform-jscript/src/index.ts | 6 +++++- .../babel-plugin-transform-json-strings/src/index.ts | 6 +++++- .../babel-plugin-transform-literals/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-modules-amd/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-modules-umd/src/index.ts | 6 +++++- .../babel-plugin-transform-new-target/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-object-super/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-parameters/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-regenerator/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-transform-runtime/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-plugin-transform-spread/src/index.ts | 6 +++++- .../babel-plugin-transform-sticky-regex/src/index.ts | 6 +++++- .../babel-plugin-transform-strict-mode/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../babel-plugin-transform-typescript/src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- .../src/index.ts | 6 +++++- packages/babel-preset-env/src/index.ts | 6 +++++- packages/babel-preset-flow/src/index.ts | 6 +++++- packages/babel-preset-react/src/index.ts | 6 +++++- packages/babel-preset-typescript/src/index.ts | 6 +++++- 110 files changed, 545 insertions(+), 118 deletions(-) diff --git a/eslint/babel-eslint-parser/src/parse.cjs b/eslint/babel-eslint-parser/src/parse.cjs index 5557bf402dba..dd2f29354e7c 100644 --- a/eslint/babel-eslint-parser/src/parse.cjs +++ b/eslint/babel-eslint-parser/src/parse.cjs @@ -13,11 +13,10 @@ let isRunningMinSupportedCoreVersion = null; module.exports = function parse(code, options, client) { // Ensure we're using a version of `@babel/core` that includes `parse()` and `tokTypes`. - let minSupportedCoreVersion = ">=7.2.0"; - // TODO(Babel 8): Update all the version checks - if (process.env.BABEL_8_BREAKING) { - minSupportedCoreVersion += " || >=8.0.0-0"; - } + const minSupportedCoreVersion = + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : ">=7.2.0"; if (typeof isRunningMinSupportedCoreVersion !== "boolean") { isRunningMinSupportedCoreVersion = semver.satisfies( diff --git a/packages/babel-core/src/config/helpers/config-api.ts b/packages/babel-core/src/config/helpers/config-api.ts index d9715a7b9e44..94ff9c745e1f 100644 --- a/packages/babel-core/src/config/helpers/config-api.ts +++ b/packages/babel-core/src/config/helpers/config-api.ts @@ -120,10 +120,6 @@ function assertVersion(range: string | number): void { if (typeof range !== "string") { throw new Error("Expected string or integer value."); } - // TODO(Babel 8): Update all the version checks - if (process.env.BABEL_8_BREAKING) { - range += ` || ^8.0.0-0`; - } if (semver.satisfies(coreVersion, range)) return; diff --git a/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/src/index.ts b/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/src/index.ts index 24c52b6a7c7f..75cb9adc441a 100644 --- a/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/src/index.ts +++ b/packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { shouldTransform } from "./util.ts"; export default declare(api => { - api.assertVersion("^7.16.0"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.16.0", + ); return { name: "plugin-bugfix-safari-id-destructuring-collision-in-function-expression", diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/index.ts b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/index.ts index 8d7649d67e50..e585bea278f9 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/index.ts +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/index.ts @@ -5,7 +5,11 @@ import type { NodePath } from "@babel/traverse"; import type * as t from "@babel/types"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const noDocumentAll = api.assumption("noDocumentAll") ?? false; const pureGetters = api.assumption("pureGetters") ?? false; diff --git a/packages/babel-plugin-external-helpers/src/index.ts b/packages/babel-plugin-external-helpers/src/index.ts index c9f4b67f617f..82554a74d2c4 100644 --- a/packages/babel-plugin-external-helpers/src/index.ts +++ b/packages/babel-plugin-external-helpers/src/index.ts @@ -7,7 +7,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { helperVersion = "7.0.0-beta.0", whitelist = false } = options; diff --git a/packages/babel-plugin-proposal-async-do-expressions/src/index.ts b/packages/babel-plugin-proposal-async-do-expressions/src/index.ts index ef2db9fb71b0..ee99764421c5 100644 --- a/packages/babel-plugin-proposal-async-do-expressions/src/index.ts +++ b/packages/babel-plugin-proposal-async-do-expressions/src/index.ts @@ -4,7 +4,11 @@ import hoistVariables from "@babel/helper-hoist-variables"; import type * as t from "@babel/types"; export default declare(({ types: t, assertVersion }) => { - assertVersion("^7.13.0"); + assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.13.0", + ); return { name: "proposal-async-do-expressions", diff --git a/packages/babel-plugin-proposal-decorators/src/index.ts b/packages/babel-plugin-proposal-decorators/src/index.ts index f0c8a6cb7564..66297bb2337c 100644 --- a/packages/babel-plugin-proposal-decorators/src/index.ts +++ b/packages/babel-plugin-proposal-decorators/src/index.ts @@ -18,7 +18,11 @@ interface Options extends SyntaxOptions { export type { Options }; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); // Options are validated in @babel/plugin-syntax-decorators if (!process.env.BABEL_8_BREAKING) { @@ -45,7 +49,11 @@ export default declare((api, options: Options) => { ) { return transformer2023_05(api, options, version); } else if (!process.env.BABEL_8_BREAKING) { - api.assertVersion("^7.0.2"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.0.2", + ); return createClassFeaturePlugin({ name: "proposal-decorators", diff --git a/packages/babel-plugin-proposal-decorators/src/transformer-2023-05.ts b/packages/babel-plugin-proposal-decorators/src/transformer-2023-05.ts index 1dadbf7283fa..12249ec52a8d 100644 --- a/packages/babel-plugin-proposal-decorators/src/transformer-2023-05.ts +++ b/packages/babel-plugin-proposal-decorators/src/transformer-2023-05.ts @@ -1205,7 +1205,7 @@ export default function ( version: "2023-05" | "2023-01" | "2022-03" | "2021-12", ): PluginObject { if (process.env.BABEL_8_BREAKING) { - assertVersion("^7.21.0"); + assertVersion(process.env.IS_PUBLISH ? PACKAGE_JSON.version : "^7.21.0"); } else { if (version === "2023-05" || version === "2023-01") { assertVersion("^7.21.0"); diff --git a/packages/babel-plugin-proposal-destructuring-private/src/index.ts b/packages/babel-plugin-proposal-destructuring-private/src/index.ts index 69a5f44992f1..8c9306887912 100644 --- a/packages/babel-plugin-proposal-destructuring-private/src/index.ts +++ b/packages/babel-plugin-proposal-destructuring-private/src/index.ts @@ -14,7 +14,11 @@ import type { NodePath, Visitor } from "@babel/traverse"; import type * as t from "@babel/types"; export default declare(function ({ assertVersion, assumption, types: t }) { - assertVersion("^7.17.0"); + assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.17.0", + ); const { assignmentExpression, assignmentPattern, diff --git a/packages/babel-plugin-proposal-do-expressions/src/index.ts b/packages/babel-plugin-proposal-do-expressions/src/index.ts index a13a01da6239..9f28abb124a0 100644 --- a/packages/babel-plugin-proposal-do-expressions/src/index.ts +++ b/packages/babel-plugin-proposal-do-expressions/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxDoExpressions from "@babel/plugin-syntax-do-expressions"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "proposal-do-expressions", diff --git a/packages/babel-plugin-proposal-duplicate-named-capturing-groups-regex/src/index.ts b/packages/babel-plugin-proposal-duplicate-named-capturing-groups-regex/src/index.ts index 73881c932ee4..4c712c84f280 100644 --- a/packages/babel-plugin-proposal-duplicate-named-capturing-groups-regex/src/index.ts +++ b/packages/babel-plugin-proposal-duplicate-named-capturing-groups-regex/src/index.ts @@ -7,7 +7,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion("^7.19.0"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.19.0", + ); const { runtime } = options; if (runtime !== undefined && typeof runtime !== "boolean") { diff --git a/packages/babel-plugin-proposal-explicit-resource-management/src/index.ts b/packages/babel-plugin-proposal-explicit-resource-management/src/index.ts index 2791a328f42b..119a430af53c 100644 --- a/packages/babel-plugin-proposal-explicit-resource-management/src/index.ts +++ b/packages/babel-plugin-proposal-explicit-resource-management/src/index.ts @@ -9,7 +9,11 @@ const enum USING_KIND { } export default declare(api => { - api.assertVersion("^7.22.0"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.22.0", + ); const TOP_LEVEL_USING = new Map(); diff --git a/packages/babel-plugin-proposal-export-default-from/src/index.ts b/packages/babel-plugin-proposal-export-default-from/src/index.ts index 81c388291c5a..d93cadad2f83 100644 --- a/packages/babel-plugin-proposal-export-default-from/src/index.ts +++ b/packages/babel-plugin-proposal-export-default-from/src/index.ts @@ -3,7 +3,11 @@ import syntaxExportDefaultFrom from "@babel/plugin-syntax-export-default-from"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "proposal-export-default-from", diff --git a/packages/babel-plugin-proposal-function-bind/src/index.ts b/packages/babel-plugin-proposal-function-bind/src/index.ts index d82b0fa9d4cb..28380c343ab5 100644 --- a/packages/babel-plugin-proposal-function-bind/src/index.ts +++ b/packages/babel-plugin-proposal-function-bind/src/index.ts @@ -4,7 +4,11 @@ import { types as t } from "@babel/core"; import type { Scope } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function getTempId(scope: Scope) { let id = scope.path.getData("functionBind"); diff --git a/packages/babel-plugin-proposal-function-sent/src/index.ts b/packages/babel-plugin-proposal-function-sent/src/index.ts index 98d43139798e..60996699c767 100644 --- a/packages/babel-plugin-proposal-function-sent/src/index.ts +++ b/packages/babel-plugin-proposal-function-sent/src/index.ts @@ -5,7 +5,11 @@ import { types as t } from "@babel/core"; import type { Visitor } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const isFunctionSent = (node: t.MetaProperty) => t.isIdentifier(node.meta, { name: "function" }) && diff --git a/packages/babel-plugin-proposal-import-attributes-to-assertions/src/index.ts b/packages/babel-plugin-proposal-import-attributes-to-assertions/src/index.ts index 836bd1118e49..b2f3fdadc2dd 100644 --- a/packages/babel-plugin-proposal-import-attributes-to-assertions/src/index.ts +++ b/packages/babel-plugin-proposal-import-attributes-to-assertions/src/index.ts @@ -4,7 +4,11 @@ import type * as t from "@babel/types"; import syntaxImportAttributes from "@babel/plugin-syntax-import-attributes"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "proposal-import-attributes-to-assertions", diff --git a/packages/babel-plugin-proposal-partial-application/src/index.ts b/packages/babel-plugin-proposal-partial-application/src/index.ts index 0b269292d62b..8a8d106b0347 100644 --- a/packages/babel-plugin-proposal-partial-application/src/index.ts +++ b/packages/babel-plugin-proposal-partial-application/src/index.ts @@ -4,7 +4,11 @@ import { types as t } from "@babel/core"; import type { Scope } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); /** * a function to figure out if a call expression has diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/index.ts b/packages/babel-plugin-proposal-pipeline-operator/src/index.ts index 77a6f62ffe14..b6840696d7f8 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/src/index.ts +++ b/packages/babel-plugin-proposal-pipeline-operator/src/index.ts @@ -14,7 +14,11 @@ const visitorsPerProposal = { }; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { proposal } = options; diff --git a/packages/babel-plugin-proposal-record-and-tuple/src/index.ts b/packages/babel-plugin-proposal-record-and-tuple/src/index.ts index 9604ea31ba4a..9ef91681c9ef 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/src/index.ts +++ b/packages/babel-plugin-proposal-record-and-tuple/src/index.ts @@ -38,7 +38,11 @@ type Cache = Map; type ImportCache = WeakMap; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const polyfillModuleName = v.validateStringOption( "polyfillModuleName", diff --git a/packages/babel-plugin-proposal-regexp-modifiers/src/index.ts b/packages/babel-plugin-proposal-regexp-modifiers/src/index.ts index 790db43479aa..77572ff25289 100644 --- a/packages/babel-plugin-proposal-regexp-modifiers/src/index.ts +++ b/packages/babel-plugin-proposal-regexp-modifiers/src/index.ts @@ -3,7 +3,11 @@ import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features- import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion("^7.19.0"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.19.0", + ); return createRegExpFeaturePlugin({ name: "proposal-regexp-modifiers", diff --git a/packages/babel-plugin-proposal-throw-expressions/src/index.ts b/packages/babel-plugin-proposal-throw-expressions/src/index.ts index 5cb1ff73a916..ca4a6cb988ca 100644 --- a/packages/babel-plugin-proposal-throw-expressions/src/index.ts +++ b/packages/babel-plugin-proposal-throw-expressions/src/index.ts @@ -3,7 +3,11 @@ import syntaxThrowExpressions from "@babel/plugin-syntax-throw-expressions"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "proposal-throw-expressions", diff --git a/packages/babel-plugin-syntax-async-do-expressions/src/index.ts b/packages/babel-plugin-syntax-async-do-expressions/src/index.ts index f2805280beae..3dc59c72e8b1 100644 --- a/packages/babel-plugin-syntax-async-do-expressions/src/index.ts +++ b/packages/babel-plugin-syntax-async-do-expressions/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-async-do-expressions", diff --git a/packages/babel-plugin-syntax-decimal/src/index.ts b/packages/babel-plugin-syntax-decimal/src/index.ts index 6e7562d73e5e..72e78fe971c0 100644 --- a/packages/babel-plugin-syntax-decimal/src/index.ts +++ b/packages/babel-plugin-syntax-decimal/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-decimal", diff --git a/packages/babel-plugin-syntax-decorators/src/index.ts b/packages/babel-plugin-syntax-decorators/src/index.ts index 034b8c1a5908..553f1ca17501 100644 --- a/packages/babel-plugin-syntax-decorators/src/index.ts +++ b/packages/babel-plugin-syntax-decorators/src/index.ts @@ -16,7 +16,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); let { version } = options; diff --git a/packages/babel-plugin-syntax-destructuring-private/src/index.ts b/packages/babel-plugin-syntax-destructuring-private/src/index.ts index 021673205f8f..b13e4364ecaf 100644 --- a/packages/babel-plugin-syntax-destructuring-private/src/index.ts +++ b/packages/babel-plugin-syntax-destructuring-private/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-destructuring-private", diff --git a/packages/babel-plugin-syntax-do-expressions/src/index.ts b/packages/babel-plugin-syntax-do-expressions/src/index.ts index f42c925550a4..5d2885b544b7 100644 --- a/packages/babel-plugin-syntax-do-expressions/src/index.ts +++ b/packages/babel-plugin-syntax-do-expressions/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-do-expressions", diff --git a/packages/babel-plugin-syntax-explicit-resource-management/src/index.ts b/packages/babel-plugin-syntax-explicit-resource-management/src/index.ts index f5eed49556c9..e1b2adc5bff6 100644 --- a/packages/babel-plugin-syntax-explicit-resource-management/src/index.ts +++ b/packages/babel-plugin-syntax-explicit-resource-management/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-explicit-resource-management", diff --git a/packages/babel-plugin-syntax-export-default-from/src/index.ts b/packages/babel-plugin-syntax-export-default-from/src/index.ts index 078a1be36ec5..3edb81b6e23a 100644 --- a/packages/babel-plugin-syntax-export-default-from/src/index.ts +++ b/packages/babel-plugin-syntax-export-default-from/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-export-default-from", diff --git a/packages/babel-plugin-syntax-flow/src/index.ts b/packages/babel-plugin-syntax-flow/src/index.ts index b814d04ac819..4ac7ea638f4f 100644 --- a/packages/babel-plugin-syntax-flow/src/index.ts +++ b/packages/babel-plugin-syntax-flow/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import type { FlowPluginOptions } from "@babel/parser"; export default declare((api, options: FlowPluginOptions) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); // When enabled and plugins includes flow, all files should be parsed as if // the @flow pragma was provided. diff --git a/packages/babel-plugin-syntax-function-bind/src/index.ts b/packages/babel-plugin-syntax-function-bind/src/index.ts index f7486f73cf99..2baf4f60fd61 100644 --- a/packages/babel-plugin-syntax-function-bind/src/index.ts +++ b/packages/babel-plugin-syntax-function-bind/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-function-bind", diff --git a/packages/babel-plugin-syntax-function-sent/src/index.ts b/packages/babel-plugin-syntax-function-sent/src/index.ts index 4dfad81d44e5..b73058769c35 100644 --- a/packages/babel-plugin-syntax-function-sent/src/index.ts +++ b/packages/babel-plugin-syntax-function-sent/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-function-sent", diff --git a/packages/babel-plugin-syntax-import-assertions/src/index.ts b/packages/babel-plugin-syntax-import-assertions/src/index.ts index e26d5101a46a..ea7073d2147a 100644 --- a/packages/babel-plugin-syntax-import-assertions/src/index.ts +++ b/packages/babel-plugin-syntax-import-assertions/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-import-assertions", diff --git a/packages/babel-plugin-syntax-import-attributes/src/index.ts b/packages/babel-plugin-syntax-import-attributes/src/index.ts index 9c27a1905d3d..686ca3d70f05 100644 --- a/packages/babel-plugin-syntax-import-attributes/src/index.ts +++ b/packages/babel-plugin-syntax-import-attributes/src/index.ts @@ -5,7 +5,11 @@ export interface Options { } export default declare((api, { deprecatedAssertSyntax }: Options) => { - api.assertVersion("^7.22.0"); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.22.0", + ); if ( deprecatedAssertSyntax != null && diff --git a/packages/babel-plugin-syntax-import-reflection/src/index.ts b/packages/babel-plugin-syntax-import-reflection/src/index.ts index d371a47f3840..4d6a517d5890 100644 --- a/packages/babel-plugin-syntax-import-reflection/src/index.ts +++ b/packages/babel-plugin-syntax-import-reflection/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-import-reflection", diff --git a/packages/babel-plugin-syntax-jsx/src/index.ts b/packages/babel-plugin-syntax-jsx/src/index.ts index 2c1611d0a66f..cca05d1c8c11 100644 --- a/packages/babel-plugin-syntax-jsx/src/index.ts +++ b/packages/babel-plugin-syntax-jsx/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-jsx", diff --git a/packages/babel-plugin-syntax-module-blocks/src/index.ts b/packages/babel-plugin-syntax-module-blocks/src/index.ts index 0cce13f321fd..8e5f2e3ab9ae 100644 --- a/packages/babel-plugin-syntax-module-blocks/src/index.ts +++ b/packages/babel-plugin-syntax-module-blocks/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-module-blocks", diff --git a/packages/babel-plugin-syntax-partial-application/src/index.ts b/packages/babel-plugin-syntax-partial-application/src/index.ts index aafcfc315e2a..4841a40a72eb 100644 --- a/packages/babel-plugin-syntax-partial-application/src/index.ts +++ b/packages/babel-plugin-syntax-partial-application/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-partial-application", diff --git a/packages/babel-plugin-syntax-pipeline-operator/src/index.ts b/packages/babel-plugin-syntax-pipeline-operator/src/index.ts index c1cbd92e5963..158c3f0245c6 100644 --- a/packages/babel-plugin-syntax-pipeline-operator/src/index.ts +++ b/packages/babel-plugin-syntax-pipeline-operator/src/index.ts @@ -11,7 +11,11 @@ export interface Options { } export default declare((api, { proposal, topicToken }: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); if (typeof proposal !== "string" || !PIPELINE_PROPOSALS.includes(proposal)) { const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", "); diff --git a/packages/babel-plugin-syntax-record-and-tuple/src/index.ts b/packages/babel-plugin-syntax-record-and-tuple/src/index.ts index 2f97eea173d0..99739f4f61b1 100644 --- a/packages/babel-plugin-syntax-record-and-tuple/src/index.ts +++ b/packages/babel-plugin-syntax-record-and-tuple/src/index.ts @@ -5,7 +5,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-record-and-tuple", diff --git a/packages/babel-plugin-syntax-throw-expressions/src/index.ts b/packages/babel-plugin-syntax-throw-expressions/src/index.ts index d9164eea2bd4..dfaa19ce12b7 100644 --- a/packages/babel-plugin-syntax-throw-expressions/src/index.ts +++ b/packages/babel-plugin-syntax-throw-expressions/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "syntax-throw-expressions", diff --git a/packages/babel-plugin-syntax-typescript/src/index.ts b/packages/babel-plugin-syntax-typescript/src/index.ts index 9cda31ca1b57..4d82ee2a4350 100644 --- a/packages/babel-plugin-syntax-typescript/src/index.ts +++ b/packages/babel-plugin-syntax-typescript/src/index.ts @@ -25,7 +25,11 @@ export interface Options { } export default declare((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { disallowAmbiguousJSXLike, dts } = opts; diff --git a/packages/babel-plugin-transform-arrow-functions/src/index.ts b/packages/babel-plugin-transform-arrow-functions/src/index.ts index ed7545922223..a36aed8be837 100644 --- a/packages/babel-plugin-transform-arrow-functions/src/index.ts +++ b/packages/babel-plugin-transform-arrow-functions/src/index.ts @@ -5,7 +5,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const noNewArrows = api.assumption("noNewArrows") ?? !options.spec; diff --git a/packages/babel-plugin-transform-async-generator-functions/src/index.ts b/packages/babel-plugin-transform-async-generator-functions/src/index.ts index 6b487f96e4bf..3cb1c7c6df6a 100644 --- a/packages/babel-plugin-transform-async-generator-functions/src/index.ts +++ b/packages/babel-plugin-transform-async-generator-functions/src/index.ts @@ -6,7 +6,11 @@ import rewriteForAwait from "./for-await.ts"; import environmentVisitor from "@babel/helper-environment-visitor"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const yieldStarVisitor = traverse.visitors.merge([ { diff --git a/packages/babel-plugin-transform-async-to-generator/src/index.ts b/packages/babel-plugin-transform-async-to-generator/src/index.ts index fb8f0e012005..6e9c03185d95 100644 --- a/packages/babel-plugin-transform-async-to-generator/src/index.ts +++ b/packages/babel-plugin-transform-async-to-generator/src/index.ts @@ -13,7 +13,11 @@ type State = { }; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { method, module } = options; // Todo(BABEL 8): Consider default it to false diff --git a/packages/babel-plugin-transform-block-scoped-functions/src/index.ts b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts index 811645d8bfd0..adc1579aa41b 100644 --- a/packages/babel-plugin-transform-block-scoped-functions/src/index.ts +++ b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts @@ -3,7 +3,11 @@ import { types as t } from "@babel/core"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function transformStatementList(paths: NodePath[]) { for (const path of paths) { diff --git a/packages/babel-plugin-transform-block-scoping/src/index.ts b/packages/babel-plugin-transform-block-scoping/src/index.ts index 9d6fd9f0e264..f7f3b2a558d3 100644 --- a/packages/babel-plugin-transform-block-scoping/src/index.ts +++ b/packages/babel-plugin-transform-block-scoping/src/index.ts @@ -17,7 +17,11 @@ export interface Options { } export default declare((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { throwIfClosureRequired = false, tdz: tdzEnabled = false } = opts; if (typeof throwIfClosureRequired !== "boolean") { diff --git a/packages/babel-plugin-transform-class-properties/src/index.ts b/packages/babel-plugin-transform-class-properties/src/index.ts index 6ea8ea104797..86cfd4899f92 100644 --- a/packages/babel-plugin-transform-class-properties/src/index.ts +++ b/packages/babel-plugin-transform-class-properties/src/index.ts @@ -11,7 +11,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return createClassFeaturePlugin({ name: "transform-class-properties", diff --git a/packages/babel-plugin-transform-class-static-block/src/index.ts b/packages/babel-plugin-transform-class-static-block/src/index.ts index 4a69c8f3eef7..0c1f511f8b39 100644 --- a/packages/babel-plugin-transform-class-static-block/src/index.ts +++ b/packages/babel-plugin-transform-class-static-block/src/index.ts @@ -25,7 +25,11 @@ function generateUid(scope: Scope, denyList: Set) { } export default declare(({ types: t, template, assertVersion }) => { - assertVersion("^7.12.0"); + assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : "^7.12.0", + ); return { name: "transform-class-static-block", diff --git a/packages/babel-plugin-transform-classes/src/index.ts b/packages/babel-plugin-transform-classes/src/index.ts index 128fd3e76900..a29375e65b19 100644 --- a/packages/babel-plugin-transform-classes/src/index.ts +++ b/packages/babel-plugin-transform-classes/src/index.ts @@ -20,7 +20,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { loose = false } = options; diff --git a/packages/babel-plugin-transform-computed-properties/src/index.ts b/packages/babel-plugin-transform-computed-properties/src/index.ts index d156b04e1bbc..0f12d5bb44e1 100644 --- a/packages/babel-plugin-transform-computed-properties/src/index.ts +++ b/packages/babel-plugin-transform-computed-properties/src/index.ts @@ -31,7 +31,11 @@ if (!process.env.BABEL_8_BREAKING) { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const setComputedProperties = api.assumption("setComputedProperties") ?? options.loose; diff --git a/packages/babel-plugin-transform-destructuring/src/index.ts b/packages/babel-plugin-transform-destructuring/src/index.ts index 100342071c81..05405ed1c7ac 100644 --- a/packages/babel-plugin-transform-destructuring/src/index.ts +++ b/packages/babel-plugin-transform-destructuring/src/index.ts @@ -30,7 +30,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { useBuiltIns = false } = options; diff --git a/packages/babel-plugin-transform-dotall-regex/src/index.ts b/packages/babel-plugin-transform-dotall-regex/src/index.ts index a41961076922..fbdab1fbc9e5 100644 --- a/packages/babel-plugin-transform-dotall-regex/src/index.ts +++ b/packages/babel-plugin-transform-dotall-regex/src/index.ts @@ -3,7 +3,11 @@ import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features- import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return createRegExpFeaturePlugin({ name: "transform-dotall-regex", diff --git a/packages/babel-plugin-transform-duplicate-keys/src/index.ts b/packages/babel-plugin-transform-duplicate-keys/src/index.ts index 1e22ffc67776..c06d24835b03 100644 --- a/packages/babel-plugin-transform-duplicate-keys/src/index.ts +++ b/packages/babel-plugin-transform-duplicate-keys/src/index.ts @@ -11,7 +11,11 @@ function getName( } export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-duplicate-keys", diff --git a/packages/babel-plugin-transform-dynamic-import/src/index.ts b/packages/babel-plugin-transform-dynamic-import/src/index.ts index e6f3f6da5546..727bc6daaed0 100644 --- a/packages/babel-plugin-transform-dynamic-import/src/index.ts +++ b/packages/babel-plugin-transform-dynamic-import/src/index.ts @@ -16,7 +16,11 @@ bundler handle dynamic imports. `; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-dynamic-import", diff --git a/packages/babel-plugin-transform-exponentiation-operator/src/index.ts b/packages/babel-plugin-transform-exponentiation-operator/src/index.ts index 1d68e9fb40d0..96e6e885e080 100644 --- a/packages/babel-plugin-transform-exponentiation-operator/src/index.ts +++ b/packages/babel-plugin-transform-exponentiation-operator/src/index.ts @@ -3,7 +3,11 @@ import build from "@babel/helper-builder-binary-assignment-operator-visitor"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-exponentiation-operator", diff --git a/packages/babel-plugin-transform-export-namespace-from/src/index.ts b/packages/babel-plugin-transform-export-namespace-from/src/index.ts index d695a5c6a034..22ba9f6520af 100644 --- a/packages/babel-plugin-transform-export-namespace-from/src/index.ts +++ b/packages/babel-plugin-transform-export-namespace-from/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-export-namespace-from", diff --git a/packages/babel-plugin-transform-flow-comments/src/index.ts b/packages/babel-plugin-transform-flow-comments/src/index.ts index 3f8cb42ebf65..c62775d7cafe 100644 --- a/packages/babel-plugin-transform-flow-comments/src/index.ts +++ b/packages/babel-plugin-transform-flow-comments/src/index.ts @@ -5,7 +5,11 @@ import generateCode from "@babel/generator"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function commentFromString(comment: string | t.Comment): t.Comment { return typeof comment === "string" diff --git a/packages/babel-plugin-transform-flow-strip-types/src/index.ts b/packages/babel-plugin-transform-flow-strip-types/src/index.ts index db6060e1d726..2cc0dd4152af 100644 --- a/packages/babel-plugin-transform-flow-strip-types/src/index.ts +++ b/packages/babel-plugin-transform-flow-strip-types/src/index.ts @@ -9,7 +9,11 @@ export interface Options { } export default declare((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/; diff --git a/packages/babel-plugin-transform-for-of/src/index.ts b/packages/babel-plugin-transform-for-of/src/index.ts index 854d12d2fcbd..bbbe45c832ef 100644 --- a/packages/babel-plugin-transform-for-of/src/index.ts +++ b/packages/babel-plugin-transform-for-of/src/index.ts @@ -33,7 +33,11 @@ function buildLoopBody( } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); { const { assumeArray, allowArrayLike, loose } = options; diff --git a/packages/babel-plugin-transform-function-name/src/index.ts b/packages/babel-plugin-transform-function-name/src/index.ts index 6f5c9bcdea26..6f742ea1d263 100644 --- a/packages/babel-plugin-transform-function-name/src/index.ts +++ b/packages/babel-plugin-transform-function-name/src/index.ts @@ -3,7 +3,11 @@ import { declare } from "@babel/helper-plugin-utils"; import nameFunction from "@babel/helper-function-name"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const supportUnicodeId = !isRequired( "transform-unicode-escapes", api.targets(), diff --git a/packages/babel-plugin-transform-instanceof/src/index.ts b/packages/babel-plugin-transform-instanceof/src/index.ts index 8e7393a1a68a..9c600d0561c2 100644 --- a/packages/babel-plugin-transform-instanceof/src/index.ts +++ b/packages/babel-plugin-transform-instanceof/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-instanceof", diff --git a/packages/babel-plugin-transform-jscript/src/index.ts b/packages/babel-plugin-transform-jscript/src/index.ts index 4e064f0e8ab9..ac02bd3071f9 100644 --- a/packages/babel-plugin-transform-jscript/src/index.ts +++ b/packages/babel-plugin-transform-jscript/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-jscript", diff --git a/packages/babel-plugin-transform-json-strings/src/index.ts b/packages/babel-plugin-transform-json-strings/src/index.ts index f4adf136529a..dbec1732dc7b 100644 --- a/packages/babel-plugin-transform-json-strings/src/index.ts +++ b/packages/babel-plugin-transform-json-strings/src/index.ts @@ -3,7 +3,11 @@ import type * as t from "@babel/types"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const regex = /(\\*)([\u2028\u2029])/g; function replace(match: string, escapes: string, separator: string) { // If there's an odd number, that means the separator itself was escaped. diff --git a/packages/babel-plugin-transform-literals/src/index.ts b/packages/babel-plugin-transform-literals/src/index.ts index 1b42ec0dc29e..fdf792c29b0c 100644 --- a/packages/babel-plugin-transform-literals/src/index.ts +++ b/packages/babel-plugin-transform-literals/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-literals", diff --git a/packages/babel-plugin-transform-logical-assignment-operators/src/index.ts b/packages/babel-plugin-transform-logical-assignment-operators/src/index.ts index 518e68f987eb..598fe2430605 100644 --- a/packages/babel-plugin-transform-logical-assignment-operators/src/index.ts +++ b/packages/babel-plugin-transform-logical-assignment-operators/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-logical-assignment-operators", diff --git a/packages/babel-plugin-transform-member-expression-literals/src/index.ts b/packages/babel-plugin-transform-member-expression-literals/src/index.ts index 78e4f947330c..a0a14f7d6e3b 100644 --- a/packages/babel-plugin-transform-member-expression-literals/src/index.ts +++ b/packages/babel-plugin-transform-member-expression-literals/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-member-expression-literals", diff --git a/packages/babel-plugin-transform-modules-amd/src/index.ts b/packages/babel-plugin-transform-modules-amd/src/index.ts index 5cd6cb07e617..88598f418f00 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.ts +++ b/packages/babel-plugin-transform-modules-amd/src/index.ts @@ -61,7 +61,11 @@ type State = { }; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { allowTopLevelThis, strict, strictMode, importInterop, noInterop } = options; diff --git a/packages/babel-plugin-transform-modules-commonjs/src/index.ts b/packages/babel-plugin-transform-modules-commonjs/src/index.ts index 80d45a6db180..4eff3c94823b 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/index.ts +++ b/packages/babel-plugin-transform-modules-commonjs/src/index.ts @@ -34,7 +34,11 @@ export interface Options extends PluginOptions { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { // 'true' for imports to strictly have .default, instead of having diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.ts b/packages/babel-plugin-transform-modules-systemjs/src/index.ts index 298f6ff36902..375953640bcf 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.ts +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.ts @@ -176,7 +176,11 @@ type ReassignmentVisitorState = { }; export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { systemGlobal = "System", allowTopLevelThis = false } = options; const reassignmentVisited = new WeakSet(); diff --git a/packages/babel-plugin-transform-modules-umd/src/index.ts b/packages/babel-plugin-transform-modules-umd/src/index.ts index c7d4c80b7645..88e0996709e5 100644 --- a/packages/babel-plugin-transform-modules-umd/src/index.ts +++ b/packages/babel-plugin-transform-modules-umd/src/index.ts @@ -53,7 +53,11 @@ export interface Options extends PluginOptions { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { globals, diff --git a/packages/babel-plugin-transform-new-target/src/index.ts b/packages/babel-plugin-transform-new-target/src/index.ts index b3b573cb052c..0f6812924590 100644 --- a/packages/babel-plugin-transform-new-target/src/index.ts +++ b/packages/babel-plugin-transform-new-target/src/index.ts @@ -3,7 +3,11 @@ import { types as t } from "@babel/core"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-new-target", diff --git a/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts b/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts index fca961196437..b89b492f1025 100644 --- a/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts +++ b/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts @@ -6,7 +6,11 @@ export interface Options { } export default declare((api, { loose = false }: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const noDocumentAll = api.assumption("noDocumentAll") ?? loose; return { diff --git a/packages/babel-plugin-transform-numeric-separator/src/index.ts b/packages/babel-plugin-transform-numeric-separator/src/index.ts index 2b0667405687..c207491b5c78 100644 --- a/packages/babel-plugin-transform-numeric-separator/src/index.ts +++ b/packages/babel-plugin-transform-numeric-separator/src/index.ts @@ -18,7 +18,11 @@ function remover({ node }: NodePath) { } export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-numeric-separator", diff --git a/packages/babel-plugin-transform-object-assign/src/index.ts b/packages/babel-plugin-transform-object-assign/src/index.ts index b24621a9b3ec..0aebbd638acb 100644 --- a/packages/babel-plugin-transform-object-assign/src/index.ts +++ b/packages/babel-plugin-transform-object-assign/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-object-assign", diff --git a/packages/babel-plugin-transform-object-rest-spread/src/index.ts b/packages/babel-plugin-transform-object-rest-spread/src/index.ts index ee3dc34ebc2e..0de6c4ef63fe 100644 --- a/packages/babel-plugin-transform-object-rest-spread/src/index.ts +++ b/packages/babel-plugin-transform-object-rest-spread/src/index.ts @@ -26,7 +26,11 @@ export interface Options { } export default declare((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const targets = api.targets(); const supportsObjectAssign = !isRequired("es6.object.assign", targets, { diff --git a/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts b/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts index b0a0a02f0173..5525e62a366a 100644 --- a/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts +++ b/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-object-set-prototype-of-to-assign", diff --git a/packages/babel-plugin-transform-object-super/src/index.ts b/packages/babel-plugin-transform-object-super/src/index.ts index 86df844f2cf1..4dcf65fc588e 100644 --- a/packages/babel-plugin-transform-object-super/src/index.ts +++ b/packages/babel-plugin-transform-object-super/src/index.ts @@ -19,7 +19,11 @@ function replacePropertySuper( } export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-object-super", diff --git a/packages/babel-plugin-transform-optional-catch-binding/src/index.ts b/packages/babel-plugin-transform-optional-catch-binding/src/index.ts index f593df2488cb..d547a8a0b905 100644 --- a/packages/babel-plugin-transform-optional-catch-binding/src/index.ts +++ b/packages/babel-plugin-transform-optional-catch-binding/src/index.ts @@ -1,7 +1,11 @@ import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-optional-catch-binding", diff --git a/packages/babel-plugin-transform-optional-chaining/src/index.ts b/packages/babel-plugin-transform-optional-chaining/src/index.ts index aa5b5762081c..b40f7bd26245 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/index.ts +++ b/packages/babel-plugin-transform-optional-chaining/src/index.ts @@ -7,7 +7,11 @@ export interface Options { loose?: boolean; } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { loose = false } = options; const noDocumentAll = api.assumption("noDocumentAll") ?? loose; diff --git a/packages/babel-plugin-transform-parameters/src/index.ts b/packages/babel-plugin-transform-parameters/src/index.ts index 63b797ba02fb..f32142715b59 100644 --- a/packages/babel-plugin-transform-parameters/src/index.ts +++ b/packages/babel-plugin-transform-parameters/src/index.ts @@ -8,7 +8,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const ignoreFunctionLength = api.assumption("ignoreFunctionLength") ?? options.loose; diff --git a/packages/babel-plugin-transform-private-methods/src/index.ts b/packages/babel-plugin-transform-private-methods/src/index.ts index 6a0d7629ba77..c15f241c956e 100644 --- a/packages/babel-plugin-transform-private-methods/src/index.ts +++ b/packages/babel-plugin-transform-private-methods/src/index.ts @@ -11,7 +11,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return createClassFeaturePlugin({ name: "transform-private-methods", diff --git a/packages/babel-plugin-transform-private-property-in-object/src/index.ts b/packages/babel-plugin-transform-private-property-in-object/src/index.ts index 9b4d4a9b9876..8bbefdef8d8e 100644 --- a/packages/babel-plugin-transform-private-property-in-object/src/index.ts +++ b/packages/babel-plugin-transform-private-property-in-object/src/index.ts @@ -13,7 +13,11 @@ export interface Options { loose?: boolean; } export default declare((api, opt: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { types: t, template } = api; const { loose } = opt; diff --git a/packages/babel-plugin-transform-property-literals/src/index.ts b/packages/babel-plugin-transform-property-literals/src/index.ts index 8e35fa027b1b..9af61c685138 100644 --- a/packages/babel-plugin-transform-property-literals/src/index.ts +++ b/packages/babel-plugin-transform-property-literals/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-property-literals", diff --git a/packages/babel-plugin-transform-property-mutators/src/index.ts b/packages/babel-plugin-transform-property-mutators/src/index.ts index 9d8b97580d41..9cbffd9caf34 100644 --- a/packages/babel-plugin-transform-property-mutators/src/index.ts +++ b/packages/babel-plugin-transform-property-mutators/src/index.ts @@ -3,7 +3,11 @@ import { type MutatorMap, pushAccessor, toDefineObject } from "./define-map.ts"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-property-mutators", diff --git a/packages/babel-plugin-transform-proto-to-assign/src/index.ts b/packages/babel-plugin-transform-proto-to-assign/src/index.ts index 68270bf3c012..e0f7f65b9731 100644 --- a/packages/babel-plugin-transform-proto-to-assign/src/index.ts +++ b/packages/babel-plugin-transform-proto-to-assign/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t, type File } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function isProtoKey(node: t.ObjectExpression["properties"][number]) { return ( diff --git a/packages/babel-plugin-transform-react-constant-elements/src/index.ts b/packages/babel-plugin-transform-react-constant-elements/src/index.ts index 95c6763ffdd1..04b2924d2ad5 100644 --- a/packages/babel-plugin-transform-react-constant-elements/src/index.ts +++ b/packages/babel-plugin-transform-react-constant-elements/src/index.ts @@ -13,7 +13,11 @@ interface VisitorState { targetScope: Scope; } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { allowMutablePropsOnTags } = options; diff --git a/packages/babel-plugin-transform-react-display-name/src/index.ts b/packages/babel-plugin-transform-react-display-name/src/index.ts index 91d9c85f5a27..e14416e5a12a 100644 --- a/packages/babel-plugin-transform-react-display-name/src/index.ts +++ b/packages/babel-plugin-transform-react-display-name/src/index.ts @@ -7,7 +7,11 @@ type ReactCreateClassCall = t.CallExpression & { }; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function addDisplayName(id: string, call: ReactCreateClassCall) { const props = call.arguments[0].properties; diff --git a/packages/babel-plugin-transform-react-inline-elements/src/index.ts b/packages/babel-plugin-transform-react-inline-elements/src/index.ts index e5f5d23b1291..bd5dd1f98bc8 100644 --- a/packages/babel-plugin-transform-react-inline-elements/src/index.ts +++ b/packages/babel-plugin-transform-react-inline-elements/src/index.ts @@ -3,7 +3,11 @@ import helper from "@babel/helper-builder-react-jsx"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function hasRefOrSpread(attrs: t.JSXOpeningElement["attributes"]) { for (let i = 0; i < attrs.length; i++) { diff --git a/packages/babel-plugin-transform-react-jsx-compat/src/index.ts b/packages/babel-plugin-transform-react-jsx-compat/src/index.ts index 510f20480628..7e9796af4c3a 100644 --- a/packages/babel-plugin-transform-react-jsx-compat/src/index.ts +++ b/packages/babel-plugin-transform-react-jsx-compat/src/index.ts @@ -3,7 +3,11 @@ import helper from "@babel/helper-builder-react-jsx"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-react-jsx-compat", diff --git a/packages/babel-plugin-transform-react-jsx-self/src/index.ts b/packages/babel-plugin-transform-react-jsx-self/src/index.ts index b5ee66803383..849ec3347292 100644 --- a/packages/babel-plugin-transform-react-jsx-self/src/index.ts +++ b/packages/babel-plugin-transform-react-jsx-self/src/index.ts @@ -71,7 +71,11 @@ function isThisAllowed(path: NodePath) { } export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const visitor: Visitor = { JSXOpeningElement(path) { diff --git a/packages/babel-plugin-transform-react-jsx-source/src/index.ts b/packages/babel-plugin-transform-react-jsx-source/src/index.ts index 86501e7061ce..7003cfdca4b2 100644 --- a/packages/babel-plugin-transform-react-jsx-source/src/index.ts +++ b/packages/babel-plugin-transform-react-jsx-source/src/index.ts @@ -27,7 +27,11 @@ type State = { fileNameIdentifier: t.Identifier; }; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); function makeTrace( fileNameIdentifier: t.Identifier, diff --git a/packages/babel-plugin-transform-react-pure-annotations/src/index.ts b/packages/babel-plugin-transform-react-pure-annotations/src/index.ts index 9bb85c9bbbdf..97f3dced44c8 100644 --- a/packages/babel-plugin-transform-react-pure-annotations/src/index.ts +++ b/packages/babel-plugin-transform-react-pure-annotations/src/index.ts @@ -27,7 +27,11 @@ const PURE_CALLS: [string, Set][] = [ ]; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-react-pure-annotations", diff --git a/packages/babel-plugin-transform-regenerator/src/index.ts b/packages/babel-plugin-transform-regenerator/src/index.ts index 77b88f03f950..a2bba7ebb66e 100644 --- a/packages/babel-plugin-transform-regenerator/src/index.ts +++ b/packages/babel-plugin-transform-regenerator/src/index.ts @@ -3,7 +3,11 @@ import type { types as t } from "@babel/core"; import regeneratorTransform from "regenerator-transform"; export default declare(({ types: t, assertVersion }) => { - assertVersion(7); + assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-regenerator", diff --git a/packages/babel-plugin-transform-reserved-words/src/index.ts b/packages/babel-plugin-transform-reserved-words/src/index.ts index cefabf680af7..b71a2a1065bb 100644 --- a/packages/babel-plugin-transform-reserved-words/src/index.ts +++ b/packages/babel-plugin-transform-reserved-words/src/index.ts @@ -3,7 +3,11 @@ import { types as t } from "@babel/core"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-reserved-words", diff --git a/packages/babel-plugin-transform-runtime/src/index.ts b/packages/babel-plugin-transform-runtime/src/index.ts index 4acf0b793a40..67f5038d4644 100644 --- a/packages/babel-plugin-transform-runtime/src/index.ts +++ b/packages/babel-plugin-transform-runtime/src/index.ts @@ -21,7 +21,11 @@ export interface Options { } export default declare((api, options: Options, dirname) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { helpers: useRuntimeHelpers = true, diff --git a/packages/babel-plugin-transform-shorthand-properties/src/index.ts b/packages/babel-plugin-transform-shorthand-properties/src/index.ts index 61927f050a1f..7e62ab4f3a23 100644 --- a/packages/babel-plugin-transform-shorthand-properties/src/index.ts +++ b/packages/babel-plugin-transform-shorthand-properties/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-shorthand-properties", diff --git a/packages/babel-plugin-transform-spread/src/index.ts b/packages/babel-plugin-transform-spread/src/index.ts index 450dc9603a98..3f2ca95a7232 100644 --- a/packages/babel-plugin-transform-spread/src/index.ts +++ b/packages/babel-plugin-transform-spread/src/index.ts @@ -12,7 +12,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const iterableIsArray = api.assumption("iterableIsArray") ?? options.loose; const arrayLikeIsIterable = diff --git a/packages/babel-plugin-transform-sticky-regex/src/index.ts b/packages/babel-plugin-transform-sticky-regex/src/index.ts index 3fee3bb2b80e..b8bf8fef448b 100644 --- a/packages/babel-plugin-transform-sticky-regex/src/index.ts +++ b/packages/babel-plugin-transform-sticky-regex/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-sticky-regex", diff --git a/packages/babel-plugin-transform-strict-mode/src/index.ts b/packages/babel-plugin-transform-strict-mode/src/index.ts index 8f3ae8b024bd..a08cc5e7cea8 100644 --- a/packages/babel-plugin-transform-strict-mode/src/index.ts +++ b/packages/babel-plugin-transform-strict-mode/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-strict-mode", diff --git a/packages/babel-plugin-transform-template-literals/src/index.ts b/packages/babel-plugin-transform-template-literals/src/index.ts index 4271c28a92ad..39f0af6eb392 100644 --- a/packages/babel-plugin-transform-template-literals/src/index.ts +++ b/packages/babel-plugin-transform-template-literals/src/index.ts @@ -7,7 +7,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const ignoreToPrimitiveHint = api.assumption("ignoreToPrimitiveHint") ?? options.loose; diff --git a/packages/babel-plugin-transform-typeof-symbol/src/index.ts b/packages/babel-plugin-transform-typeof-symbol/src/index.ts index 308dbc10437a..8024c2347e9f 100644 --- a/packages/babel-plugin-transform-typeof-symbol/src/index.ts +++ b/packages/babel-plugin-transform-typeof-symbol/src/index.ts @@ -2,7 +2,11 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return { name: "transform-typeof-symbol", diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index e592bfa00bd2..c87bd1b2628d 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -119,7 +119,11 @@ export default declare((api, opts: Options) => { // Ref: https://github.com/babel/babel/issues/15089 const { types: t, template } = api; - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const JSX_PRAGMA_REGEX = /\*?\s*@jsx((?:Frag)?)\s+([^\s]+)/; diff --git a/packages/babel-plugin-transform-unicode-escapes/src/index.ts b/packages/babel-plugin-transform-unicode-escapes/src/index.ts index 7f7150a68c97..e551ba3e4463 100644 --- a/packages/babel-plugin-transform-unicode-escapes/src/index.ts +++ b/packages/babel-plugin-transform-unicode-escapes/src/index.ts @@ -3,7 +3,11 @@ import { types as t } from "@babel/core"; import type { NodePath } from "@babel/traverse"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const surrogate = /[\ud800-\udfff]/g; const unicodeEscape = /(\\+)u\{([0-9a-fA-F]+)\}/g; diff --git a/packages/babel-plugin-transform-unicode-property-regex/src/index.ts b/packages/babel-plugin-transform-unicode-property-regex/src/index.ts index 9cb84ecaf885..ab26dc9e6413 100644 --- a/packages/babel-plugin-transform-unicode-property-regex/src/index.ts +++ b/packages/babel-plugin-transform-unicode-property-regex/src/index.ts @@ -7,7 +7,11 @@ export interface Options { } export default declare((api, options: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { useUnicodeFlag = true } = options; if (typeof useUnicodeFlag !== "boolean") { diff --git a/packages/babel-plugin-transform-unicode-regex/src/index.ts b/packages/babel-plugin-transform-unicode-regex/src/index.ts index cfc4cd8a40f2..652744c3b3cb 100644 --- a/packages/babel-plugin-transform-unicode-regex/src/index.ts +++ b/packages/babel-plugin-transform-unicode-regex/src/index.ts @@ -3,7 +3,11 @@ import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features- import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return createRegExpFeaturePlugin({ name: "transform-unicode-regex", diff --git a/packages/babel-plugin-transform-unicode-sets-regex/src/index.ts b/packages/babel-plugin-transform-unicode-sets-regex/src/index.ts index 4aeb8e078cb7..2c04362c1c7c 100644 --- a/packages/babel-plugin-transform-unicode-sets-regex/src/index.ts +++ b/packages/babel-plugin-transform-unicode-sets-regex/src/index.ts @@ -3,7 +3,11 @@ import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features- import { declare } from "@babel/helper-plugin-utils"; export default declare(api => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); return createRegExpFeaturePlugin({ name: "transform-unicode-sets-regex", diff --git a/packages/babel-preset-env/src/index.ts b/packages/babel-preset-env/src/index.ts index 627d59a62359..69ff06d934ef 100644 --- a/packages/babel-preset-env/src/index.ts +++ b/packages/babel-preset-env/src/index.ts @@ -327,7 +327,11 @@ function supportsExportNamespaceFrom(caller: CallerMetadata | undefined) { } export default declarePreset((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const babelTargets = api.targets(); diff --git a/packages/babel-preset-flow/src/index.ts b/packages/babel-preset-flow/src/index.ts index 7c0b07a44513..44a3846bf138 100644 --- a/packages/babel-preset-flow/src/index.ts +++ b/packages/babel-preset-flow/src/index.ts @@ -3,7 +3,11 @@ import transformFlowStripTypes from "@babel/plugin-transform-flow-strip-types"; import normalizeOptions from "./normalize-options.ts"; export default declarePreset((api, opts) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { all, allowDeclareFields, diff --git a/packages/babel-preset-react/src/index.ts b/packages/babel-preset-react/src/index.ts index 614ec763c0a5..e093a22920ce 100644 --- a/packages/babel-preset-react/src/index.ts +++ b/packages/babel-preset-react/src/index.ts @@ -18,7 +18,11 @@ export interface Options { } export default declarePreset((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { development, diff --git a/packages/babel-preset-typescript/src/index.ts b/packages/babel-preset-typescript/src/index.ts index cacefd65ec33..302d7d28e14c 100644 --- a/packages/babel-preset-typescript/src/index.ts +++ b/packages/babel-preset-typescript/src/index.ts @@ -7,7 +7,11 @@ import type { Options } from "./normalize-options.ts"; import pluginRewriteTSImports from "./plugin-rewrite-ts-imports.ts"; export default declarePreset((api, opts: Options) => { - api.assertVersion(7); + api.assertVersion( + process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH + ? PACKAGE_JSON.version + : 7, + ); const { allExtensions,