Skip to content

Commit b27561a

Browse files
filipesilvavikerman
authored andcommitted
fix(@ngtools/webpack): don't delete virtual files for resources still on disk
Fix angular#15453
1 parent bac65f4 commit b27561a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/compiler_host.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,16 @@ export class WebpackCompilerHost implements ts.CompilerHost {
141141
return;
142142
}
143143

144-
for (const ext of this._virtualStyleFileExtensions) {
145-
const virtualFile = (fullPath + ext) as Path;
146-
if (this._memoryHost.exists(virtualFile)) {
147-
this._memoryHost.delete(virtualFile);
144+
if (!exists) {
145+
// At this point we're only looking at resource files (html/css/scss/etc).
146+
// If the original was deleted, we should delete the virtual files too.
147+
// If the original it wasn't deleted we should leave them to be overwritten, because webpack
148+
// might begin the loading process before our plugin has re-emitted them.
149+
for (const ext of this._virtualStyleFileExtensions) {
150+
const virtualFile = (fullPath + ext) as Path;
151+
if (this._memoryHost.exists(virtualFile)) {
152+
this._memoryHost.delete(virtualFile);
153+
}
148154
}
149155
}
150156
}

0 commit comments

Comments
 (0)