Skip to content

Persist Metro transform and file-map caches under .harness#160

Merged
V3RON merged 2 commits into
mainfrom
feat/cache-package
Jul 14, 2026
Merged

Persist Metro transform and file-map caches under .harness#160
V3RON merged 2 commits into
mainfrom
feat/cache-package

Conversation

@V3RON

@V3RON V3RON commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What is this?

Metro's transform cache and its file-map (haste) cache now persist under .harness/cache/metro and .harness/cache/metro-file-map in 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/cache layout 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 new cache config option group (cache.metro, defaulting to true; cache.version as an invalidation salt folded into Metro's cacheVersion, which is now derived from the package version instead of a static string). The previous unstable__enableMetroCache flag 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/cache also 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.

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.
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview, Comment Jul 14, 2026 12:56pm

Request Review

@V3RON V3RON changed the title feat: persist Metro transform and file-map caches under .harness Persist Metro transform and file-map caches under .harness Jul 14, 2026
@V3RON V3RON merged commit 267b967 into main Jul 14, 2026
6 checks passed
@V3RON V3RON deleted the feat/cache-package branch July 14, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant