Skip to content

Commit 9f45745

Browse files
filipesilvaalexeagle
authored andcommitted
feat(@schematics/angular): default Ivy apps to AOT true
Testing on AIO with Angular master as of 28/05/2019 I got these results: JIT ~414ms (369, 378, 408, 323, 593) AOT using VE ~1383ms (1365, 1185, 1767, 1135, 1467) AOT using Ivy ~517ms (600, 391, 444, 756, 394) This is largely due to angular/angular#29380 and angular/angular#30238. The second PR above was not merged to master, and thus will not be in 8.0.0. This PR should be merged to match it.
1 parent 958d4cc commit 9f45745

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
194194
main: `${sourceRoot}/main.ts`,
195195
polyfills: `${sourceRoot}/polyfills.ts`,
196196
tsConfig: `${projectRoot}tsconfig.app.json`,
197+
aot: !!options.enableIvy,
197198
assets: [
198199
`${sourceRoot}/favicon.ico`,
199200
`${sourceRoot}/assets`,

packages/schematics/angular/application/index_spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,24 @@ describe('Application Schematic', () => {
213213
]));
214214
});
215215

216+
it('should set AOT option to false for VE projects', async () => {
217+
const options = { ...defaultOptions };
218+
219+
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
220+
.toPromise();
221+
const workspace = JSON.parse(tree.readContent('/angular.json'));
222+
expect(workspace.projects.foo.architect.build.options.aot).toEqual(false);
223+
});
224+
225+
it('should set AOT option to true for Ivy projects', async () => {
226+
const options = { ...defaultOptions, enableIvy: true };
227+
228+
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
229+
.toPromise();
230+
const workspace = JSON.parse(tree.readContent('/angular.json'));
231+
expect(workspace.projects.foo.architect.build.options.aot).toEqual(true);
232+
});
233+
216234
describe(`update package.json`, () => {
217235
it(`should add build-angular to devDependencies`, async () => {
218236
const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree)

tests/legacy-cli/e2e/tests/build/polyfills.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ng } from '../../utils/process';
99
import { expectToFail } from '../../utils/utils';
1010

1111
export default async function () {
12-
await ng('build');
12+
await ng('build', '--aot=false');
1313
// files were created successfully
1414
await expectFileToMatch('dist/test-project/polyfills-es5.js', 'core-js/proposals/reflect-metadata');
1515
await expectFileToMatch('dist/test-project/polyfills-es5.js', 'zone.js');
@@ -21,7 +21,7 @@ export default async function () {
2121
`);
2222
const jitPolyfillSize = await getFileSize('dist/test-project/polyfills-es5.js');
2323

24-
await ng('build', '--aot');
24+
await ng('build', '--aot=true');
2525
// files were created successfully
2626
await expectFileToExist('dist/test-project/polyfills-es5.js');
2727
await expectFileSizeToBeUnder('dist/test-project/polyfills-es5.js', jitPolyfillSize);

tests/legacy-cli/e2e/tests/build/script-target.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { expectToFail } from '../../utils/utils';
88
export default function () {
99
// TODO(architect): Delete this test. It is now in devkit/build-angular.
1010

11-
// Skip this test in Angular 2, it had different bundles.
11+
// Skip this test in Angular 2, it had different bundles.
1212
if (getGlobalVariable('argv')['ng2']) {
1313
return Promise.resolve();
1414
}
@@ -19,7 +19,7 @@ export default function () {
1919
compilerOptions['target'] = 'es2015';
2020
}))
2121
.then(() => ng('build', '--optimization', '--output-hashing=none', '--vendor-chunk'))
22-
// Check class constructors are present in the vendor output.
23-
.then(() => expectFileToMatch('dist/test-project/vendor-es2015.js', /class \w{constructor\(\){/))
24-
.then(() => expectToFail(() => expectFileToMatch('dist/test-project/vendor-es5.js', /class \w{constructor\(\){/)));
25-
}
22+
// Check class constructors are present in the vendor output.
23+
.then(() => expectFileToMatch('dist/test-project/vendor-es2015.js', /class \w{constructor\(/))
24+
.then(() => expectToFail(() => expectFileToMatch('dist/test-project/vendor-es5.js', /class \w{constructor\(/)));
25+
}

0 commit comments

Comments
 (0)