circular dependencies scanner ⚡
[](https://npmjs.com/package/circular-dependency-scanner)
Out-of-box circular dependencies detector, with both JavaScript API and Command Line Tool built in, support all file types we used in common like .js,.jsx,.ts,.tsx,.mjs,.cjs,.vue.
Pull out import/require/export path from files and revert it into to real path (if aliased) with path alias configurations, then calculate the circles among and print which with colors.
English | 中文
Features
- 📦 All file types support.
- 🗑 Optional removal of pure TypeScript type references.
- 💡 Friendly Command Line Tool.
- 🛠️ Fully Typed JavaScript APIs and Prompts.
- 🌩 Tiny, Pretty, Fast and Reliable.
Example
Here the running example for the ds -o circles.json execution:
The ts,js,vue files will be printed directly into console as blue,yellow,green as follows if you didn't pass an output filename param:
Command Line Tool (Prefer)
The ds command which means depscan will be available after you installed this package globally.
pnpm i -g circular-dependency-scanner # or npm/yarn
cd path/to/execute # change directory
ds # run `ds` commandThere are detailed documentations built in, you can use -h option to print help information anytime.
ds [options] [path] # Automatically detect circular dependencies under the current directory and print the circles.Options
ds -h # print help info
ds -V/--version # print cli version
ds # current dir by default
ds src # detect src directory...and so on.
ds --filter 'src/router/*.ts' # only print the circles matched the pattern.
ds --absolute # print absolute path.
ds --ignore output dist node_modules # path to ignore.
ds --output circles.json # output analysis into specified file.
ds --throw # exit with code 1 when cycles're found.
ds --exclude-type # exclude pure type-references when calculating circles.