statictrace

Node.js 14.15.0 以上が動作する環境。

Usage no npm install needed!

<script type="module">
  import statictrace from 'https://cdn.skypack.dev/statictrace';
</script>

README

statictrace

Requirements

Node.js 14.15.0 以上が動作する環境。

Usage

現在は、ソースからビルドする以外の使用方法がありません。

pnpm install
pnpm run build

Use as CLI

pnpm run build
pnpm run parse -- -p /absolute/path/to/tsconfig.json

ts-nodeの場合:

`pnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json`

.envファイルを作成し、TS_PROJECT_CONFIG環境変数を定義することで、-pオプションは省略できます。

その他のオプション

  • u, --use <printer> (optional): デフォルトの中からプリンターを選択する (textまたはmermaid).
TS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json

Use API programmatically

const { run } = require('./build/lib');
const output = run('/absolute/path/to/tsconfig.json');
// ...do something with output

run(pathToTsConfig: string, printer?: Printer): any

全てのプロジェクトのファイルをロードし、@entrypoint@traceでマークされている全ての関数のコールのグラフを作る。Printerは、グラフをプリント(なんらかの方法で表示できる)ことを表すインターフェースで、そのインターフェースを implement したものならなんでもオプショナルな引数として渡すことができます。何も渡さなかった場合は、解析の結果をTextPrinterが文字列として戻します。

interface Printer {
  print(graph: Into<Printable>): any;
}