Skip to content

Commit 4509d3c

Browse files
clydinmgechev
authored andcommittedApr 6, 2020
fix(@angular-devkit/build-optimizer): use TypeScript 3.6
Fixes: #17320
1 parent 142099e commit 4509d3c

File tree

5 files changed

+72
-18
lines changed

5 files changed

+72
-18
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

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@angular/language-service": "github:angular/language-service-builds#e4c45a027958642903873913bdeb5a321b1a2220",
1313
"@angular/localize": "github:angular/localize-builds#00aca0caa37113b01dd270c31fcb1c3009807539",
1414
"@angular/material": "github:angular/material2-builds#261ff75b8acdbfda3d69c65a30898df029816f32",
15+
"@angular/material-moment-adapter": "github:angular/material-moment-adapter-builds#93f405e88f0360127bf2419941ec133dac84b4a5",
1516
"@angular/platform-browser": "github:angular/platform-browser-builds#2f6d4dd67601a7589783a226b8145837dd3c963c",
1617
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#609599de331caf8bc05f6e522823c2f07162772d",
1718
"@angular/platform-server": "github:angular/platform-server-builds#f4b83463f893b894a9984446782086f9bde8b240",
+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
@@ -11560,6 +11560,11 @@ typedarray@^0.0.6:
1156011560
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1156111561
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1156211562

11563+
typescript@3.6.5:
11564+
version "3.6.5"
11565+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.5.tgz#dae20114a7b4ff4bd642db9c8c699f2953e8bbdb"
11566+
integrity sha512-BEjlc0Z06ORZKbtcxGrIvvwYs5hAnuo6TKdNFL55frVDlB+na3z5bsLhFaIxmT+dPWgBIjMo6aNnTOgHHmHgiQ==
11567+
1156311568
typescript@3.8.3:
1156411569
version "3.8.3"
1156511570
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"

0 commit comments

Comments
 (0)
Please sign in to comment.