HeadlinesBriefing favicon HeadlinesBriefing.com

Tackling JavaScript Dependency Bloat: Three Core Causes

Hacker News •
×

Over the past two years the e18e community has driven a “cleanup” push that prunes redundant, outdated npm packages. A frequent complaint is dependency bloat: trees swell with tiny modules that duplicate native functionality. The author groups the problem into three pillars—legacy runtime support, overly atomic architecture, and supply‑chain surface area—each adding weight to everyday projects.

First pillar covers legacy environments. Some developers still target ES3 browsers or ancient Node versions, forcing packages like is‑string or hasown to polyfill missing features such as Array.prototype.forEach. Node also shields itself with “primordials” to prevent global mutation, spawning utilities that re‑export Math functions. Cross‑realm checks, needed when code runs in iframes, further justify tiny wrappers that otherwise duplicate native APIs.

Second pillar critiques the atomic package trend. Developers break even simple one‑liners—e.g., arrify or onetime—into separate modules, inflating the dependency graph. Many of these packages have a single consumer, leading to duplicated versions across projects and expanding the supply‑chain attack surface; a recent compromise of a maintainer’s account affected hundreds of such tiny modules. Inlining trivial code cuts install time, bandwidth, and security risk.