Skip to content

Commit

Permalink
[babel 8] Add missing assertVersion conditions (#16169)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 11, 2023
1 parent bf9ff15 commit 4b62d1d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ function buildFieldsReplacement(
}

export default declare(api => {
api.assertVersion(7);
api.assertVersion(
process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH
? PACKAGE_JSON.version
: 7,
);

const setPublicClassFields = api.assumption("setPublicClassFields");

Expand Down
6 changes: 5 additions & 1 deletion packages/babel-plugin-proposal-import-defer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { defineCommonJSHook } from "@babel/plugin-transform-modules-commonjs";
import syntaxImportDefer from "@babel/plugin-syntax-import-defer";

export default declare(api => {
api.assertVersion("^7.23.0");
api.assertVersion(
process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH
? PACKAGE_JSON.version
: "^7.23.0",
);
// We need the explicit type annotation otherwise when using t.assert* ts
// reports that 'Assertions require every name in the call target to be
// declared with an explicit type annotation'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function imp(path: NodePath, name: string, module: string) {

export default declare(api => {
const { types: t, template } = api;
api.assertVersion("^7.23.0");
api.assertVersion(
process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH
? PACKAGE_JSON.version
: "^7.23.0",
);

const { node: nodeTarget, ...webTargets } = api.targets();
const emptyNodeTarget = nodeTarget == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { skipTransparentExprWrappers } from "@babel/helper-skip-transparent-expr
import { transformOptionalChain } from "@babel/plugin-transform-optional-chaining";

export default declare(api => {
api.assertVersion("^7.22.5");
api.assertVersion(
process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH
? PACKAGE_JSON.version
: "^7.22.5",
);

const assumptions = {
noDocumentAll: api.assumption("noDocumentAll") ?? false,
Expand Down
6 changes: 5 additions & 1 deletion packages/babel-plugin-syntax-import-defer/src/index.ts
Original file line number Diff line number Diff line change
@@ -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-defer",
Expand Down
6 changes: 5 additions & 1 deletion packages/babel-plugin-syntax-import-source/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { declare } from "@babel/helper-plugin-utils";
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",
);

return {
name: "syntax-import-source",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export interface Options {
}

export default declare((api, options: Options) => {
api.assertVersion("^7.23.0");
api.assertVersion(
process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH
? PACKAGE_JSON.version
: "^7.23.0",
);

v.validateTopLevelOptions(options, { version: "version" });
const { version } = options;
Expand Down

0 comments on commit 4b62d1d

Please sign in to comment.