|
1 | 1 | import {task} from 'gulp';
|
2 |
| -import {DIST_DEMOAPP, SOURCE_ROOT} from '../constants'; |
3 |
| -import {sequenceTask} from '../util/task_helpers'; |
| 2 | +import {copySync} from 'fs-extra'; |
| 3 | +import {DIST_DEMOAPP, DIST_RELEASE} from '../constants'; |
| 4 | +import {sequenceTask, execNodeTask} from '../util/task_helpers'; |
4 | 5 | import {join} from 'path';
|
5 |
| -import {Program, CompilerHost} from 'typescript'; |
6 |
| -import { |
7 |
| - main as tsc, CodeGenerator, AngularCompilerOptions, NgcCliOptions |
8 |
| -} from '@angular/compiler-cli'; |
9 | 6 |
|
10 |
| -const tsconfigFile = join(SOURCE_ROOT, 'demo-app', 'tsconfig-aot.json'); |
| 7 | +const tsconfigFile = join(DIST_DEMOAPP, 'tsconfig-aot.json'); |
11 | 8 |
|
12 | 9 | /** Builds the demo-app and library. To be able to run NGC, apply the metadata workaround. */
|
13 |
| -task('aot:deps', sequenceTask('build:devapp', 'library:build:fix-metadata')); |
| 10 | +task('aot:deps', sequenceTask('build:devapp', ':package:release', 'aot:copy-release')); |
14 | 11 |
|
15 |
| -/** After building the demo-app, run the Angular compiler to verify that all components work. */ |
16 |
| -task('aot:build', ['aot:deps'], () => runAngularCompiler()); |
| 12 | +// As a workaround for https://github.com/angular/angular/issues/12249, we need to |
| 13 | +// copy the Material ESM output inside of the demo-app output. |
| 14 | +task('aot:copy-release', () => { |
| 15 | + copySync(DIST_RELEASE, join(DIST_DEMOAPP, 'material')); |
| 16 | +}); |
17 | 17 |
|
18 |
| -/** |
19 |
| - * Angular does not expose a public function to run the Angular compiler. |
20 |
| - * Creating the CodeGenerator from NGC and using it inside of tsc-wrapped is the same. */ |
21 |
| -function runAngularCompiler() { |
22 |
| - return tsc(tsconfigFile, {basePath: DIST_DEMOAPP}, codegen); |
23 |
| -} |
24 |
| - |
25 |
| -/** |
26 |
| - * Codgen function from the @angular/compiler-cli package. |
27 |
| - * See: https://github.com/angular/angular/blob/master/packages/compiler-cli/src/main.ts |
28 |
| - */ |
29 |
| -function codegen(ngOptions: AngularCompilerOptions, cliOptions: NgcCliOptions, program: Program, |
30 |
| - host: CompilerHost) { |
31 |
| - return CodeGenerator.create(ngOptions, cliOptions, program, host).codegen(); |
32 |
| -} |
| 18 | +/** Build the demo-app and a release to confirm that the library is AOT-compatible. */ |
| 19 | +task('aot:build', ['aot:deps'], execNodeTask( |
| 20 | + '@angular/compiler-cli', 'ngc', ['-p', tsconfigFile] |
| 21 | +)); |
0 commit comments