Ofri Peretz Posted on May 30 • Originally published at ofriperetz.dev Payload CMS Has 508 Circular Dependencies. Next.js Has 17. Here's Why They Form in Every Large JS Codebase. # javascript # typescript # node # webdev We ran madge (TypeScript-aware cycle detection, unlimited depth) across some of the most popular open-source JavaScript projects. Here is what we found: Project Stars Files analyzed Circular dependencies Payload CMS 33K 675 508 Next.js 131K 14,556 17 Medusa 27K 803 8 Strapi 65K 259 5 Twenty 25K — 0 ✅ Payload has 508 circular dependencies in 675 TypeScript files. That is not a typo. And nobody who works on Payload wrote a single line with the intention of creating a cycle. Every one of those 508 paths through the import graph was the result of incremental, individually reasonable decisions. This is how circular dependencies work. They accumulate silently. The build succeeds. The tests pass. The app ships. And somewhere in that import graph, modules are pulling in code they do not need, tests are loading the entire dependency tree, and a developer is staring at an undefined error that only happens during initialization and disappears the moment they add a console.log . Circular dependencies are the silent technical debt of every large JavaScript codebase. Here is why they form, what they quietly break, and how to find all of them. What a circular dependency actually is A circular dependency exists when module A imports from module B, which imports (directly or transitively) from module A. // user.service.ts import { formatUser } from ' ./user.utils ' ; // user.utils.ts import { UserService } from ' ./user.service ' ; // ← closes the loop Enter fullscreen mode Exit fullscreen mode Neither developer planned this. user.service.ts needed a formatter. user.utils.ts needed the service type for a helper function added three sprints later. Nobody saw the cycle form — they just saw two reasonable imports. This is how every circular dependency is born:
Back to Home

Payload CMS Has 508 Circular Dependencies. Next.js Has 17. Here's Why They Form in Every Large JS Codebase.
B
Blizine Admin
·2 min read·0 views
📰Dev.to — dev.to
B
Blizine Admin
View Profile Staff Writer