2
其实我寻找类似-M
键gcc
但tsc
有什么办法可以获得项目的依赖关系图吗?
其实我寻找类似-M
键gcc
但tsc
有什么办法可以获得项目的依赖关系图吗?
Dependency cruiser可产生依赖性图:你已经通过它安装npm
后
:
npm install --save-dev dependency-cruiser
你应该首先运行:
node_modules/.bin/depcruise --info
为了确保,TypeScript支持起作用。
用命令
node_modules/.bin/depcruise --exclude "^node_modules" --output-type json <your_entry_point.ts> > dependencies.json
您可以创建一个包含您的打字稿文件之间的依赖关系的JSON文件。
如果您已经安装了dot
实用程序(在graphviz
包大多数Linux发行版可用)也一样,你可以这样做:
node_modules/.bin/depcruise --exclude "^node_modules" --output-type dot <your_entry_point.ts> | dot -T svg > dependency_graph.svg
生成依赖图作为SVG图像。
虽然此链接可能回答此问题,但最好在此处包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/18312553) – DarthJDG
我看到NPM模块typescript-dependency-util,但它已过时,最后更新3/4/15,无法在当前TS上工作。它可能可以作为如何创建依赖图生成器的一个例子。 – webjprgm