Skip to content

Instantly share code, notes, and snippets.

@sverweij
Last active March 2, 2017 20:59
Show Gist options
  • Save sverweij/069a34c787982a7fea82d03d20a991f1 to your computer and use it in GitHub Desktop.
Save sverweij/069a34c787982a7fea82d03d20a991f1 to your computer and use it in GitHub Desktop.
Get dependencies of a typescript code base with dependency-cruiser

The recipe in previous revisions of this gist is obsolete as dependency-cruiser supports typescript (and coffeescript, livescript) out of the box since december 2016, so it's currently as simple as:

npm i --global dependency-cruiser

# ... assuming your source is in src, you can dump the dependencies 
# (including those in node_modules) to a file with:
depcruise -T json -f dependencies.json src

# or if you want to make a graph - send it through graphviz dot
depcruise -x node_modules -T dot src | dot -T svg > dependencygraph.svg

(Assuming TypeScript is installed --global as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment