|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | +import { replaceInFile } from '../../utils/fs'; |
| 9 | +import { request } from '../../utils/http'; |
| 10 | +import { killAllProcesses, ng } from '../../utils/process'; |
| 11 | +import { createProject, ngServe } from '../../utils/project'; |
| 12 | + |
| 13 | +export default async function() { |
| 14 | + try { |
| 15 | + await createProject('ivy-project-opt-out', '--enable-ivy'); |
| 16 | + // trigger an Ivy builds to process packages with NGCC |
| 17 | + await ng('e2e', '--prod'); |
| 18 | + |
| 19 | + // View Engine (NGC) compilation should work after running NGCC from Webpack |
| 20 | + await replaceInFile('tsconfig.app.json', '"enableIvy": true', '"enableIvy": false'); |
| 21 | + |
| 22 | + // verify that VE compilation works during runtime |
| 23 | + await ng('e2e', '--prod'); |
| 24 | + |
| 25 | + // verify that it is not Ivy |
| 26 | + await ngServe('--prod'); |
| 27 | + // Verify the index.html |
| 28 | + const body = await request('http://localhost:4200/'); |
| 29 | + if (!body.match(/<app-root><\/app-root>/)) { |
| 30 | + throw new Error('Response does not match expected value.'); |
| 31 | + } |
| 32 | + |
| 33 | + // Verify it's compiled with NGC |
| 34 | + const mainUrlMatch = body.match(/src="(main\.[a-z0-9]{0,32}\.js)"/); |
| 35 | + const mainUrl = mainUrlMatch && mainUrlMatch[1]; |
| 36 | + const main = await request('http://localhost:4200/' + mainUrl); |
| 37 | + |
| 38 | + if (main.match(/ngComponentDef\s*=/)) { |
| 39 | + throw new Error('Loaded Ivy but expected View Engine applicatiom.'); |
| 40 | + } |
| 41 | + |
| 42 | + } finally { |
| 43 | + await killAllProcesses(); |
| 44 | + } |
| 45 | +} |
0 commit comments