rushstack
rushstack copied to clipboard
[heft] Move heft-jest-data file to an easily cacheable location
Summary
- Change the heft data folder location from
.heft/totemp/heft. - Modify the
HeftJestDataFilelocation totemp/heft/build-cache/heft-jest-data.json.
Fix for #3436.
Details
If you are configuring a monorepo to support build caching and phased builds, and you use Jest, then the generated HeftJestDataFile must be included in your build phase's outputFolderNames configuration.
However, the current location (the .heft/ folder) is a bit of an older naming scheme. My proposal is to move the folder to temp/heft.
- In the Rushstack monorepo, which caches the entirety of
temp/in the build phase, this corrects the problem automatically. - In other monorepos, I would suggest caching specific
temp/subfolders. For example, you might cachetemp/heftin the build phase, andtemp/code-coveragein the test phase.
There might be a better way to do this. In particular it's a bit messy that
HeftJestDataFiledoesn't follow the configuration of Heft, but I don't see an easy way to change that (wiring heft configuration through the BuildTransformer looked messy for example). So I didn't tackle that problem.
How it was tested
- Confirmed locally that with this change, you can cache
temp/heftand successfully run "test" phase after pulling "build" phase from cache.