pahen / madge

Create graphs from your CommonJS, AMD or ES6 module dependencies
MIT License
8.71k stars 312 forks source link

Feature request: topological sort for dependencies #398

Open danvk opened 5 months ago

danvk commented 5 months ago

If you're migrating a project from JavaScript to TypeScript, it's typically a good idea to work your way up from the leaves (modules with no dependencies). One way of codifying an order would be topological sort: print a list of modules where no module appears until all its dependencies have already appeared. This would give you the order in which to perform the migration.

This could probably be done as a post-processing step with madge --json, but it would be more convenient as part of the library.