The bloat of edge-case first libraries
7 hours ago
- #javascript
- #dependencies
- #optimization
- Edge-case-first libraries often handle unlikely scenarios, leading to bloated dependency trees.
- Over-engineering for rare inputs (e.g., number-like strings in a clamp function) complicates code unnecessarily.
- Example libraries like 'is-number' and 'is-arrayish' solve edge cases but are often misused for common scenarios.
- Libraries should focus on common use cases and assume correct input types, leaving validation to the application level.
- Overly-granular libraries (e.g., 'shebang-regex') add unnecessary complexity and bloat.
- Tools like npmgraph and Dependabot help manage and optimize dependency trees.
- Validation should occur at data boundaries, not deep within dependency trees.
- The community is working on replacing bloated dependencies with modern, efficient alternatives.