@@ -3,15 +3,14 @@ import { basename, dirname, extname, join, normalize, relative, resolve } from '
33
44import 'reflect-metadata' ;
55import { CompilerOptions , createProgram , ParsedCommandLine , Program , transpileModule , TranspileOptions , TranspileOutput } from 'typescript' ;
6- import { CodeGenerator , NgcCliOptions , NodeReflectorHostContext , ReflectorHost , StaticReflector } from '@angular/compiler-cli' ;
6+ import { NgcCliOptions } from '@angular/compiler-cli' ;
77import { tsc } from '@angular/tsc-wrapped/src/tsc' ;
88import AngularCompilerOptions from '@angular/tsc-wrapped/src/options' ;
99
1010import { HybridFileSystem } from '../util/hybrid-file-system' ;
1111import { getInstance as getHybridFileSystem } from '../util/hybrid-file-system-factory' ;
1212import { getInstance } from './compiler-host-factory' ;
1313import { NgcCompilerHost } from './compiler-host' ;
14- import { patchReflectorHost } from './reflector-host' ;
1514import { getFallbackMainContent , replaceBootstrap } from './utils' ;
1615import { Logger } from '../logger/logger' ;
1716import { printDiagnostics , clearDiagnostics , DiagnosticsType } from '../logger/logger-diagnostics' ;
@@ -21,13 +20,13 @@ import { BuildError } from '../util/errors';
2120import { changeExtension } from '../util/helpers' ;
2221import { BuildContext } from '../util/interfaces' ;
2322
23+ import { doCodegen } from './codegen' ;
24+
2425export class AotCompiler {
2526
2627 private tsConfig : ParsedTsConfig ;
2728 private angularCompilerOptions : AngularCompilerOptions ;
2829 private program : Program ;
29- private reflector : StaticReflector ;
30- private reflectorHost : ReflectorHost ;
3130 private compilerHost : NgcCompilerHost ;
3231 private fileSystem : HybridFileSystem ;
3332 private lazyLoadedModuleDictionary : any ;
@@ -43,8 +42,6 @@ export class AotCompiler {
4342 this . fileSystem = getHybridFileSystem ( ) ;
4443 this . compilerHost = getInstance ( this . tsConfig . parsed . options ) ;
4544 this . program = createProgram ( this . tsConfig . parsed . fileNames , this . tsConfig . parsed . options , this . compilerHost ) ;
46- this . reflectorHost = new ReflectorHost ( this . program , this . compilerHost , this . angularCompilerOptions ) ;
47- this . reflector = new StaticReflector ( this . reflectorHost ) ;
4845 }
4946
5047 compile ( ) : Promise < void > {
@@ -58,20 +55,13 @@ export class AotCompiler {
5855 basePath : this . options . rootDir
5956 } ;
6057
61- // Create the Code Generator.
62- const codeGenerator = CodeGenerator . create (
63- this . angularCompilerOptions ,
64- i18nOptions ,
65- this . program ,
66- this . compilerHost ,
67- new NodeReflectorHostContext ( this . compilerHost )
68- ) ;
69-
70- // We need to temporarily patch the CodeGenerator until either it's patched or allows us
71- // to pass in our own ReflectorHost.
72- patchReflectorHost ( codeGenerator ) ;
7358 Logger . debug ( '[AotCompiler] compile: starting codegen ... ' ) ;
74- return codeGenerator . codegen ( { transitiveModules : true } ) ;
59+ return doCodegen ( {
60+ angularCompilerOptions : this . angularCompilerOptions ,
61+ cliOptions : i18nOptions ,
62+ program : this . program ,
63+ compilerHost : this . compilerHost
64+ } ) ;
7565 } ) . then ( ( ) => {
7666 Logger . debug ( '[AotCompiler] compile: starting codegen ... DONE' ) ;
7767 Logger . debug ( '[AotCompiler] compile: Creating and validating new TypeScript Program ...' ) ;
0 commit comments