Skip to content

fix(@angular-devkit/build-angular): ensure watch file paths from TypeScript are normalized #26393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { Message, PartialMessage } from 'esbuild';
import { normalize } from 'node:path';
import type { ChangedFiles } from '../../tools/esbuild/watcher';
import type { SourceFileCache } from './angular/source-file-cache';
import type { BuildOutputFile, BuildOutputFileType, BundlerContext } from './bundler-context';
Expand Down Expand Up @@ -88,11 +89,15 @@ export class ExecutionResult {
}

get watchFiles() {
// Bundler contexts internally normalize file dependencies
const files = this.rebuildContexts.flatMap((context) => [...context.watchFiles]);
if (this.codeBundleCache?.referencedFiles) {
files.push(...this.codeBundleCache.referencedFiles);
// These files originate from TS/NG and can have POSIX path separators even on Windows.
// To ensure path comparisons are valid, all these paths must be normalized.
files.push(...this.codeBundleCache.referencedFiles.map(normalize));
}
if (this.codeBundleCache?.loadResultCache) {
// Load result caches internally normalize file dependencies
files.push(...this.codeBundleCache.loadResultCache.watchFiles);
}

Expand Down