@@ -33,6 +33,13 @@ export class WebpackCompilerHost implements ts.CompilerHost {
33
33
private _basePath : Path ;
34
34
private _resourceLoader ?: WebpackResourceLoader ;
35
35
private _sourceFileCache = new Map < string , ts . SourceFile > ( ) ;
36
+ private _virtualFileExtensions = [
37
+ '.js' , '.js.map' ,
38
+ '.ngfactory.js' , '.ngfactory.js.map' ,
39
+ '.ngstyle.js' , '.ngstyle.js.map' ,
40
+ '.ngsummary.json' ,
41
+ ] ;
42
+
36
43
37
44
constructor (
38
45
private _options : ts . CompilerOptions ,
@@ -79,19 +86,24 @@ export class WebpackCompilerHost implements ts.CompilerHost {
79
86
80
87
invalidate ( fileName : string ) : void {
81
88
const fullPath = this . resolve ( fileName ) ;
82
-
83
- if ( this . _memoryHost . exists ( fullPath ) ) {
84
- this . _memoryHost . delete ( fullPath ) ;
85
- }
86
-
87
89
this . _sourceFileCache . delete ( fullPath ) ;
88
90
89
91
try {
90
92
const exists = this . _syncHost . isFile ( fullPath ) ;
91
93
if ( exists ) {
92
94
this . _changedFiles . add ( fullPath ) ;
93
95
}
94
- } catch { }
96
+ } catch {
97
+ // File doesn't exist anymore, so we should delete the related virtual files.
98
+ if ( fullPath . endsWith ( '.ts' ) ) {
99
+ this . _virtualFileExtensions . forEach ( ext => {
100
+ const virtualFile = fullPath . replace ( / \. t s $ / , ext ) as Path ;
101
+ if ( this . _memoryHost . exists ( virtualFile ) ) {
102
+ this . _memoryHost . delete ( virtualFile ) ;
103
+ }
104
+ } ) ;
105
+ }
106
+ }
95
107
}
96
108
97
109
fileExists ( fileName : string , delegate = true ) : boolean {
0 commit comments