Named exports used for tree-shaking
Why it matters
A package that only exports a single default namespace object forces bundlers to include the entire package in every consumer's bundle, regardless of which methods they actually use. ISO 25010 resource-utilization degrades linearly with how much dead code consumers are forced to carry. Tools like webpack, Rollup, and Vite perform tree-shaking on named exports but cannot eliminate unused properties of a default export object. For frontend consumers, this directly inflates page weight and Lighthouse scores.
Severity rationale
High because default-only exports defeat tree-shaking across all major bundlers, forcing consumers to ship your entire API surface even when they use one function.
Remediation
Replace or supplement a default namespace export with named exports from src/index.ts.
// Before — single default object, not tree-shakeable:
const sdk = { createClient: () => {}, parseResponse: () => {} }
export default sdk
// After — named exports, each independently shakeable:
export function createClient() {}
export function parseResponse() {}
export function formatError() {}
A default export alongside named exports is acceptable if the class or factory function is the natural primary API. The key requirement: import { specificFunction } from 'your-package' must work without importing the rest.
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 SDK / Package Quality 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 utilisation — tree-shaking reduces bundle size
- iso-25010:2011 · maintainability.modifiability — Modifiability — named exports make API surface explicit
Taxons
History
- 2026-04-18·v1.0.0·Initial import from sdk-package-quality·automated