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