Actually I'm looking for something like -M
key in gcc
but for tsc
Dependency cruiser can generate dependencies graphs:
First you have to install it via npm
:
npm install --save-dev dependency-cruiser
To make sure TypeScript support works you should first run:
node_modules/.bin/depcruise --info
You can create a JSON file containing the dependencies between your TypeScript files:
node_modules/.bin/depcruise --exclude "^node_modules" --output-type json [your_entry_point.ts] > dependencies.json
If you have installed the dot
utility included in graphviz
you can generate an SVG
node_modules/.bin/depcruise --exclude "^node_modules" --output-type dot [your_entry_point.ts] > dependencies.dot
dot dependencies.dot -T svg -o dependencies.svg
Dot support many other output formats and graphviz
is available as package of most Linux distributions and other operational systems as well
I created ts-dependency-graph, since dependency cruiser did never finish for my rather large project. It contains some options to handle large dependency graphs.
npm i ts_dependency_graph -g
ts_dependency_graph --start src/index.ts
Copy output e.g. to https://dreampuf.github.io/GraphvizOnline/
ts_dependency_graph --help
Options:
--help Show help [boolean]
--version Show version number [boolean]
--start the starting file, for the analysis [string]
--aggregate_by_folder, --agg create graph on folder level
[boolean] [default: false]
--max_depth [number] [default: 1000]
--filter filters files containing the provided strings
[array] [default: []]
--verbose, -v prints information about ignored files
[boolean] [default: false]
--hotspots, -h identify hotspots, by analyzing number of
incoming and outgoing edges
[boolean] [default: false]
--base_path calculates path relatives to the base path
[string] [default: "/currentpath"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With