Skip to content

Commit 2885a93

Browse files
clydinmgechev
authored andcommittedApr 6, 2020
fix(@angular-devkit/build-optimizer): use TypeScript 3.6
Fixes: #17320
1 parent 3c808c6 commit 2885a93

File tree

5 files changed

+86
-32
lines changed

5 files changed

+86
-32
lines changed
 

‎packages/angular_devkit/build_optimizer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"loader-utils": "2.0.0",
1313
"source-map": "0.7.3",
1414
"tslib": "1.11.1",
15-
"typescript": "3.8.3",
15+
"typescript": "3.6.5",
1616
"webpack-sources": "1.4.3"
1717
}
1818
}

‎packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ function isTslibHelper(
594594
checker: ts.TypeChecker,
595595
) {
596596

597-
let callExprIdent = callExpr.expression as ts.Identifier | ts.PrivateIdentifier;
597+
let callExprIdent = callExpr.expression as ts.Identifier;
598598

599599
if (callExpr.expression.kind !== ts.SyntaxKind.Identifier) {
600600
if (callExpr.expression.kind === ts.SyntaxKind.PropertyAccessExpression) {

‎tests/legacy-cli/e2e/ng-snapshot/package.json

+15-14
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
"description": "snapshot versions of Angular for e2e testing",
33
"private": true,
44
"dependencies": {
5-
"@angular/animations": "github:angular/animations-builds#9fe8b543b33f555fabc1606876cc4ec363da4537",
6-
"@angular/cdk": "github:angular/cdk-builds#9f8f26403874e3bd1bd48122e22cdb2912930071",
7-
"@angular/common": "github:angular/common-builds#7d19e430b47efd687b35b6789674b92334d397a7",
8-
"@angular/compiler": "github:angular/compiler-builds#60996e104d5efd02bfef34d2cea5f7cd7b6924a1",
9-
"@angular/compiler-cli": "github:angular/compiler-cli-builds#f397a99462f689ab0fa6251221e44138ea8d12c5",
10-
"@angular/core": "github:angular/core-builds#e77932ea8853947401a4d12fee4f37f36f5e0688",
11-
"@angular/forms": "github:angular/forms-builds#ab32de290377792cf1a8dc83a5d081db613c845f",
12-
"@angular/language-service": "github:angular/language-service-builds#70cdb38917ac2ddcc83a198484c0406b98fc45db",
13-
"@angular/localize": "github:angular/localize-builds#898fdff51f203b0ce635f8b362ec286acdbe5c1a",
14-
"@angular/material": "github:angular/material2-builds#c13d96c97b1d3ce2ac06a4d0cc25e9e27ba071ad",
15-
"@angular/platform-browser": "github:angular/platform-browser-builds#4bef44058b37f5457ff3b08ee5f65c8e8848ad56",
16-
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#ad30c159864814f9fcf8589ba255450a4fadf92d",
17-
"@angular/platform-server": "github:angular/platform-server-builds#0010a319bb54a9dc620463f935b762bc1b666e8c",
18-
"@angular/router": "github:angular/router-builds#73578d4471f1a31bf7ea921475aed8962909ae7c"
5+
"@angular/animations": "github:angular/animations-builds#83ac2e068b436216f77de3fae86ae651b8102c2b",
6+
"@angular/cdk": "github:angular/cdk-builds#d8905b3e70eb0df8b9790ca664432a363cc431a9",
7+
"@angular/common": "github:angular/common-builds#1e65621763a7794475dfc82034c7a1d5626e431c",
8+
"@angular/compiler": "github:angular/compiler-builds#6bdc2b5f3483be31ca223229dcf98bc0ebdc1732",
9+
"@angular/compiler-cli": "github:angular/compiler-cli-builds#1336ad7aff4e4a7a7ce3b549e0cc577527e0f14b",
10+
"@angular/core": "github:angular/core-builds#ab7a963a273606aab4bd3fd33d41affd3e1c4368",
11+
"@angular/forms": "github:angular/forms-builds#796e46075c82c315d6dd7c5e517e873f7929d50d",
12+
"@angular/language-service": "github:angular/language-service-builds#e4c45a027958642903873913bdeb5a321b1a2220",
13+
"@angular/localize": "github:angular/localize-builds#00aca0caa37113b01dd270c31fcb1c3009807539",
14+
"@angular/material": "github:angular/material2-builds#261ff75b8acdbfda3d69c65a30898df029816f32",
15+
"@angular/material-moment-adapter": "github:angular/material-moment-adapter-builds#93f405e88f0360127bf2419941ec133dac84b4a5",
16+
"@angular/platform-browser": "github:angular/platform-browser-builds#2f6d4dd67601a7589783a226b8145837dd3c963c",
17+
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#609599de331caf8bc05f6e522823c2f07162772d",
18+
"@angular/platform-server": "github:angular/platform-server-builds#f4b83463f893b894a9984446782086f9bde8b240",
19+
"@angular/router": "github:angular/router-builds#3dea8bb66e4c05e729b35ff9d8f4335c0c719e50"
1920
}
2021
}
+64-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,74 @@
11
import { getGlobalVariable } from '../../utils/env';
2+
import { replaceInFile } from '../../utils/fs';
23
import { ng, silentNpm } from '../../utils/process';
34
import { updateJsonFile } from '../../utils/project';
45

56
const snapshots = require('../../ng-snapshot/package.json');
67

78
export default async function () {
8-
await ng('add', '@angular/material');
9-
10-
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
11-
if (isSnapshotBuild) {
12-
await updateJsonFile('package.json', packageJson => {
13-
const dependencies = packageJson['dependencies'];
14-
// Angular material adds dependencies on other Angular packages
15-
// Iterate over all of the packages to update them to the snapshot version.
16-
for (const [name, version] of Object.entries(snapshots.dependencies)) {
17-
if (name in dependencies) {
18-
dependencies[name] = version;
19-
}
20-
}
21-
});
22-
}
9+
await ng('add', '@angular/material');
10+
11+
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
12+
if (isSnapshotBuild) {
13+
await updateJsonFile('package.json', (packageJson) => {
14+
const dependencies = packageJson['dependencies'];
15+
// Angular material adds dependencies on other Angular packages
16+
// Iterate over all of the packages to update them to the snapshot version.
17+
for (const [name, version] of Object.entries(snapshots.dependencies)) {
18+
if (name in dependencies) {
19+
dependencies[name] = version;
20+
}
21+
}
22+
23+
dependencies['@angular/material-moment-adapter'] =
24+
snapshots.dependencies['@angular/material-moment-adapter'];
25+
});
2326

2427
await silentNpm('install');
25-
await ng('build', '--prod');
28+
} else {
29+
await silentNpm('install', '@angular/material-moment-adapter');
30+
}
31+
32+
await silentNpm('install', 'moment');
33+
34+
await ng('build', '--prod');
35+
36+
// Ensure moment adapter works (uses unique importing mechanism for moment)
37+
// Issue: https://github.com/angular/angular-cli/issues/17320
38+
await replaceInFile(
39+
'src/app/app.module.ts',
40+
`import { AppComponent } from './app.component';`,
41+
`
42+
import { AppComponent } from './app.component';
43+
import {
44+
MomentDateAdapter,
45+
MAT_MOMENT_DATE_FORMATS
46+
} from '@angular/material-moment-adapter';
47+
import {
48+
DateAdapter,
49+
MAT_DATE_LOCALE,
50+
MAT_DATE_FORMATS
51+
} from '@angular/material/core';
52+
`,
53+
);
54+
55+
await replaceInFile(
56+
'src/app/app.module.ts',
57+
`providers: []`,
58+
`
59+
providers: [
60+
{
61+
provide: DateAdapter,
62+
useClass: MomentDateAdapter,
63+
deps: [MAT_DATE_LOCALE]
64+
},
65+
{
66+
provide: MAT_DATE_FORMATS,
67+
useValue: MAT_MOMENT_DATE_FORMATS
68+
}
69+
]
70+
`,
71+
);
72+
73+
await ng('e2e', '--prod');
2674
}

‎yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -11501,6 +11501,11 @@ typedarray@^0.0.6:
1150111501
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1150211502
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1150311503

11504+
typescript@3.6.5:
11505+
version "3.6.5"
11506+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.5.tgz#dae20114a7b4ff4bd642db9c8c699f2953e8bbdb"
11507+
integrity sha512-BEjlc0Z06ORZKbtcxGrIvvwYs5hAnuo6TKdNFL55frVDlB+na3z5bsLhFaIxmT+dPWgBIjMo6aNnTOgHHmHgiQ==
11508+
1150411509
typescript@3.8.3:
1150511510
version "3.8.3"
1150611511
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"

0 commit comments

Comments
 (0)
Please sign in to comment.