dpdm is a robust static dependency analyzer designed for JavaScript and TypeScript projects. It efficiently identifies circular dependencies, detects unused files, and generates comprehensive dependency trees. Currently at stable version 4.0.1, the library maintains a relatively frequent release cadence, often aligning minor versions with updates to TypeScript and Node.js to ensure compatibility with modern language features. Key differentiators include its complete support for both CommonJS and ESM module systems, comprehensive TypeScript features such as path mapping resolution and the ability to ignore type-only dependencies, and a lightweight architecture that leverages the official TypeScript compiler for parsing. It aims to provide stable and consistent output, addressing inconsistencies found in alternative tools like `madge` when analyzing complex TypeScript projects.
npm install dpdmVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `dpdm` programmatically to analyze a project for circular dependencies and unused files, showing basic configuration and result handling.
Upgrade your Node.js runtime environment to version 20 or newer. Use `nvm` or `volta` to manage Node.js versions if needed.
Ensure that your project's TypeScript version is compatible with the dpdm version you are using. Check dpdm's release notes for the supported TypeScript version in each major/minor release.
Carefully choose between `circular` and `tree` values for `--skip-dynamic-imports` based on whether you want to exclude dynamic imports from only circularity checks or from the entire dependency graph analysis.
Always use `--exit-code circular:1` (or a similar pattern for other checks like unused files) in CI/CD environments to ensure that the build process fails if unwanted dependencies are detected.
Upgrade Node.js to version 20 or newer using `nvm install 20 && nvm use 20` or by updating your Node.js distribution.
Double-check the file paths and glob patterns specified in your dpdm command or API call. Ensure they are relative to the `--context` or `context` option, or are absolute paths.
Update dpdm to its latest version, or ensure your project's `tsconfig.json` `compilerOptions.target` and `moduleResolution` settings are standard and well-formed. Verify that the TypeScript version your project uses is compatible with the dpdm version's tested TS version.
Verify your `tsconfig.json` includes correct `compilerOptions.baseUrl` and `compilerOptions.paths` if you are using path aliases. Ensure `--extensions` (or `extensions` in API) includes all relevant file types for resolution (e.g., `.ts,.tsx,.js,.jsx`).