Skip to content

Commit 06feb1c

Browse files
committed
fix(@ngtools/webpack): cleanup more resources after modules are loaded
Followup to #12994
1 parent c3fbdb2 commit 06feb1c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ export class AngularCompilerPlugin {
672672
this._program = null;
673673
this._transformers = [];
674674
this._resourceLoader = undefined;
675+
this._compilerHost.reset();
675676
}
676677
});
677678
});

packages/ngtools/webpack/src/compiler_host.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const dev = Math.floor(Math.random() * 10000);
2020

2121
export class WebpackCompilerHost implements ts.CompilerHost {
2222
private _syncHost: virtualFs.SyncDelegateHost;
23+
private _innerMemoryHost: virtualFs.SimpleMemoryHost;
2324
private _memoryHost: virtualFs.SyncDelegateHost;
2425
private _changedFiles = new Set<string>();
2526
private _readResourceFiles = new Set<string>();
@@ -49,14 +50,23 @@ export class WebpackCompilerHost implements ts.CompilerHost {
4950
private readonly moduleResolutionCache?: ts.ModuleResolutionCache,
5051
) {
5152
this._syncHost = new virtualFs.SyncDelegateHost(host);
52-
this._memoryHost = new virtualFs.SyncDelegateHost(new virtualFs.SimpleMemoryHost());
53+
this._innerMemoryHost = new virtualFs.SimpleMemoryHost();
54+
this._memoryHost = new virtualFs.SyncDelegateHost(this._innerMemoryHost);
5355
this._basePath = normalize(basePath);
5456
}
5557

5658
private get virtualFiles(): Path[] {
5759
return [...((this._memoryHost.delegate as {}) as { _cache: Map<Path, {}> })._cache.keys()];
5860
}
5961

62+
reset() {
63+
this._innerMemoryHost.reset();
64+
this._changedFiles.clear();
65+
this._readResourceFiles.clear();
66+
this._sourceFileCache.clear();
67+
this._resourceLoader = undefined;
68+
}
69+
6070
denormalizePath(path: string) {
6171
return getSystemPath(normalize(path));
6272
}

0 commit comments

Comments
 (0)