Skip to content

Commit 7df180d

Browse files
alan-agius4vikerman
authored andcommitted
fix(@ngtools/webpack): use a single module resolution cache
1 parent 79f5298 commit 7df180d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,6 @@ export class AngularCompilerPlugin {
355355
this._updateForkedTypeChecker(this._rootNames, this._getChangedCompilationFiles());
356356
}
357357

358-
// Use an identity function as all our paths are absolute already.
359-
this._moduleResolutionCache = ts.createModuleResolutionCache(this._basePath, x => x);
360358
const oldTsProgram = this._getTsProgram();
361359

362360
if (this._JitMode) {
@@ -721,6 +719,9 @@ export class AngularCompilerPlugin {
721719
);
722720
}
723721

722+
// Use an identity function as all our paths are absolute already.
723+
this._moduleResolutionCache = ts.createModuleResolutionCache(this._basePath, x => x);
724+
724725
// Create the webpack compiler host.
725726
const webpackCompilerHost = new WebpackCompilerHost(
726727
this._compilerOptions,
@@ -729,6 +730,7 @@ export class AngularCompilerPlugin {
729730
true,
730731
this._options.directTemplateLoading,
731732
ngccProcessor,
733+
this._moduleResolutionCache,
732734
);
733735

734736
// Create and set a new WebpackResourceLoader in AOT

packages/ngtools/webpack/src/compiler_host.ts

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
4646
private readonly cacheSourceFiles: boolean,
4747
private readonly directTemplateLoading = false,
4848
private readonly ngccProcessor?: NgccProcessor,
49+
private readonly moduleResolutionCache?: ts.ModuleResolutionCache,
4950
) {
5051
this._syncHost = new virtualFs.SyncDelegateHost(host);
5152
this._memoryHost = new virtualFs.SyncDelegateHost(new virtualFs.SimpleMemoryHost());
@@ -405,6 +406,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
405406
workaroundResolve(containingFile),
406407
this._options,
407408
this,
409+
this.moduleResolutionCache,
408410
);
409411

410412
if (this._options.enableIvy && resolvedModule && this.ngccProcessor) {

0 commit comments

Comments
 (0)