rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[heft] Move heft-jest-data file to an easily cacheable location

Open elliot-nelson opened this issue 3 years ago • 0 comments

Summary

  • Change the heft data folder location from .heft/ to temp/heft.
  • Modify the HeftJestDataFile location to temp/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 cache temp/heft in the build phase, and temp/code-coverage in the test phase.

There might be a better way to do this. In particular it's a bit messy that HeftJestDataFile doesn'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/heft and successfully run "test" phase after pulling "build" phase from cache.

elliot-nelson avatar May 29 '22 12:05 elliot-nelson