|
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 PreprocessRegistry from 'ember-cli-preprocess-registry'; |
7 | 6 | import { addon } from './lib/utilities/ember-cli-entities'; |
@@ -84,24 +83,6 @@ export default addon({ |
84 | 83 | if (this.parent === this.project) { |
85 | 84 | this._registerCollisionDetectionPreprocessor(registry); |
86 | 85 | } |
87 | | - |
88 | | - // Normally this is the sort of logic that would live in `included()`, but |
89 | | - // ember-cli-babel reads the configured extensions when setting up the |
90 | | - // preprocessor registry, so we need to beat it to the punch. |
91 | | - this._registerBabelExtension(); |
92 | | - |
93 | | - // As of 3.7, TS supports the optional chaining and nullish coalescing proposals. |
94 | | - // https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/ |
95 | | - // Since we can't necessarily know what version of TS an addon was developed with, |
96 | | - // we unconditionally add the Babel plugins for both proposals. |
97 | | - this._addBabelPluginIfNotPresent('@babel/plugin-proposal-optional-chaining'); |
98 | | - this._addBabelPluginIfNotPresent('@babel/plugin-proposal-nullish-coalescing-operator'); |
99 | | - |
100 | | - // Needs to come after the class properties plugin (see tests/unit/build-test.ts - |
101 | | - // "property initialization occurs in the right order") |
102 | | - this._addBabelPluginIfNotPresent('@babel/plugin-transform-typescript', { |
103 | | - after: ['@babel/plugin-proposal-class-properties'], |
104 | | - }); |
105 | 86 | }, |
106 | 87 |
|
107 | 88 | shouldIncludeChildAddon(addon) { |
@@ -154,10 +135,11 @@ export default addon({ |
154 | 135 | _checkBabelVersion() { |
155 | 136 | let babel = this.parent.addons.find((addon) => addon.name === 'ember-cli-babel'); |
156 | 137 | let version = babel && babel.pkg.version; |
157 | | - if (!babel || !(semver.gte(version!, '7.7.3') && semver.lt(version!, '8.0.0'))) { |
| 138 | + |
| 139 | + if (!babel || !(semver.gte(version!, '7.17.0') && semver.lt(version!, '8.0.0'))) { |
158 | 140 | let versionString = babel ? `version ${babel.pkg.version}` : `no instance of ember-cli-babel`; |
159 | 141 | this.ui.writeWarnLine( |
160 | | - `ember-cli-typescript requires ember-cli-babel ^7.7.3, but you have ${versionString} installed; ` + |
| 142 | + `ember-cli-typescript requires ember-cli-babel ^7.17.0, but you have ${versionString} installed; ` + |
161 | 143 | 'your TypeScript files may not be transpiled correctly.' |
162 | 144 | ); |
163 | 145 | } |
@@ -218,31 +200,6 @@ export default addon({ |
218 | 200 | } |
219 | 201 | }, |
220 | 202 |
|
221 | | - _getConfigurationTarget() { |
222 | | - // If `this.app` isn't present, we know `this.parent` is an addon |
223 | | - return this.app || (this.parent as Addon); |
224 | | - }, |
225 | | - |
226 | | - _registerBabelExtension() { |
227 | | - let target = this._getConfigurationTarget(); |
228 | | - let options: Record<string, any> = target.options || (target.options = {}); |
229 | | - let babelAddonOptions: Record<string, any> = |
230 | | - options['ember-cli-babel'] || (options['ember-cli-babel'] = {}); |
231 | | - let extensions: string[] = |
232 | | - babelAddonOptions.extensions || (babelAddonOptions.extensions = ['js']); |
233 | | - |
234 | | - if (!extensions.includes('ts')) { |
235 | | - extensions.push('ts'); |
236 | | - } |
237 | | - }, |
238 | | - |
239 | | - _addBabelPluginIfNotPresent(pluginName: string, pluginOptions?: AddPluginOptions) { |
240 | | - let target = this._getConfigurationTarget(); |
241 | | - if (!hasPlugin(target, pluginName)) { |
242 | | - addPlugin(target, require.resolve(pluginName), pluginOptions); |
243 | | - } |
244 | | - }, |
245 | | - |
246 | 203 | _addTypecheckMiddleware(app: Application) { |
247 | 204 | let workerPromise = this._getTypecheckWorker(); |
248 | 205 | let middleware = new TypecheckMiddleware(this.project, workerPromise); |
|
0 commit comments