Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions etc/api/angular_devkit/core/src/_golden-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ export declare class SimpleMemoryHost implements Host<{}> {
list(path: Path): Observable<PathFragment[]>;
read(path: Path): Observable<FileBuffer>;
rename(from: Path, to: Path): Observable<void>;
reset(): void;
stat(path: Path): Observable<Stats<{}> | null> | null;
watch(path: Path, options?: HostWatchOptions): Observable<HostWatchEvent> | null;
write(path: Path, content: FileBuffer): Observable<void>;
Expand Down
5 changes: 5 additions & 0 deletions packages/angular_devkit/core/src/virtual-fs/host/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,9 @@ export class SimpleMemoryHost implements Host<{}> {
watch(path: Path, options?: HostWatchOptions): Observable<HostWatchEvent> | null {
return this._watch(path, options);
}

reset(): void {
this._cache.clear();
this._watchers.clear();
}
}
1 change: 1 addition & 0 deletions packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ export class AngularCompilerPlugin {
this._program = null;
this._transformers = [];
this._resourceLoader = undefined;
this._compilerHost.reset();
}
});
});
Expand Down
12 changes: 11 additions & 1 deletion packages/ngtools/webpack/src/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const dev = Math.floor(Math.random() * 10000);

export class WebpackCompilerHost implements ts.CompilerHost {
private _syncHost: virtualFs.SyncDelegateHost;
private _innerMemoryHost: virtualFs.SimpleMemoryHost;
private _memoryHost: virtualFs.SyncDelegateHost;
private _changedFiles = new Set<string>();
private _readResourceFiles = new Set<string>();
Expand Down Expand Up @@ -49,14 +50,23 @@ export class WebpackCompilerHost implements ts.CompilerHost {
private readonly moduleResolutionCache?: ts.ModuleResolutionCache,
) {
this._syncHost = new virtualFs.SyncDelegateHost(host);
this._memoryHost = new virtualFs.SyncDelegateHost(new virtualFs.SimpleMemoryHost());
this._innerMemoryHost = new virtualFs.SimpleMemoryHost();
this._memoryHost = new virtualFs.SyncDelegateHost(this._innerMemoryHost);
this._basePath = normalize(basePath);
}

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

reset() {
this._innerMemoryHost.reset();
this._changedFiles.clear();
this._readResourceFiles.clear();
this._sourceFileCache.clear();
this._resourceLoader = undefined;
}

denormalizePath(path: string) {
return getSystemPath(normalize(path));
}
Expand Down