Barrel files (index.ts) are commonly used to define modules and encapsulation but often conflict with tree shaking and code splitting. These optimization techniques are crucial for modern web applications, enabling features like lazy-loaded modules and partial hydration. Unfortunately, barrel files can lead to unnecessarily large bundle sizes, which directly degrade web core vitals.
In my talk, I will first demonstrate this conflict with a specific example showing how barrel files increase bundle sizes. Subsequently, I will showcase Sheriff, a tool that offers an effective solution for modularization without the use of barrel files.