@@ -80,14 +80,19 @@ export default addon({
80
80
// preprocessor registry, so we need to beat it to the punch.
81
81
this . _registerBabelExtension ( ) ;
82
82
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
+ }
91
96
92
97
// Needs to come after the class properties plugin (see tests/unit/build-test.ts -
93
98
// "property initialization occurs in the right order")
@@ -100,11 +105,15 @@ export default addon({
100
105
return ! [ 'in-repo-a' , 'in-repo-b' ] . includes ( addon . name ) ;
101
106
} ,
102
107
103
- _checkBabelVersion ( ) {
108
+ _getBabelVersion ( ) {
104
109
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` ;
108
117
this . ui . writeWarnLine (
109
118
`ember-cli-typescript requires ember-cli-babel ^7.1.0, but you have ${ versionString } installed; ` +
110
119
'your TypeScript files may not be transpiled correctly.'
0 commit comments