Caching lifecycle scripts #1248
-
|
Hi, We have a monorepo that we just migrated from The issue we have at the moment is caching lifecycle scripts of our internal packages. Our monorepo contains a bunch of apps, microservices, and libraries. The libraries need to be built for them to work in our apps or other libraries depending on them. We use We would like to cache those lifecycle script using turborepo, but I can't find a way to do it properly. I've tried giving those scripts a different name and run them manually after we run Is there something I'm missing here? I feel like building using lifecycle scripts is a pretty common usecase, but I really don't see how we can cache them using turborepo, and I also can't seem to find any existing discussion or issue about this. Thanks in advance 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
So, by default, In a monorepo, riding on the Then, you'd use
I'm surprised by this; and I'm wondering if you can provide more detail? This isn't how it's supposed to work... |
Beta Was this translation helpful? Give feedback.
So, by default,
turbostays out of the package install management lifecycle. That's deeply integrated with each package manager and is not something we can safely intercept. You've noted multiple types of behavior where attempting to cache the results of an install could lead to incorrect behavior. Caching of that lifecycle is best handled by the package managers themselves.In a monorepo, riding on the
installrails (prepare,postinstall) isn't an approach I would recommend; I'd typically just encourage^buildwhich will make sure that all things are built correctly. The first<package manager> installwill set up all the workspace links correctly, and then you'd only callinstallagain …