Skip to content

Commit 1743d87

Browse files
authored
Merge branch 'master' into renovate/execa-3.x
2 parents 4256d74 + 6c493ae commit 1743d87

File tree

3 files changed

+68
-13
lines changed

3 files changed

+68
-13
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -u"
4040
},
4141
"dependencies": {
42+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
43+
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
4244
"@babel/plugin-transform-typescript": "~7.6.0",
4345
"ansi-to-html": "^0.6.6",
4446
"debug": "^4.0.0",

ts/addon.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import semver from 'semver';
22
import { Remote } from 'stagehand';
33
import { connect } from 'stagehand/lib/adapters/child-process';
4-
import { hasPlugin, addPlugin } from 'ember-cli-babel-plugin-helpers';
4+
import { hasPlugin, addPlugin, AddPluginOptions } from 'ember-cli-babel-plugin-helpers';
55
import Addon from 'ember-cli/lib/models/addon';
66
import { addon } from './lib/utilities/ember-cli-entities';
77
import fork from './lib/utilities/fork';
@@ -77,15 +77,19 @@ export default addon({
7777
// preprocessor registry, so we need to beat it to the punch.
7878
this._registerBabelExtension();
7979

80-
let pluginTarget = this._getConfigurationTarget();
81-
82-
if (!hasPlugin(pluginTarget, '@babel/plugin-transform-typescript')) {
83-
// Needs to come after the class properties plugin (see tests/unit/build-test.ts -
84-
// "property initialization occurs in the right order")
85-
addPlugin(pluginTarget, require.resolve('@babel/plugin-transform-typescript'), {
86-
after: ['@babel/plugin-proposal-class-properties'],
87-
});
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+
let tsVersion = this._getProjectTypeScriptVersion();
83+
if (semver.gte(tsVersion, '3.7.0-alpha.0')) {
84+
this._addBabelPluginIfNotPresent('@babel/plugin-proposal-optional-chaining');
85+
this._addBabelPluginIfNotPresent('@babel/plugin-proposal-nullish-coalescing-operator');
8886
}
87+
88+
// Needs to come after the class properties plugin (see tests/unit/build-test.ts -
89+
// "property initialization occurs in the right order")
90+
this._addBabelPluginIfNotPresent('@babel/plugin-transform-typescript', {
91+
after: ['@babel/plugin-proposal-class-properties'],
92+
});
8993
},
9094

9195
shouldIncludeChildAddon(addon) {
@@ -179,6 +183,24 @@ export default addon({
179183
}
180184
},
181185

186+
_addBabelPluginIfNotPresent(pluginName: string, pluginOptions?: AddPluginOptions) {
187+
let target = this._getConfigurationTarget();
188+
if (!hasPlugin(target, pluginName)) {
189+
addPlugin(target, pluginName, pluginOptions);
190+
}
191+
},
192+
193+
_getProjectTypeScriptVersion() {
194+
try {
195+
let pkg = this.project.require('typescript/package.json') as { version: string };
196+
return pkg.version;
197+
} catch {
198+
throw new Error(
199+
`[ember-cli-typescript] Unable to determine project TypeScript version; is it installed?`
200+
);
201+
}
202+
},
203+
182204
_addTypecheckMiddleware(app: Application) {
183205
let workerPromise = this._getTypecheckWorker();
184206
let middleware = new TypecheckMiddleware(this.project, workerPromise);

yarn.lock

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,14 @@
401401
"@babel/helper-plugin-utils" "^7.0.0"
402402
"@babel/plugin-syntax-json-strings" "^7.2.0"
403403

404+
"@babel/plugin-proposal-nullish-coalescing-operator@^7.4.4":
405+
version "7.4.4"
406+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.4.4.tgz#41c360d59481d88e0ce3a3f837df10121a769b39"
407+
integrity sha512-Amph7Epui1Dh/xxUxS2+K22/MUi6+6JVTvy3P58tja3B6yKTSjwwx0/d83rF7551D6PVSSoplQb8GCwqec7HRw==
408+
dependencies:
409+
"@babel/helper-plugin-utils" "^7.0.0"
410+
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.2.0"
411+
404412
"@babel/plugin-proposal-object-rest-spread@^7.3.4":
405413
version "7.3.4"
406414
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.3.4.tgz#47f73cf7f2a721aad5c0261205405c642e424654"
@@ -417,6 +425,14 @@
417425
"@babel/helper-plugin-utils" "^7.0.0"
418426
"@babel/plugin-syntax-optional-catch-binding" "^7.2.0"
419427

428+
"@babel/plugin-proposal-optional-chaining@^7.6.0":
429+
version "7.6.0"
430+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.6.0.tgz#e9bf1f9b9ba10c77c033082da75f068389041af8"
431+
integrity sha512-kj4gkZ6qUggkprRq3Uh5KP8XnE1MdIO0J7MhdDX8+rAbB6dJ2UrensGIS+0NPZAaaJ1Vr0PN6oLUgXMU1uMcSg==
432+
dependencies:
433+
"@babel/helper-plugin-utils" "^7.0.0"
434+
"@babel/plugin-syntax-optional-chaining" "^7.2.0"
435+
420436
"@babel/plugin-proposal-unicode-property-regex@^7.2.0":
421437
version "7.2.0"
422438
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.2.0.tgz#abe7281fe46c95ddc143a65e5358647792039520"
@@ -454,6 +470,13 @@
454470
dependencies:
455471
"@babel/helper-plugin-utils" "^7.0.0"
456472

473+
"@babel/plugin-syntax-nullish-coalescing-operator@^7.2.0":
474+
version "7.2.0"
475+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.2.0.tgz#f75083dfd5ade73e783db729bbd87e7b9efb7624"
476+
integrity sha512-lRCEaKE+LTxDQtgbYajI04ddt6WW0WJq57xqkAZ+s11h4YgfRHhVA/Y2VhfPzzFD4qeLHWg32DMp9HooY4Kqlg==
477+
dependencies:
478+
"@babel/helper-plugin-utils" "^7.0.0"
479+
457480
"@babel/plugin-syntax-object-rest-spread@^7.2.0":
458481
version "7.2.0"
459482
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e"
@@ -468,6 +491,13 @@
468491
dependencies:
469492
"@babel/helper-plugin-utils" "^7.0.0"
470493

494+
"@babel/plugin-syntax-optional-chaining@^7.2.0":
495+
version "7.2.0"
496+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.2.0.tgz#a59d6ae8c167e7608eaa443fda9fa8fa6bf21dff"
497+
integrity sha512-HtGCtvp5Uq/jH/WNUPkK6b7rufnCPLLlDAFN7cmACoIjaOOiXxUt3SswU5loHqrhtqTsa/WoLQ1OQ1AGuZqaWA==
498+
dependencies:
499+
"@babel/helper-plugin-utils" "^7.0.0"
500+
471501
"@babel/plugin-syntax-typescript@^7.2.0":
472502
version "7.3.3"
473503
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz#a7cc3f66119a9f7ebe2de5383cce193473d65991"
@@ -6095,7 +6125,7 @@ [email protected]:
60956125
dependencies:
60966126
broccoli-caching-writer "^3.0.3"
60976127
ember-cli-babel "^6.6.0"
6098-
esdoc "github:pzuraq/esdoc#015a342"
6128+
esdoc pzuraq/esdoc#015a342
60996129
esdoc-accessor-plugin "^1.0.0"
61006130
esdoc-ecmascript-proposal-plugin "^1.0.0"
61016131
fs-extra "^5.0.0"
@@ -7502,7 +7532,6 @@ esdoc-ecmascript-proposal-plugin@^1.0.0:
75027532

75037533
"esdoc@github:pzuraq/esdoc#015a342":
75047534
version "1.0.4"
7505-
uid "015a3426b2e53b2b0270a9c00133780db3f1d144"
75067535
resolved "https://codeload.github.com/pzuraq/esdoc/tar.gz/015a3426b2e53b2b0270a9c00133780db3f1d144"
75077536
dependencies:
75087537
babel-generator "6.26.0"
@@ -9461,10 +9490,12 @@ imurmurhash@^0.1.4:
94619490
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
94629491

94639492
"in-repo-a@link:tests/dummy/lib/in-repo-a":
9464-
version "1.0.0"
9493+
version "0.0.0"
9494+
uid ""
94659495

94669496
"in-repo-b@link:tests/dummy/lib/in-repo-b":
9467-
version "1.0.0"
9497+
version "0.0.0"
9498+
uid ""
94689499

94699500
include-path-searcher@^0.1.0:
94709501
version "0.1.0"

0 commit comments

Comments
 (0)