Persist Metro transform and file-map caches under .harness#160
Merged
Conversation
Introduce @react-native-harness/cache as the single owner of .harness/cache layout and warmth checks. Metro's transform cache moves to .harness/cache/metro and its file-map (haste) cache, previously left in $TMPDIR, is now pinned to .harness/cache/metro-file-map. Both are enabled by default via a new `cache` config option group; `unstable__enableMetroCache` is kept as a deprecated alias for one release. The GitHub Action's cache step now covers both directories under a bumped cache key.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
Metro's transform cache and its file-map (haste) cache now persist under
.harness/cache/metroand.harness/cache/metro-file-mapin your project root, on by default. Previously, persistent caching required opting in (unstable__enableMetroCache), and even then only the transform cache was captured — the file-map cache always fell back to a temp directory and was invisible to CI caching.How does it work?
A new package,
@react-native-harness/cache, owns the.harness/cachelayout and warmth checks; it's the single place that constructs cache paths, so Metro integration, Jest, and future cache domains all consume its narrow API instead of duplicating path logic. Caching is controlled by a newcacheconfig option group (cache.metro, defaulting totrue;cache.versionas an invalidation salt folded into Metro'scacheVersion, which is now derived from the package version instead of a static string). The previousunstable__enableMetroCacheflag still works as a deprecated alias for one release. Cache I/O never fails a run — any filesystem error while creating directories or checking warmth is logged and treated as a cold cache. The GitHub Action's Metro cache step now restores/saves both directories under a bumped cache key so old entries at the previous location aren't mistakenly reused.Why is this useful?
Repeated Metro runs, both locally and in CI, no longer discard the file-map crawl and transform work between invocations by default. Consolidating everything under
.harness/cachealso gives the project a single directory to reason about, back up, or wipe, and sets up a stable component boundary for caching other things (the iOS XCTest agent build, Android AVDs) in a follow-up change.