A Vite plugin that records a project's module import graph as a JSON file. Version 0.0.1 is the initial stable release. It focuses purely on data output without a visualization frontend, making it faster than integrated tools. It supports options like absolute/relative module IDs and prefixing virtual/npm modules. Output is a JSON object mapping module IDs to arrays of imported IDs, with npm package paths merged at the package level. The plugin is lightweight and designed for downstream use with visualization (D3.js, Graphviz) or analysis (circular dependencies, dead code, test impact).
npm install vite-plugin-import-graphVerified import paths — ran on the pinned version, not inferred.
Configure the plugin with default options to generate import graph JSON.
Specify an absolute path for `filename` if needed.
Use `absoluteModuleIds: true` with custom resolution if you need per-file granularity.
Enable `usePrefix` only if you need to distinguish virtual/npm modules.
Run `npm i -D vite-plugin-import-graph` and ensure Vite dev/build is executed in the same project.
Change to `import importGraph from 'vite-plugin-import-graph'`.
Upgrade Vite to ^5.0.0: `npm i vite@^5.0.0 -D`.