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
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"autoprefixer": "8.4.1",
"circular-dependency-plugin": "5.0.2",
"clean-css": "4.2.1",
"copy-webpack-plugin": "4.5.2",
"copy-webpack-plugin": "4.5.3",
"file-loader": "2.0.0",
"glob": "7.1.3",
"istanbul": "0.4.5",
Expand Down
28 changes: 22 additions & 6 deletions packages/ngtools/webpack/src/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export class WebpackCompilerHost implements ts.CompilerHost {
private _basePath: Path;
private _resourceLoader?: WebpackResourceLoader;
private _sourceFileCache = new Map<string, ts.SourceFile>();
private _virtualFileExtensions = [
'.js', '.js.map',
'.ngfactory.js', '.ngfactory.js.map',
'.ngstyle.js', '.ngstyle.js.map',
'.ngsummary.json',
];


constructor(
private _options: ts.CompilerOptions,
Expand Down Expand Up @@ -79,19 +86,28 @@ export class WebpackCompilerHost implements ts.CompilerHost {

invalidate(fileName: string): void {
const fullPath = this.resolve(fileName);

if (this._memoryHost.exists(fullPath)) {
this._memoryHost.delete(fullPath);
}

this._sourceFileCache.delete(fullPath);

let exists = false;
try {
const exists = this._syncHost.isFile(fullPath);
exists = this._syncHost.isFile(fullPath);
if (exists) {
this._changedFiles.add(fullPath);
}
} catch { }

// File doesn't exist anymore and is not a factory, so we should delete the related
// virtual files.
if (!exists && fullPath.endsWith('.ts') && !(
fullPath.endsWith('.ngfactory.ts') || fullPath.endsWith('.shim.ngstyle.ts')
)) {
this._virtualFileExtensions.forEach(ext => {
const virtualFile = (fullPath.slice(0, -3) + ext) as Path;
if (this._memoryHost.exists(virtualFile)) {
this._memoryHost.delete(virtualFile);
}
});
}
}

fileExists(fileName: string, delegate = true): boolean {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2285,10 +2285,10 @@ copy-descriptor@^0.1.0:
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=

copy-webpack-plugin@4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.2.tgz#d53444a8fea2912d806e78937390ddd7e632ee5c"
integrity sha512-zmC33E8FFSq3AbflTvqvPvBo621H36Afsxlui91d+QyZxPIuXghfnTsa1CuqiAaCPgJoSUWfTFbKJnadZpKEbQ==
copy-webpack-plugin@4.5.3:
version "4.5.3"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.3.tgz#14a224d205e46f7a79f7956028e1da6df2225ff2"
integrity sha512-VKCiNXQcc8zyznaepXfKpCH2cZD+/j3T3B+gsFY97P7qMlEsj34wr/sI9OCG7QPUUh7gAHVx3q8Q1rdQIDM4bA==
dependencies:
cacache "^10.0.4"
find-cache-dir "^1.0.0"
Expand Down