Skip to content

fix(@angular/build): refresh template diagnostics on Windows after an external template changes - #34736

Open
thekhegay wants to merge 2 commits into
angular:mainfrom
thekhegay:build-windows-template-diagnostics
Open

thekhegay wants to merge 2 commits into
angular:mainfrom
thekhegay:build-windows-template-diagnostics

Conversation

@thekhegay

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #34725

On Windows SourceFileCache.invalidate puts path.normalized paths (backslashes) into modifiedFiles, but resource dependencies from compiler have forward slashes. So modifiedFiles.has(resourceDependency) in AotCompilation never matches, diagnostics cache of the component is not dropped and template errors stay stale after editing external template

What is the new behavior?

Resource dependency is normalized before the lookup, same as referencedFiles are normalized in SourceFileCache.invalidate. On POSIX normalize doesnt change anything

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

No test: mismatch only happens with Windows separators, cant reproduce it on Linux/macOS. Issue has repro repo with output from both platforms

… external template changes

On Windows the modified files are normalized to backslash paths while component resource dependencies use forward slashes, so the lookup never matched and the cached Angular diagnostics of the component were kept.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the AotCompilation class in aot-compilation.ts to import and use the normalize function from node:path when checking resource dependencies. This ensures path separator consistency, particularly on Windows platforms. There are no review comments, so I have no feedback to provide.

for (const resourceDependency of resourceDependencies) {
if (
!hostOptions.modifiedFiles.has(resourceDependency) ||
// modifiedFiles holds normalized paths, so the separators differ on Windows

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here is not true. modifiedFiles can be posix paths on Windows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, removed it. Since set can hold both forms it now checks resource path as is and normalized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants