11import semver from 'semver' ;
22import { Remote } from 'stagehand' ;
33import { connect } from 'stagehand/lib/adapters/child-process' ;
4- import { hasPlugin , addPlugin , AddPluginOptions } from 'ember-cli-babel-plugin-helpers' ;
54import Addon from 'ember-cli/lib/models/addon' ;
65import { addon } from './lib/utilities/ember-cli-entities' ;
76import fork from './lib/utilities/fork' ;
@@ -69,28 +68,6 @@ export default addon({
6968 }
7069 } ,
7170
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-
9471 shouldIncludeChildAddon ( addon ) {
9572 // For testing, we have dummy in-repo addons set up, but e-c-ts doesn't depend on them;
9673 // its dummy app does. Otherwise we'd have a circular dependency.
@@ -100,6 +77,8 @@ export default addon({
10077 _checkBabelVersion ( ) {
10178 let babel = this . parent . addons . find ( addon => addon . name === 'ember-cli-babel' ) ;
10279 let version = babel && babel . pkg . version ;
80+
81+ // TODO update this check and warning message once we have a Babel version to target
10382 if ( ! babel || ! ( semver . gte ( version ! , '7.7.3' ) && semver . lt ( version ! , '8.0.0' ) ) ) {
10483 let versionString = babel ? `version ${ babel . pkg . version } ` : `no instance of ember-cli-babel` ;
10584 this . ui . writeWarnLine (
@@ -164,31 +143,6 @@ export default addon({
164143 }
165144 } ,
166145
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-
192146 _addTypecheckMiddleware ( app : Application ) {
193147 let workerPromise = this . _getTypecheckWorker ( ) ;
194148 let middleware = new TypecheckMiddleware ( this . project , workerPromise ) ;
0 commit comments