-
Notifications
You must be signed in to change notification settings - Fork 12k
/
ivy.ts
52 lines (45 loc) · 1.78 KB
/
ivy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { getGlobalVariable } from '../../utils/env';
import { expectFileToExist, replaceInFile } from '../../utils/fs';
import { request } from '../../utils/http';
import { killAllProcesses, ng } from '../../utils/process';
import { ngServe } from '../../utils/project';
export default async function() {
if (getGlobalVariable('argv')['ve']) {
// Don't run this test for VE jobs. It only applies to Ivy.
return;
}
try {
// Add in a reference to a secondary entry-point to check that ngcc processes it correctly
await replaceInFile(
'src/app/app.module.ts',
`import { AppComponent } from './app.component';`,
`import { AppComponent } from './app.component';\nimport { HttpClientModule } from '@angular/common/http';`,
);
await replaceInFile('src/app/app.module.ts', `imports: [`, `imports: [\n HttpClientModule,`);
await ngServe('--prod');
// Check that @angular/common/http was processed by ngcc
await expectFileToExist('node_modules/@angular/common/http/http.d.ts.__ivy_ngcc_bak');
// Verify the index.html
const body = await request('http://localhost:4200/');
if (!body.match(/<app-root><\/app-root>/)) {
throw new Error('Response does not match expected value.');
}
// Verify it's Ivy.
const main = await request('http://localhost:4200/main.js');
if (!main.match(/ɵcmp\s*=/) && !main.match(/\\u0275cmp\s*=/)) {
throw new Error('Ivy could not be found.');
}
if (main.match(/ngDevMode/)) {
throw new Error('NgDevMode was not tree shaken away.');
}
} finally {
killAllProcesses();
}
}