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

Allow ember-cli-babel >= v8 for apps and addons #1334

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions packages/compat/src/v1-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,23 @@ export default class V1App {
babelMajorVersion(): 7 {
let babelAddon = this.app.project.addons.find((a: any) => a.name === 'ember-cli-babel');
if (babelAddon) {
let major = Number(babelAddon.pkg.version.split('.')[0]);
if (major !== 7) {
throw new Error(`@embroider/compat only supports v1 addons that use babel 7`);
let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]);
let babelMajor = 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]);
} else {
babelMajor = 7;
}
}
if (babelMajor !== 7) {
throw new Error('`@embroider/compat` only supports apps and addons that use Babel v7.');
}
return major;
return babelMajor;
}
// if we didn't have our own babel plugin at all, it's safe to parse our
// code with 7.
Expand Down