I successfully integrated Jest cache with our GitLab jobs, and everything worked well. I noticed a significant performance improvement and verified that the cache object met my expectations. However, I encountered an issue where the Jest cache directory's size kept growing over time. To investigate further, I compared two different versions of the cache folder and found multiple instances of duplicated component bundles being cached. Strangely, the file contents were identical, but they existed in various folders.
What perplexed me was that the job ran on the exact same version/branch/codebase, and these components remained unchanged. Despite this, the incremental cache object consistently recreated some map caching for these components. This behavior was not observed in my local settings, even though the settings and scripts were exactly the same.
As an illustration, here are examples of what I found in my cache folder:
- Client.jest-cache\jest-transform-cache-680f9b3d68c715b13f1ba9c1049c9179-ca986ddda9866a0e5968c3a335afc5cd\00\examplecomponent_0001116000f8a5933391e62b89025883
- Client.jest-cache\jest-transform-cache-680f9b3d68c715b13f1ba9c1049c9179-ca986ddda9866a0e5968c3a335afc5cd\1d\examplecomponent_1de8872600db0e811da3c77c31657587
and a lot of references to the same thing, I know that this is not happening for all the components, but just some of them
I hope to resolve this inconsistency between the CI and local environments, as it can potentially impact our build process.