vite icon indicating copy to clipboard operation
vite copied to clipboard

Monorepo projects share a cache

Open Dunqing opened this issue 3 years ago • 4 comments

Description

When we have multiple vite projects in a monorepo project, I want them to use the same cache, meaning that they can reuse the existing cache when I set the cacheDir to the same path.

This can significantly increase the speed of "pre-bundling" when developing multiple projects at the same time.

Suggested solution

Use the same cacheDir , shared cache

Alternative

No response

Additional context

No response

Validations

Dunqing avatar Jul 14 '22 11:07 Dunqing

The cache currently contains metadata on per-project basis. I'm not sure sharing it is a good idea and might make the whole flow even complex and slower. Because we now need to know the entire monorepo dependencies in order to optimize them leading to slow startup, if we found dependencies dynamically the startup time will compound. And if we install a new dependency in one project, the whole cache needs to rebuild for other projects too.

bluwy avatar Jul 14 '22 14:07 bluwy

The cache currently contains metadata on per-project basis. I'm not sure sharing it is a good idea and might make the whole flow even complex and slower. Because we now need to know the entire monorepo dependencies in order to optimize them leading to slow startup, if we found dependencies dynamically the startup time will compound. And if we install a new dependency in one project, the whole cache needs to rebuild for other projects too.

I think we'll find a good strategy to make that happen

Dunqing avatar Jul 19 '22 15:07 Dunqing

@Dunqing do you mean you're willing to make a PR for the proposed feature?

bluwy avatar Jul 20 '22 10:07 bluwy

@Dunqing do you mean you're willing to make a PR for the proposed feature?

When I'm free I'm willing to give it a try

Dunqing avatar Jul 20 '22 10:07 Dunqing

Closing as I don't think this is possible without sacrificing startup/prebundling time. If there's a solution, feel free to send a PR directly. Thanks!

bluwy avatar Apr 01 '23 14:04 bluwy