[Feature] Add option to output not the "imports" file tree, but "is-imported-by"

#52 · closed · 2 comments

View on GitHub ↗

ptandler

**Is your feature request related to a problem? Please describe.** To analyze the application architecture, I need to know which modules are *used* by which other modules. **Describe the solution you'd like** Add option to output the reverted import tree. Ideally, I'd like to specify the files I like to see the output dependencies on the command line and additionally pass the application root file where to start analysis. **Describe alternatives you've considered** Do this manually somehow :grimacing:

Comments

acrazing

You can try to write a custom script to process it. `dpdm` provided an util function called `parseDependents` at https://github.com/acrazing/dpdm/blob/master/src/utils.ts#L164. You can use it directly after `parseDependencyTree`. For example: ```ts #!/usr/bin/env node import { parseDependencyTree, parseDependents } from 'dpdm'; parseDependencyTree('index.ts', {}).then((tree) => { const importedByTree = parseDependents(tree); console.log(importedByTree); }); ```

ptandler

Thanks, this works well :)