farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
5.02k stars 166 forks source link

Optimize persistent cache strategy #1208

Open wre232114 opened 7 months ago

wre232114 commented 7 months ago

What problem does this feature solve?

Currently when lockfile is changed, all cache will be invalidated. For some dependencies like components, they could be changed frequently, so Farm need to support configuring that if some packages are changed, only caches of these packages are invalidated, caches of other packages should be reused.

What does the proposed API look like?

  1. add a loose: boolean, when keys like lockfile changed with loose: true, all cache should not be invalidated, and Farm should validate cache for immutable modules.
  2. optimize optimize_module_graph and render_resource_pot_modules cache. optimize_module_graph should be cached to skip unnecessary calculations. and cache of render_resource_pot_modules should considering used exports info of the modules.
  3. Config can be modified in rust plugins, farm should use final config to generate cache key for global keys.
  4. Optimize cache storage algorithm, there are thousands of modules generated under node_modules/.farm/cache, we needs to limit the storage usege
289420843 commented 7 months ago

有进展吗?我非常关心该功能

wre232114 commented 7 months ago

正在实现中,会优先支持

wre232114 commented 7 months ago

可设置 persistentCache: { globalBuiltinCacheKeyStrategy: { lockfile: false } } } 关闭 lockfile 的检查