$30 off During Our Annual Pro Sale. View Details »

End of Barrel Files: New Modularization Techniq...

End of Barrel Files: New Modularization Techniques with Sheriff

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.

Rainer Hahnekamp

November 07, 2024
Tweet

More Decks by Rainer Hahnekamp

Other Decks in Technology

Transcript

  1. RainerHahnekamp The End of Barrel Files Rainer Hahnekamp ng-Poland 6.

    November 2024 New Modularization Techniques with Sheriff
  2. RainerHahnekamp About Me... https://www.ng-news.com https://github.com/softarc-consulting/sheriff • Rainer Hahnekamp ANGULARarchitects.io NgRx

    Team (Trusted Collaborator) • Developer / Trainer / Speaker @RainerHahnekamp Workshops NgRx • Testing • Spring • Quality
  3. RainerHahnekamp Agenda • Barrel Files as Module Boundaries ◦ Nx

    & Sheriff • Tree-Shaking & Barrel Files • Barrel-less Modules in Sheriff
  4. RainerHahnekamp Shared Forms Grid Error Handling Widgets Backend Middleware ...

    App Shell Domain (Holidays ) Domain (Customers) Domain (Bookings) Domain (Diary) Layer 1 - Domain modules
  5. RainerHahnekamp Before we end… • Hybrid Mode ◦ Modules as

    Folder ◦ Nx Libraries ◦ Sheriff for both Barrel-less and Barrel Modules (=Libraries) • Secondary Entry Points for Libraries ◦ Smaller, but multiple "Barrel Files" ◦ Angular Material as Example