Create import graphs with Graphviz.
The easiest way to use it is npx
:
npx @jamen/import-graph src/**.js | dot -T svg > imports.svg
The command takes file paths and outputs DOT.
The folloing options may be supplied:
-i
,--ignore <pattern>
: Omit files that match the pattern. Defaults to defaults tonode_modules
and.git
.-f
,--from <directory>
: Change where paths in labels are relative from. Defaults to cwd.-o
,--output <file>
: Outputs to a file instead of stdout.
This tool uses regex patterns to build the graph, making it easy to support many languages with different import syntax, without parsing every language.
The files it supports by default are:
- JavaScript ESM & Commonjs
- TypeScript
- package.json (i.e.
main
andbin
fields) - CSS
- SCSS/SASS
- Less.js
- Stylus