Skip to content

Commit 601fdbf

Browse files
Chris Garrettchriskrycho
Chris Garrett
authored andcommitted
[BUGFIX] Removes the class properties transform for the latest ember-cli-babel
1 parent e5219ba commit 601fdbf

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

ts/addon.ts

+21-12
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,19 @@ export default addon({
8080
// preprocessor registry, so we need to beat it to the punch.
8181
this._registerBabelExtension();
8282

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

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

103-
_checkBabelVersion() {
108+
_getBabelVersion() {
104109
let babel = this.parent.addons.find(addon => addon.name === 'ember-cli-babel');
105-
let version = babel && babel.pkg.version;
106-
if (!babel || !(semver.gte(version!, '7.1.0') && semver.lt(version!, '8.0.0'))) {
107-
let versionString = babel ? `version ${babel.pkg.version}` : `no instance of ember-cli-babel`;
110+
return babel && babel.pkg.version;
111+
},
112+
113+
_checkBabelVersion() {
114+
let version = this._getBabelVersion();
115+
if (!version || !(semver.gte(version!, '7.1.0') && semver.lt(version!, '8.0.0'))) {
116+
let versionString = version ? `version ${version}` : `no instance of ember-cli-babel`;
108117
this.ui.writeWarnLine(
109118
`ember-cli-typescript requires ember-cli-babel ^7.1.0, but you have ${versionString} installed; ` +
110119
'your TypeScript files may not be transpiled correctly.'

0 commit comments

Comments
 (0)