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