Add pre-build turbo prune support

Feature Request: Turbo Prune Pre-Build Support

We’re managing a large monorepo where most apps only need a fraction of the total dependencies. However, each build currently waits 3+ minutes to install all dependencies.

Could Vercel support running turbo prune before installing dependencies? This would dramatically speed up builds by installing only necessary dependencies per app.

Is this possible with current configurations? If not, we believe this would greatly benefit teams using monorepos.

if you use a shared build cache it shouldn’t take more then a second or two to churn over and confirm the unchanged dependencies and then use the cached ones, this should solve your issue, you can also use --filter= to only target the needed project and it’s dependencies which will cut down the unused builds but does nothing to help you rebuilding the sub dependencies.

1 Like

Hi! Thanks for the reply, perhaps I was not so clear: by dependencies I mean’t npm dependencies, deps inside package.json.

For example if apps/web has a lot of dependencies such as react, next, tailwind, various plugins, lodash, moment.js, framer-motion, and and apps/docs has different dependencies like remix, vite, styled components, various plugins, underscore, gsasp, date-fns, and another app like apps/dashboard is using nuxt and vuejs… you can start to see the example I am trying to show.

So each app uses different npm dependencies, however when we go to build apps/web we need to install all dependencies of apps/doc even if they are not used. Our npm install script takes just over 2 minutes, although if we were to prune the package.json dependencies for apps/web this would be around 20s (from our estimation/tests).

are you not using a npm cache in your CI that should also fully resolve the issue

Sometimes restoring a cache takes longer than installing deps, so I don’t consider it solved for all steps. It’s about 1-3 minutes to restore ~/.npm then 1-2 minutes to run npm i worst case scenario.

Perhaps we are doing something incorrect, we are using circleci although also on Vercel speeds vary at different times although usually it’s about ~1min30s to get past npm install.

For some apps if we prune them and run npm i we don’t need to cache as the deps are so minimal it takes about 20s to install deps. That’s kind of the angle we are trying to take.