Skip to content

Commit

Permalink
fix(@ngtools/webpack): only track actual resource file dependencies
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
clydin authored and josephperrott committed Apr 21, 2021
1 parent 22ac3b3 commit ca5ceaa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/ngtools/webpack/src/resource_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import { createHash } from 'crypto';
import * as path from 'path';
import * as vm from 'vm';
import { Compilation, EntryPlugin, NormalModule, library, node, sources } from 'webpack';
import { normalizePath } from './ivy/paths';
Expand Down Expand Up @@ -206,6 +207,14 @@ export class WebpackResourceLoader {
this._fileDependencies.set(filePath, new Set(childCompilation.fileDependencies));
for (const file of childCompilation.fileDependencies) {
const resolvedFile = normalizePath(file);

// Skip paths that do not appear to be files (have no extension).
// `fileDependencies` can contain directories and not just files which can
// cause incorrect cache invalidation on rebuilds.
if (!path.extname(resolvedFile)) {
continue;
}

const entry = this._reverseDependencies.get(resolvedFile);
if (entry) {
entry.add(filePath);
Expand Down

0 comments on commit ca5ceaa

Please sign in to comment.