Skip to content

Commit c145229

Browse files
committed
build: serve e2e-app in aot mode
* Starts building the e2e-app in AOT mode
1 parent 0103d2a commit c145229

File tree

6 files changed

+59
-42
lines changed

6 files changed

+59
-42
lines changed

src/e2e-app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<script>
2626
System.import('system-config.js').then(function () {
27-
System.import('main');
27+
System.import('main-aot');
2828
}).catch(console.error.bind(console));
2929
</script>
3030
</body>

src/e2e-app/main-aot.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
2+
import {E2eAppModuleNgFactory} from './e2e-app-module.ngfactory';
3+
4+
platformBrowserDynamic().bootstrapModuleFactory(E2eAppModuleNgFactory);

src/e2e-app/main.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/e2e-app/tsconfig-build.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@
1010
"moduleResolution": "node",
1111
"noEmitOnError": true,
1212
"noImplicitAny": true,
13-
"outDir": "../../dist/packages/e2e-app",
13+
"rootDir": ".",
14+
"outDir": ".",
1415
"sourceMap": true,
1516
"target": "es5",
16-
"stripInternal": false,
1717
"typeRoots": [
1818
"../../node_modules/@types/!(node)"
1919
],
2020
"baseUrl": "",
2121
"paths": {
22-
"@angular/material": ["../../dist/packages/material/public_api"]
22+
"@angular/material": ["./material"],
23+
"@angular/cdk": ["./cdk"]
2324
}
2425
},
26+
"files": [
27+
"./e2e-app-module.ts",
28+
"./e2e-app-types.d.ts",
29+
"./main-aot.ts",
30+
"./system-config.ts"
31+
],
2532
"angularCompilerOptions": {
26-
"genDir": "../../dist",
27-
"skipTemplateCodegen": true,
28-
"debug": true
33+
"skipMetadataEmit": true
2934
}
3035
}

tools/gulp/tasks/e2e.ts

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
import {task, watch} from 'gulp';
2-
import * as path from 'path';
3-
4-
import {SOURCE_ROOT, DIST_E2EAPP, PROJECT_ROOT} from '../build-config';
5-
import {
6-
tsBuildTask, copyTask, buildAppTask, execNodeTask, sequenceTask, serverTask
7-
} from '../util/task_helpers';
2+
import {join} from 'path';
3+
import {SOURCE_ROOT, DIST_E2EAPP, PROJECT_ROOT, DIST_RELEASES} from '../build-config';
4+
import {ngcBuildTask, copyTask, execNodeTask, sequenceTask, serverTask} from '../util/task_helpers';
5+
import {copySync} from 'fs-extra';
86

97
// There are no type definitions available for these imports.
108
const gulpConnect = require('gulp-connect');
119

12-
const appDir = path.join(SOURCE_ROOT, 'e2e-app');
10+
const appDir = join(SOURCE_ROOT, 'e2e-app');
1311
const outDir = DIST_E2EAPP;
1412

15-
const PROTRACTOR_CONFIG_PATH = path.join(PROJECT_ROOT, 'test/protractor.conf.js');
16-
const tsconfigPath = path.join(appDir, 'tsconfig-build.json');
13+
const PROTRACTOR_CONFIG_PATH = join(PROJECT_ROOT, 'test/protractor.conf.js');
14+
const tsconfigPath = join(outDir, 'tsconfig-build.json');
1715

18-
task(':watch:e2eapp', () => {
19-
watch(path.join(appDir, '**/*.ts'), [':build:e2eapp:ts']);
20-
watch(path.join(appDir, '**/*.html'), [':build:e2eapp:assets']);
21-
});
16+
/** Glob that matches all files that need to be copied to the output folder. */
17+
const assetsGlob = join(appDir, '**/*.+(html|css|json|ts)');
18+
19+
/**
20+
* Builds and serves the e2e-app and runs protractor once the e2e-app is ready.
21+
*/
22+
task('e2e', sequenceTask(
23+
[':test:protractor:setup', 'serve:e2eapp'],
24+
':test:protractor',
25+
':serve:e2eapp:stop',
26+
'screenshots',
27+
));
2228

23-
/** Builds e2e app ts to js. */
24-
task(':build:e2eapp:ts', tsBuildTask(tsconfigPath));
29+
/** Task that builds the e2e-app in AOT mode. */
30+
task('e2e-app:build', sequenceTask(
31+
'clean',
32+
['material:build-release', 'cdk:build-release'],
33+
['e2e-app:copy-release', 'e2e-app:copy-assets'],
34+
'e2e-app:build-ts'
35+
));
2536

26-
/** Copies e2e app assets (html, css) to build output. */
27-
task(':build:e2eapp:assets', copyTask(appDir, outDir));
37+
/** Task that copies all required assets to the output folder. */
38+
task('e2e-app:copy-assets', copyTask(assetsGlob, outDir));
2839

29-
/** Builds the entire e2e app. */
30-
task('build:e2eapp', buildAppTask('e2eapp'));
40+
/** Task that builds the TypeScript sources. Those are compiled inside of the dist folder. */
41+
task('e2e-app:build-ts', ngcBuildTask(tsconfigPath));
42+
43+
task(':watch:e2eapp', () => {
44+
watch(join(appDir, '**/*.ts'), ['e2e-app:build']);
45+
watch(join(appDir, '**/*.html'), ['e2e-app:copy-assets']);
46+
});
3147

3248
/** Ensures that protractor and webdriver are set up to run. */
3349
task(':test:protractor:setup', execNodeTask('protractor', 'webdriver-manager', ['update']));
@@ -42,21 +58,18 @@ task(':serve:e2eapp', serverTask(outDir, false));
4258
task(':serve:e2eapp:stop', gulpConnect.serverClose);
4359

4460
/** Builds and serves the e2e app. */
45-
task('serve:e2eapp', sequenceTask('build:e2eapp', ':serve:e2eapp'));
61+
task('serve:e2eapp', sequenceTask('e2e-app:build', ':serve:e2eapp'));
4662

4763
/**
4864
* [Watch task] Builds and serves e2e app, rebuilding whenever the sources change.
4965
* This should only be used when running e2e tests locally.
5066
*/
5167
task('serve:e2eapp:watch', ['serve:e2eapp', 'material:watch', ':watch:e2eapp']);
5268

53-
/**
54-
* Builds and serves the e2e-app and runs protractor once the e2e-app is ready.
55-
*/
56-
task('e2e', sequenceTask(
57-
[':test:protractor:setup', 'serve:e2eapp'],
58-
':test:protractor',
59-
':serve:e2eapp:stop',
60-
'screenshots',
61-
));
69+
// As a workaround for https://github.com/angular/angular/issues/12249, we need to
70+
// copy the Material and CDK ESM output inside of the demo-app output.
71+
task('e2e-app:copy-release', () => {
72+
copySync(join(DIST_RELEASES, 'material'), join(outDir, 'material'));
73+
copySync(join(DIST_RELEASES, 'cdk'), join(outDir, 'cdk'));
74+
});
6275

tools/gulp/util/task_helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function tsBuildTask(tsConfigPath: string) {
3737
return execNodeTask('typescript', 'tsc', ['-p', tsConfigPath]);
3838
}
3939

40-
/** Creates a task that runs the Angular compiler CLI. */
40+
/** Creates a task that runs the Angular Compiler CLI. */
4141
export function ngcBuildTask(tsConfigPath: string) {
4242
return execNodeTask('@angular/compiler-cli', 'ngc', ['-p', tsConfigPath]);
4343
}

0 commit comments

Comments
 (0)