Skip to content

fix(@angular/build): restore font stylesheet caching - #34720

Open
nagahara-naoki wants to merge 2 commits into
angular:mainfrom
nagahara-naoki:fix-font-inline-cache
Open

nagahara-naoki wants to merge 2 commits into
angular:mainfrom
nagahara-naoki:fix-font-inline-cache

Conversation

@nagahara-naoki

Copy link
Copy Markdown

Hi! This fixes the font stylesheet disk cache so builds can save downloaded CSS and reuse it on later runs.

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?

The font cache directory is not created automatically, so saving the stylesheet fails silently. Even when the directory exists, cache reads compare a Base64 hash against the hexadecimal hash stored by cache writes. Valid cache files are consequently deleted and downloaded again.

Fixes #34719.

What is the new behavior?

  • Create the parent directory recursively before writing a cached stylesheet.
  • Validate cached content using the existing hexadecimal hash format, allowing subsequent processors to reuse the file without another request.

Add regression coverage for directory creation, reuse across processor instances, corrupted cache entries, disabled caching, and cache write failures.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This fixes the existing font stylesheet cache path. No documentation update is needed for this internal correction.

The reproduction in #34719 was verified with actual CLI 22.2.6 builds: the initial build did not create the cache directory; after creating it manually, the next build discarded the saved file and failed when the font request was unavailable.

Validation: repository formatting, targeted ESLint, and git diff --check. The added regression tests have not been executed locally.

Create the font cache directory before writing and validate cached
stylesheets using the same hexadecimal hash format used when saving them.
Add regression tests for cache reuse and failure handling.

Fixes angular#34719

@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 ensures that the font cache directory is created recursively before writing cached stylesheets, updates the content hash validation to use hex encoding, and adds a comprehensive test suite for the disk cache functionality. The review feedback suggests optimizing the directory creation by using the cache path directly instead of computing dirname(cacheFile), which also allows removing the unused dirname import.

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.

Font inlining cache is not created or reused

1 participant