The `metro-cache-key` package is an internal utility within the Metro bundler ecosystem, primarily responsible for generating consistent and correct cache keys. These keys are crucial for optimizing build performance by enabling Metro to effectively cache various components, such as transformer outputs and Babel configurations, in React Native projects. The package is currently at version 0.84.3. As an integral part of the larger Metro monorepo, its release schedule is synchronized with Metro's development, typically involving frequent minor updates and occasional hotfixes. A key differentiator is its deep integration and specialized optimization for Metro's internal caching strategy, addressing complex factors like user-defined Babel configs to prevent stale caches and ensure build correctness.
npm install metro-cache-keyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how a cache key might be generated for a simulated Metro project configuration using a conceptual `createCacheKey` function, highlighting its role in identifying unique build contexts for effective caching.
Ensure your Node.js environment meets the minimum requirements: `^20.19.4 || ^22.13.0 || ^24.3.0 || >= 25.0.0`. Upgrade Node.js if necessary.
Always use the latest patch version available (e.g., 0.84.3) to ensure you have the correct TypeScript types. If facing type issues, try clearing your `node_modules` and reinstalling dependencies.
For most React Native developers, `metro-cache-key` is an indirect dependency managed by Metro. Avoid direct imports unless you are specifically working on Metro or a custom transformer/resolver.
When extending Metro's caching mechanisms, ensure all relevant inputs that could affect the output of a build step are included in the cache key generation logic. Refer to Metro's source for how it constructs its own keys.
Update your Node.js installation to a compatible version as specified in the package's `engines` field.
Ensure `metro-cache-key` is listed in your `package.json` and correctly installed. If using TypeScript, update to the latest patch version to mitigate issues with missing type definitions.
Verify the exact named exports provided by the package. Consider using `import * as CacheKey from 'metro-cache-key'` to inspect available exports, or check the package's `index.d.ts` for type definitions.
No dependency data recorded yet.