From f2ee4f68863ebafedf46649d9bd77b95b2b8ac96 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 24 Jul 2019 09:26:46 +0200 Subject: [PATCH] fix(@ngtools/webpack): use a single module resolution cache --- packages/ngtools/webpack/src/angular_compiler_plugin.ts | 6 ++++-- packages/ngtools/webpack/src/compiler_host.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/ngtools/webpack/src/angular_compiler_plugin.ts b/packages/ngtools/webpack/src/angular_compiler_plugin.ts index 872b47f37ca7..76608a957099 100644 --- a/packages/ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/ngtools/webpack/src/angular_compiler_plugin.ts @@ -355,8 +355,6 @@ export class AngularCompilerPlugin { this._updateForkedTypeChecker(this._rootNames, this._getChangedCompilationFiles()); } - // Use an identity function as all our paths are absolute already. - this._moduleResolutionCache = ts.createModuleResolutionCache(this._basePath, x => x); const oldTsProgram = this._getTsProgram(); if (this._JitMode) { @@ -675,6 +673,9 @@ export class AngularCompilerPlugin { ); } + // Use an identity function as all our paths are absolute already. + this._moduleResolutionCache = ts.createModuleResolutionCache(this._basePath, x => x); + // Create the webpack compiler host. const webpackCompilerHost = new WebpackCompilerHost( this._compilerOptions, @@ -683,6 +684,7 @@ export class AngularCompilerPlugin { true, this._options.directTemplateLoading, ngccProcessor, + this._moduleResolutionCache, ); // Create and set a new WebpackResourceLoader in AOT diff --git a/packages/ngtools/webpack/src/compiler_host.ts b/packages/ngtools/webpack/src/compiler_host.ts index 915b94454dc4..042195b96e32 100644 --- a/packages/ngtools/webpack/src/compiler_host.ts +++ b/packages/ngtools/webpack/src/compiler_host.ts @@ -46,6 +46,7 @@ export class WebpackCompilerHost implements ts.CompilerHost { private readonly cacheSourceFiles: boolean, private readonly directTemplateLoading = false, private readonly ngccProcessor?: NgccProcessor, + private readonly moduleResolutionCache?: ts.ModuleResolutionCache, ) { this._syncHost = new virtualFs.SyncDelegateHost(host); this._memoryHost = new virtualFs.SyncDelegateHost(new virtualFs.SimpleMemoryHost()); @@ -405,6 +406,7 @@ export class WebpackCompilerHost implements ts.CompilerHost { workaroundResolve(containingFile), this._options, this, + this.moduleResolutionCache, ); if (this._options.enableIvy && resolvedModule && this.ngccProcessor) {