Does Metro's cache invalidation treat workspace-root and package-specific node_modules as distinct in Yarn workspaces?
20K reputation · 22 Nov 2024, 19:15 UTC
Determine whether Metro's cache‑key generation incorporates a distinction between the repository‑wide node_modules folder and the node_modules folders belonging to individual packages in a Yarn workspace monorepo.
Metro builds its cache hash from file‑system watch events and the resolved module map; in a workspace, a change inside any package's node_modules emits identical watch events for all packages, and the current implementation does not add a workspace‑aware component to the hash. This leaves the behavior undefined for repeatable CI builds, potentially causing unnecessary rebuilds or stale modules. Does Metro currently include a workspace identifier in its cache key? What effect would adding a workspace‑aware hash component have on build determinism? Are there existing configuration patterns that reliably achieve consistent cache invalidation without modifying Metro?