Build tool supports tree shaking (no barrel file issues)
Why it matters
Barrel files that re-export every module in a directory prevent the build tool from eliminating dead code — even when you only import one function, the bundler may include the entire barrel. A lib/index.ts that re-exports 50 utilities causes every importer to pull in all 50, regardless of usage. Without sideEffects: false in package.json, the bundler cannot safely drop any of those exports. On large codebases, this pattern adds tens to hundreds of kilobytes to the bundle that serve no user-visible function. ISO 25010 performance-efficiency.resource-utilization identifies this as avoidable resource inclusion.
Severity rationale
Low because tree-shaking issues rarely cause visible failures but silently add unnecessary payload, compounding with other bundle-size problems.
Remediation
Set sideEffects: false in package.json to signal the bundler that modules can be safely dropped when unused. Reduce or eliminate barrel files with more than 10 re-exports, replacing them with direct imports.
// package.json
{
"sideEffects": false
}
// Before — barrel file prevents tree shaking
// lib/index.ts
export * from './utils/date'
export * from './utils/string'
export * from './hooks/useCounter'
export * from './hooks/useDebounce'
export * from './components/Button'
// ...40 more
// After — import directly from the module
import { formatDate } from '@/lib/utils/date'
import { useCounter } from '@/lib/hooks/useCounter'
For monorepos, also set sideEffects: false in each package's package.json, not just the root.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Performance & Load Readiness Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.resource-utilization — Resource Utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from performance-load·automated