Skip to content

Commit 0236451

Browse files
committed
fix(@angular-devkit/build-angular): always normalize AOT file reference tracker paths
The path comparisons for the TypeScript and AOT file reference tracking now use the native path normalization functions. This avoids issues where the TypeScript paths which use POSIX separators may not correct match system paths. The file reference tracking is used to trigger updates to both web workers as well as component stylesheets that have preprocessor (Sass/Less/etc.) dependencies. (cherry picked from commit 1d82a7c)
1 parent 7c7c0ac commit 0236451

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/file-reference-tracker.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { normalize } from 'node:path';
10+
911
export class FileReferenceTracker {
1012
#referencingFiles = new Map<string, Set<string>>();
1113

@@ -14,17 +16,19 @@ export class FileReferenceTracker {
1416
}
1517

1618
add(containingFile: string, referencedFiles: Iterable<string>): void {
19+
const normalizedContainingFile = normalize(containingFile);
1720
for (const file of referencedFiles) {
18-
if (file === containingFile) {
21+
const normalizedReferencedFile = normalize(file);
22+
if (normalizedReferencedFile === normalizedContainingFile) {
1923
// Containing file is already known to the AOT compiler
2024
continue;
2125
}
2226

23-
const referencing = this.#referencingFiles.get(file);
27+
const referencing = this.#referencingFiles.get(normalizedReferencedFile);
2428
if (referencing === undefined) {
25-
this.#referencingFiles.set(file, new Set([containingFile]));
29+
this.#referencingFiles.set(normalizedReferencedFile, new Set([normalizedContainingFile]));
2630
} else {
27-
referencing.add(containingFile);
31+
referencing.add(normalizedContainingFile);
2832
}
2933
}
3034
}
@@ -39,14 +43,15 @@ export class FileReferenceTracker {
3943

4044
// Add referencing files to fully notify the AOT compiler of required component updates
4145
for (const modifiedFile of changed) {
42-
const referencing = this.#referencingFiles.get(modifiedFile);
46+
const normalizedModifiedFile = normalize(modifiedFile);
47+
const referencing = this.#referencingFiles.get(normalizedModifiedFile);
4348
if (referencing) {
4449
allChangedFiles ??= new Set(changed);
4550
for (const referencingFile of referencing) {
4651
allChangedFiles.add(referencingFile);
4752
}
4853
// Cleanup the stale record which will be updated by new resource transforms
49-
this.#referencingFiles.delete(modifiedFile);
54+
this.#referencingFiles.delete(normalizedModifiedFile);
5055
}
5156
}
5257

0 commit comments

Comments
 (0)