@@ -22,19 +22,15 @@ import {ModuleWithProvidersScanner} from '../../modulewithproviders';
2222import { PartialEvaluator } from '../../partial_evaluator' ;
2323import { NOOP_PERF_RECORDER , PerfRecorder } from '../../perf' ;
2424import { TypeScriptReflectionHost } from '../../reflection' ;
25- import { HostResourceLoader } from '../../resource' ;
25+ import { AdapterResourceLoader } from '../../resource' ;
2626import { entryPointKeyFor , NgModuleRouteAnalyzer } from '../../routing' ;
2727import { ComponentScopeReader , LocalModuleScopeRegistry , MetadataDtsModuleScopeResolver } from '../../scope' ;
2828import { generatedFactoryTransform } from '../../shims' ;
2929import { ivySwitchTransform } from '../../switch' ;
3030import { aliasTransformFactory , declarationTransformFactory , DecoratorHandler , DtsTransformRegistry , ivyTransformFactory , TraitCompiler } from '../../transform' ;
3131import { isTemplateDiagnostic , TemplateTypeChecker , TypeCheckContext , TypeCheckingConfig , TypeCheckingProgramStrategy } from '../../typecheck' ;
3232import { getSourceFileOrNull , isDtsPath , resolveModuleName } from '../../util/src/typescript' ;
33- import { LazyRoute , NgCompilerOptions } from '../api' ;
34-
35- import { NgCompilerHost } from './host' ;
36-
37-
33+ import { LazyRoute , NgCompilerAdapter , NgCompilerOptions } from '../api' ;
3834
3935/**
4036 * State information about a compilation which is only generated once some data is requested from
@@ -94,18 +90,18 @@ export class NgCompiler {
9490 private nextProgram : ts . Program ;
9591 private entryPoint : ts . SourceFile | null ;
9692 private moduleResolver : ModuleResolver ;
97- private resourceManager : HostResourceLoader ;
93+ private resourceManager : AdapterResourceLoader ;
9894 private cycleAnalyzer : CycleAnalyzer ;
9995 readonly incrementalDriver : IncrementalDriver ;
10096 readonly ignoreForDiagnostics : Set < ts . SourceFile > ;
10197 readonly ignoreForEmit : Set < ts . SourceFile > ;
10298
10399 constructor (
104- private host : NgCompilerHost , private options : NgCompilerOptions ,
100+ private adapter : NgCompilerAdapter , private options : NgCompilerOptions ,
105101 private tsProgram : ts . Program ,
106102 private typeCheckingProgramStrategy : TypeCheckingProgramStrategy ,
107103 oldProgram : ts . Program | null = null , private perfRecorder : PerfRecorder = NOOP_PERF_RECORDER ) {
108- this . constructionDiagnostics . push ( ...this . host . diagnostics ) ;
104+ this . constructionDiagnostics . push ( ...this . adapter . constructionDiagnostics ) ;
109105 const incompatibleTypeCheckOptionsDiagnostic = verifyCompatibleTypeCheckOptions ( this . options ) ;
110106 if ( incompatibleTypeCheckOptionsDiagnostic !== null ) {
111107 this . constructionDiagnostics . push ( incompatibleTypeCheckOptionsDiagnostic ) ;
@@ -115,18 +111,19 @@ export class NgCompiler {
115111 this . closureCompilerEnabled = ! ! this . options . annotateForClosureCompiler ;
116112
117113 this . entryPoint =
118- host . entryPoint !== null ? getSourceFileOrNull ( tsProgram , host . entryPoint ) : null ;
114+ adapter . entryPoint !== null ? getSourceFileOrNull ( tsProgram , adapter . entryPoint ) : null ;
119115
120116 const moduleResolutionCache = ts . createModuleResolutionCache (
121- this . host . getCurrentDirectory ( ) , fileName => this . host . getCanonicalFileName ( fileName ) ) ;
117+ this . adapter . getCurrentDirectory ( ) ,
118+ fileName => this . adapter . getCanonicalFileName ( fileName ) ) ;
122119 this . moduleResolver =
123- new ModuleResolver ( tsProgram , this . options , this . host , moduleResolutionCache ) ;
124- this . resourceManager = new HostResourceLoader ( host , this . options ) ;
120+ new ModuleResolver ( tsProgram , this . options , this . adapter , moduleResolutionCache ) ;
121+ this . resourceManager = new AdapterResourceLoader ( adapter , this . options ) ;
125122 this . cycleAnalyzer = new CycleAnalyzer ( new ImportGraph ( this . moduleResolver ) ) ;
126123
127124 let modifiedResourceFiles : Set < string > | null = null ;
128- if ( this . host . getModifiedResourceFiles !== undefined ) {
129- modifiedResourceFiles = this . host . getModifiedResourceFiles ( ) || null ;
125+ if ( this . adapter . getModifiedResourceFiles !== undefined ) {
126+ modifiedResourceFiles = this . adapter . getModifiedResourceFiles ( ) || null ;
130127 }
131128
132129 if ( oldProgram === null ) {
@@ -146,9 +143,9 @@ export class NgCompiler {
146143 setIncrementalDriver ( tsProgram , this . incrementalDriver ) ;
147144
148145 this . ignoreForDiagnostics =
149- new Set ( tsProgram . getSourceFiles ( ) . filter ( sf => this . host . isShim ( sf ) ) ) ;
146+ new Set ( tsProgram . getSourceFiles ( ) . filter ( sf => this . adapter . isShim ( sf ) ) ) ;
150147
151- this . ignoreForEmit = this . host . ignoreForEmit ;
148+ this . ignoreForEmit = this . adapter . ignoreForEmit ;
152149 }
153150
154151 /**
@@ -279,7 +276,7 @@ export class NgCompiler {
279276 const containingFile = this . tsProgram . getRootFileNames ( ) [ 0 ] ;
280277 const [ entryPath , moduleName ] = entryRoute . split ( '#' ) ;
281278 const resolvedModule =
282- resolveModuleName ( entryPath , containingFile , this . options , this . host , null ) ;
279+ resolveModuleName ( entryPath , containingFile , this . options , this . adapter , null ) ;
283280
284281 if ( resolvedModule ) {
285282 entryRoute = entryPointKeyFor ( resolvedModule . resolvedFileName , moduleName ) ;
@@ -326,8 +323,9 @@ export class NgCompiler {
326323 afterDeclarations . push ( aliasTransformFactory ( compilation . traitCompiler . exportStatements ) ) ;
327324 }
328325
329- if ( this . host . factoryTracker !== null ) {
330- before . push ( generatedFactoryTransform ( this . host . factoryTracker . sourceInfo , importRewriter ) ) ;
326+ if ( this . adapter . factoryTracker !== null ) {
327+ before . push (
328+ generatedFactoryTransform ( this . adapter . factoryTracker . sourceInfo , importRewriter ) ) ;
331329 }
332330 before . push ( ivySwitchTransform ) ;
333331
@@ -499,7 +497,7 @@ export class NgCompiler {
499497 const typeCheckSpan = this . perfRecorder . start ( 'typeCheckDiagnostics' ) ;
500498 const diagnostics : ts . Diagnostic [ ] = [ ] ;
501499 for ( const sf of this . tsProgram . getSourceFiles ( ) ) {
502- if ( sf . isDeclarationFile || this . host . isShim ( sf ) ) {
500+ if ( sf . isDeclarationFile || this . adapter . isShim ( sf ) ) {
503501 continue ;
504502 }
505503
@@ -600,7 +598,7 @@ export class NgCompiler {
600598 // Construct the ReferenceEmitter.
601599 let refEmitter : ReferenceEmitter ;
602600 let aliasingHost : AliasingHost | null = null ;
603- if ( this . host . unifiedModulesHost === null || ! this . options . _useHostForImportGeneration ) {
601+ if ( this . adapter . unifiedModulesHost === null || ! this . options . _useHostForImportGeneration ) {
604602 let localImportStrategy : ReferenceEmitStrategy ;
605603
606604 // The strategy used for local, in-project imports depends on whether TS has been configured
@@ -613,7 +611,7 @@ export class NgCompiler {
613611 // rootDirs logic is in effect - use the `LogicalProjectStrategy` for in-project relative
614612 // imports.
615613 localImportStrategy = new LogicalProjectStrategy (
616- reflector , new LogicalFileSystem ( [ ...this . host . rootDirs ] , this . host ) ) ;
614+ reflector , new LogicalFileSystem ( [ ...this . adapter . rootDirs ] , this . adapter ) ) ;
617615 } else {
618616 // Plain relative imports are all that's needed.
619617 localImportStrategy = new RelativePathStrategy ( reflector ) ;
@@ -648,9 +646,9 @@ export class NgCompiler {
648646 // Then use aliased references (this is a workaround to StrictDeps checks).
649647 new AliasStrategy ( ) ,
650648 // Then use fileNameToModuleName to emit imports.
651- new UnifiedModulesStrategy ( reflector , this . host . unifiedModulesHost ) ,
649+ new UnifiedModulesStrategy ( reflector , this . adapter . unifiedModulesHost ) ,
652650 ] ) ;
653- aliasingHost = new UnifiedModulesAliasingHost ( this . host . unifiedModulesHost ) ;
651+ aliasingHost = new UnifiedModulesAliasingHost ( this . adapter . unifiedModulesHost ) ;
654652 }
655653
656654 const evaluator = new PartialEvaluator ( reflector , checker , this . incrementalDriver . depGraph ) ;
@@ -693,7 +691,7 @@ export class NgCompiler {
693691 const handlers : DecoratorHandler < unknown , unknown , unknown > [ ] = [
694692 new ComponentDecoratorHandler (
695693 reflector , evaluator , metaRegistry , metaReader , scopeReader , scopeRegistry , isCore ,
696- this . resourceManager , this . host . rootDirs , this . options . preserveWhitespaces || false ,
694+ this . resourceManager , this . adapter . rootDirs , this . options . preserveWhitespaces || false ,
697695 this . options . i18nUseExternalIds !== false ,
698696 this . options . enableI18nLegacyMessageIdFormat !== false ,
699697 this . options . i18nNormalizeLineEndingsInICUs , this . moduleResolver , this . cycleAnalyzer ,
@@ -721,7 +719,7 @@ export class NgCompiler {
721719 injectableRegistry ) ,
722720 new NgModuleDecoratorHandler (
723721 reflector , evaluator , metaReader , metaRegistry , scopeRegistry , referencesRegistry , isCore ,
724- routeAnalyzer , refEmitter , this . host . factoryTracker , defaultImportTracker ,
722+ routeAnalyzer , refEmitter , this . adapter . factoryTracker , defaultImportTracker ,
725723 this . closureCompilerEnabled , injectableRegistry , this . options . i18nInLocale ) ,
726724 ] ;
727725
@@ -731,7 +729,7 @@ export class NgCompiler {
731729
732730 const templateTypeChecker = new TemplateTypeChecker (
733731 this . tsProgram , this . typeCheckingProgramStrategy , traitCompiler ,
734- this . getTypeCheckingConfig ( ) , refEmitter , reflector , this . host , this . incrementalDriver ) ;
732+ this . getTypeCheckingConfig ( ) , refEmitter , reflector , this . adapter , this . incrementalDriver ) ;
735733
736734 return {
737735 isCore,
0 commit comments