Skip to content

Commit ca5ceaa

Browse files
clydinjosephperrott
authored andcommitted
fix(@ngtools/webpack): only track actual resource file dependencies
Webpack's `fileDependencies` Set could contain directories as well as files. The directories were previously stored and incorrectly used during cache invalidation which resulted in excessive cache validation. This change attempts to skip directories by ignoring any `fileDependencies` entry that does not have a file extension. (cherry picked from commit b8fc1dc)
1 parent 22ac3b3 commit ca5ceaa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/ngtools/webpack/src/resource_loader.ts

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { createHash } from 'crypto';
9+
import * as path from 'path';
910
import * as vm from 'vm';
1011
import { Compilation, EntryPlugin, NormalModule, library, node, sources } from 'webpack';
1112
import { normalizePath } from './ivy/paths';
@@ -206,6 +207,14 @@ export class WebpackResourceLoader {
206207
this._fileDependencies.set(filePath, new Set(childCompilation.fileDependencies));
207208
for (const file of childCompilation.fileDependencies) {
208209
const resolvedFile = normalizePath(file);
210+
211+
// Skip paths that do not appear to be files (have no extension).
212+
// `fileDependencies` can contain directories and not just files which can
213+
// cause incorrect cache invalidation on rebuilds.
214+
if (!path.extname(resolvedFile)) {
215+
continue;
216+
}
217+
209218
const entry = this._reverseDependencies.get(resolvedFile);
210219
if (entry) {
211220
entry.add(filePath);

0 commit comments

Comments
 (0)