1
1
import semver from 'semver' ;
2
2
import { Remote } from 'stagehand' ;
3
3
import { connect } from 'stagehand/lib/adapters/child-process' ;
4
- import { hasPlugin , addPlugin , AddPluginOptions } from 'ember-cli-babel-plugin-helpers' ;
5
4
import Addon from 'ember-cli/lib/models/addon' ;
6
5
import { addon } from './lib/utilities/ember-cli-entities' ;
7
6
import fork from './lib/utilities/fork' ;
@@ -69,28 +68,6 @@ export default addon({
69
68
}
70
69
} ,
71
70
72
- setupPreprocessorRegistry ( type ) {
73
- if ( type !== 'parent' ) return ;
74
-
75
- // Normally this is the sort of logic that would live in `included()`, but
76
- // ember-cli-babel reads the configured extensions when setting up the
77
- // preprocessor registry, so we need to beat it to the punch.
78
- this . _registerBabelExtension ( ) ;
79
-
80
- // As of 3.7, TS supports the optional chaining and nullish coalescing proposals.
81
- // https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/
82
- // Since we can't necessarily know what version of TS an addon was developed with,
83
- // we unconditionally add the Babel plugins for both proposals.
84
- this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-optional-chaining' ) ;
85
- this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-nullish-coalescing-operator' ) ;
86
-
87
- // Needs to come after the class properties plugin (see tests/unit/build-test.ts -
88
- // "property initialization occurs in the right order")
89
- this . _addBabelPluginIfNotPresent ( '@babel/plugin-transform-typescript' , {
90
- after : [ '@babel/plugin-proposal-class-properties' ] ,
91
- } ) ;
92
- } ,
93
-
94
71
shouldIncludeChildAddon ( addon ) {
95
72
// For testing, we have dummy in-repo addons set up, but e-c-ts doesn't depend on them;
96
73
// its dummy app does. Otherwise we'd have a circular dependency.
@@ -100,6 +77,8 @@ export default addon({
100
77
_checkBabelVersion ( ) {
101
78
let babel = this . parent . addons . find ( addon => addon . name === 'ember-cli-babel' ) ;
102
79
let version = babel && babel . pkg . version ;
80
+
81
+ // TODO update this check and warning message once we have a Babel version to target
103
82
if ( ! babel || ! ( semver . gte ( version ! , '7.7.3' ) && semver . lt ( version ! , '8.0.0' ) ) ) {
104
83
let versionString = babel ? `version ${ babel . pkg . version } ` : `no instance of ember-cli-babel` ;
105
84
this . ui . writeWarnLine (
@@ -164,31 +143,6 @@ export default addon({
164
143
}
165
144
} ,
166
145
167
- _getConfigurationTarget ( ) {
168
- // If `this.app` isn't present, we know `this.parent` is an addon
169
- return this . app || ( this . parent as Addon ) ;
170
- } ,
171
-
172
- _registerBabelExtension ( ) {
173
- let target = this . _getConfigurationTarget ( ) ;
174
- let options : Record < string , any > = target . options || ( target . options = { } ) ;
175
- let babelAddonOptions : Record < string , any > =
176
- options [ 'ember-cli-babel' ] || ( options [ 'ember-cli-babel' ] = { } ) ;
177
- let extensions : string [ ] =
178
- babelAddonOptions . extensions || ( babelAddonOptions . extensions = [ 'js' ] ) ;
179
-
180
- if ( ! extensions . includes ( 'ts' ) ) {
181
- extensions . push ( 'ts' ) ;
182
- }
183
- } ,
184
-
185
- _addBabelPluginIfNotPresent ( pluginName : string , pluginOptions ?: AddPluginOptions ) {
186
- let target = this . _getConfigurationTarget ( ) ;
187
- if ( ! hasPlugin ( target , pluginName ) ) {
188
- addPlugin ( target , require . resolve ( pluginName ) , pluginOptions ) ;
189
- }
190
- } ,
191
-
192
146
_addTypecheckMiddleware ( app : Application ) {
193
147
let workerPromise = this . _getTypecheckWorker ( ) ;
194
148
let middleware = new TypecheckMiddleware ( this . project , workerPromise ) ;
0 commit comments