yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.47k stars 1.12k forks source link

[Feature] Support layer zip file as an alternative to cache folder #6578

Open Downchuck opened 1 month ago

Downchuck commented 1 month ago

Describe the user story

Enable the cacheFolder to point to a store zip archive which contains all of the zip files that would otherwise be in a folder.

Describe the solution you'd like

Yarn Berry functions well in putting zip files into a local .yarn/cache folder which can then be zipped up as a layer.zip for deployment to cloud services such as AWS Lambda. In some deployment cases it would be nice to distribute that zip file directly without requiring an unzip pass.

As the zip archives in the cache folder are already loaded through yarn's zip processing, allowing the cacheFolder feature, perhaps as cacheArchive to point to a read-only zip may be well supported.

Describe the drawbacks of your solution

This is a niche feature, which adds one level of indirection from fs readdir and seek; while that is unlikely to cause any concern, simply supporting the feature does add more complexity to the list of yarn settings. The solution is for read-only archives and users may request additional tooling, such as explicit instructions on how to zip their current cache folder to make a zip file.

Describe alternatives you've considered

Simply unzipping the cache archive works well, and for zero install, a cache archive can be more appropriate than many zip files. That stated, if a zip archive is modified with intention, the update of the dependency will be nearly the same size as if it was a separate file.

And so a repository whether on blob store or in revision control, may have a single .yarn/cacheArchive.zip file and still work within practice as well as having the many .yarn/cache/...zip files as we do in present use.