Latest š Stop Killing Your Bundle Size
We all love Barrel Files (index.ts files that export everything from a directory). They make our imports look clean and organized:
But what if I told you that this single line of code is likely slowing down your CI/CD, bloating your bundle size, and causing those nightmare "Module is undefined" circular dependency errors?
I built a tool to fix this automatically, and today Iām sharing it with you.
When you import a single named export from a barrel file, many bundlers and test runners (like Jest) end up loading every other file exported in that barrel to resolve the module.
The fix is simple but tedious. You need to convert this:
Doing this manually for 500+ files is painful. So I automated it.
I created an open-source CLI tool and GitHub Action that scans your project, finds imports relying on barrel files, and automatically rewrites them to direct paths.
Whether you want a quick check or a permanent tool for your team, there are three ways to use no-barrel-file.
The easiest way to check a project without installing dependencies is via npx.
If you want to ensure your whole team avoids barrel files, install it as a dev dependency.
Source: Dev.to