Skip to content

Commit 5d81ee3

Browse files
author
Chris Garrett
committed
[BUGFIX] Removes the class properties transform for the latest ember-cli-babel
1 parent 43a078e commit 5d81ee3

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

ts/addon.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ export default addon({
7575
// preprocessor registry, so we need to beat it to the punch.
7676
this._registerBabelExtension();
7777

78-
this._addPluginIfMissing(
79-
'@babel/plugin-proposal-class-properties',
80-
{ loose: true },
81-
{
82-
// Needs to come after the decorators plugin, if present
83-
after: ['@babel/plugin-proposal-decorators'],
84-
}
85-
);
78+
// Newer versions of ember-cli-babel add the transforms automatically, so we
79+
// only need to add ours on older versions.
80+
let babelVersion = this._getBabelVersion();
81+
if (!babelVersion || semver.lt(babelVersion, '7.7.0')) {
82+
this._addPluginIfMissing(
83+
'@babel/plugin-proposal-class-properties',
84+
{ loose: true },
85+
{
86+
// Needs to come after the decorators plugin, if present
87+
after: ['@babel/plugin-proposal-decorators'],
88+
}
89+
);
90+
}
8691

8792
// Needs to come after the class properties plugin (see tests/unit/build-test.ts -
8893
// "property initialization occurs in the right order")
@@ -95,11 +100,15 @@ export default addon({
95100
return !['in-repo-a', 'in-repo-b'].includes(addon.name);
96101
},
97102

98-
_checkBabelVersion() {
103+
_getBabelVersion() {
99104
let babel = this.parent.addons.find(addon => addon.name === 'ember-cli-babel');
100-
let version = babel && babel.pkg.version;
101-
if (!babel || !(semver.gte(version!, '7.1.0') && semver.lt(version!, '8.0.0'))) {
102-
let versionString = babel ? `version ${babel.pkg.version}` : `no instance of ember-cli-babel`;
105+
return babel && babel.pkg.version;
106+
},
107+
108+
_checkBabelVersion() {
109+
let version = this._getBabelVersion();
110+
if (!version || !(semver.gte(version!, '7.1.0') && semver.lt(version!, '8.0.0'))) {
111+
let versionString = version ? `version ${version}` : `no instance of ember-cli-babel`;
103112
this.ui.writeWarnLine(
104113
`ember-cli-typescript requires ember-cli-babel ^7.1.0, but you have ${versionString} installed; ` +
105114
'your TypeScript files may not be transpiled correctly.'

0 commit comments

Comments
 (0)