Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@ngtools/webpack): remove use of Webpack compilation fileTimestam…
…ps property The `fileTimestamps` property on the Webpack compilation object no longer exists with Webpack 5. This change uses the Webpack compiler's property of the same name instead. The cache invalidation is also moved to a separate file and now calculates the changed file set as well. This eliminates the second iteration of the file timestamps within the resource loader.
- Loading branch information
1 parent
c21742b
commit 391d60c
Showing
3 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import * as ts from 'typescript'; | ||
import { normalizePath } from './paths'; | ||
|
||
export class SourceFileCache extends Map<string, ts.SourceFile> { | ||
invalidate( | ||
fileTimestamps: Map<string, number | { timestamp: number } | null>, | ||
buildTimestamp: number, | ||
): Set<string> { | ||
const changedFiles = new Set<string>(); | ||
for (const [file, timeOrEntry] of fileTimestamps) { | ||
const time = | ||
timeOrEntry && (typeof timeOrEntry === 'number' ? timeOrEntry : timeOrEntry.timestamp); | ||
if (time === null || buildTimestamp < time) { | ||
// Cache stores paths using the POSIX directory separator | ||
const normalizedFile = normalizePath(file); | ||
this.delete(normalizedFile); | ||
changedFiles.add(normalizedFile); | ||
} | ||
} | ||
|
||
return changedFiles; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters