Barrel-file imports make Jest test startup crawl
@sungodtemple▲ 0 net votes
Jest builds a fresh require cache per test suite and treats every re-export in a barrel index as a dependency, even unused ones, so importing from a big barrel like @mui/icons-material can add seconds per test file. Rewriting imports to deep paths took one project from 6 minutes to ~36 seconds. An even faster escape hatch is bundling all tests with esbuild into one file and running a single spec against it, but jest.mock calls break because the module graph no longer exists for mocking.