From 1b00ac014bd71acf708ed562029c6198272996de Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Sat, 28 Jan 2023 09:35:12 +0100 Subject: [PATCH] Fix `@babel/core` version check to support `ember-cli-babel` v8 --- packages/compat/src/v1-app.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/compat/src/v1-app.ts b/packages/compat/src/v1-app.ts index 0768f9197..107e52d37 100644 --- a/packages/compat/src/v1-app.ts +++ b/packages/compat/src/v1-app.ts @@ -287,14 +287,14 @@ export default class V1App { let babelAddon = this.app.project.addons.find((a: any) => a.name === 'ember-cli-babel'); if (babelAddon) { let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]); - let babelMajor = babelAddonMajor; + let babelMajor: number | undefined = babelAddonMajor; if (babelAddonMajor >= 8) { // `ember-cli-babel` v8 breaks lockstep with Babel, because it now // defines `@babel/core` as a peer dependency, so we need to check the // project's version of `@babel/core`: let babelVersion = this.app.project.pkg.devDependencies?.['@babel/core']; if (babelVersion) { - babelMajor = Number(babelVersion.split('.')[0]); + babelMajor = semver.coerce(babelVersion)?.major; } else { babelMajor = 7; }