rev-dep 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/Readme.md +227 -101
  2. package/bin.js +3 -1
  3. package/package.json +26 -23
package/Readme.md CHANGED
@@ -1,17 +1,18 @@
1
1
  <p align="center">
2
- <img src="https://github.com/jayu/rev-dep/raw/master/logo.png" width="400">
2
+ <img src="https://github.com/jayu/rev-dep/raw/master/logo.png" width="400" alt="Rev-dep logo">
3
3
  </p>
4
+
4
5
  <p align="center">
5
- <a href="#about-">About</a>&nbsp;&nbsp;•&nbsp;&nbsp;
6
- <a href="#getting-started-">Getting Started</a>&nbsp;&nbsp;•&nbsp;&nbsp;
7
- <a href="#recipes-️">Recipes</a>&nbsp;&nbsp;•&nbsp;&nbsp;
8
- <a href="#cli-reference-">CLI Reference</a>
6
+ <a href="#key-features-">Key Features</a>&nbsp;&nbsp;•&nbsp;&nbsp;
7
+ <a href="#installation-">Installation</a>&nbsp;&nbsp;•&nbsp;&nbsp;
8
+ <a href="#practical-examples-">Practical Examples</a>&nbsp;&nbsp;•&nbsp;&nbsp;
9
+ <a href="#cli-reference-">CLI Reference</a>
9
10
  </p>
10
11
 
11
12
  <p align="center">
12
- Dependency analysis and optimization toolkit for modern TypeScript projects.
13
+ Dependency analysis and optimization toolkit for modern JavaScript and TypeScript projects.
13
14
  <br>
14
- <a href="#reimplemented-to-achieve-7x-37x-speedup">Completely rewritten in Go for maximum speed and efficiency ⚡</a>
15
+ Trace imports, find unused code, clean dependencies all from a blazing-fast CLI.
15
16
  </p>
16
17
 
17
18
  ---
@@ -19,150 +20,196 @@
19
20
  <img alt="rev-dep version" src="https://img.shields.io/npm/v/rev-dep"> <img alt="rev-dep license" src="https://img.shields.io/npm/l/rev-dep"> <img alt="rev-dep PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square">
20
21
 
21
22
 
22
- ## About 📣
23
-
24
- The tool was created to help with daily development struggles by answering these questions:
25
23
 
26
- 👉 What entry points does my codebase have?
24
+ # **About 📣**
27
25
 
28
- 👉 Which entry points use a given file?
26
+ Working in large JS/TS projects makes it difficult to answer simple but crucial questions:
29
27
 
30
- 👉 Which dependencies does a given file have?
28
+ * Which files depend on this file?
29
+ * Is this file even used?
30
+ * Which files does this entry point import?
31
+ * Do I have circular dependencies?
32
+ * Which packages in node_modules are unused?
33
+ * Which modules take the most disk space?
31
34
 
32
- 👉 Do any circular dependencies exist in the project?
35
+ Rev-dep helps you understand the real structure of your codebase so you can debug issues faster, refactor safely, and keep your dependencies clean.
33
36
 
34
- 👉 Which node modules are unused or not listed in package.json?
37
+ It's particularly useful for JavaScript projects without TypeScript or test coverage places where answering question "What will break if I change this" is not straightforward
35
38
 
36
- 👉 Which node modules take up the most space on disk?
37
39
 
40
+ ## **Why Rev-dep? 🤔**
38
41
 
39
- This helps to debug project dependencies, plan refactoring, optimize bundles or plan code splitting.
42
+ Rev-dep is designed for **fast iteration** and **minimal, actionable results** no noise, just answers.
40
43
 
41
- It's especially useful in JS world without TypeScript or tests coverage.
44
+ ### **Results in milliseconds**
42
45
 
43
- It also helps to identify and eliminate dead files, understand the complexity of the file dependencies
46
+ Built in Go for speed. Even on large codebases, rev-dep responds almost instantly.
44
47
 
45
- [🦘 Jump to CLI reference](#cli-reference-)
48
+ ### **Actionable, list-based output**
46
49
 
47
- ### Use cases 🧑‍💻
50
+ You get **exact file paths**, **import chains**, and **clear dependency relationships** — the kind of information you can fix or clean up right away.
48
51
 
49
- - [You plan to refactor some file and you wonder which entry points are affected](#how-to-identify-where-a-file-is-used-in-the-project)
50
- - [You are wondering wether a given source file is used](#how-to-check-if-a-file-is-used-in-the-project)
51
- - [You wonder if there are any dead files in your project](#how-to-identify-dead-files-in-the-project)
52
- - [You want to verify if a given entry point imports only the required files](#how-to-check-which-files-are-imported-by-a-given-file)
53
- - [You want to optimize the amount of files imported by an entry point](#how-to-reduce-amount-of-files-imported-by-entry-point)
54
- - [You want to detect circular dependencies in your project](#how-to-detect-circular-dependencies-in-the-project)
55
- - [You want to find unused node modules to clean up dependencies](#how-to-find-unused-node-modules)
56
- - [You want to identify which node modules are consuming the most disk space](#how-to-identify-space-consuming-node-modules)
52
+ ### **Designed for real-world JS/TS**
57
53
 
58
- ### How about dependency or bundle graphs?
54
+ Works with mixed JS/TS projects, path aliases and thousands of files without configuration hassles.
59
55
 
60
- There are tool that can output nice, visual representation of project dependencies like [webpack-bundle-analyzer](https://www.npmjs.com/package/webpack-bundle-analyzer) or [dependency-cruiser](https://www.npmjs.com/package/dependency-cruiser) (_which btw rev-dep uses for non-TS codebases_)
56
+ ### **Deep analysis, one CLI**
61
57
 
62
- While graphs can be useful to identify major problems like too big bundle size or to visualize mess in your deps, it's hard to take any action based on them (_at least it was hard for me_ 🤷‍♂️)
58
+ Unused files, unused or missing dependencies, reverse-imports, entry point detection, node_modules insights, dependency paths everything in one tool.
63
59
 
64
- `rev-dep` visualize dependencies as lists, so it's really easy to see where to cut the line to solve the problem.
65
60
 
66
- ## Getting Started 🎉
61
+ ### **Much faster than alternatives**
67
62
 
68
- ### Install globally to use as CLI tool
63
+ Rev-dep outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
69
64
 
70
- `yarn global add rev-dep`
65
+ For large project with 500k+ lines of code and 6k+ source code files get checks as fast as:
71
66
 
72
- `npm -g install rev-dep`
67
+ | Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep |
68
+ |------|-------|--------------|------|----|
69
+ | Find circular dependencies | 289 | dpdm-fast | 7061| 24x|
70
+ | Find unused files | 588 | knip | 6346 | 11x |
71
+ | Find unused node modules | 594 | knip | 6230 | 10x |
72
+ | Find missing node modules | 553 | knip| 6226 | 11x |
73
+ | List all files imported by an entry point | 229 | madge | 4467 | 20x |
74
+ | Discover entry points | 323 | madge | 67000 | 207x
75
+ | Resolve dependency path between files | 228 | please suggest |
76
+ | Count lines of code | 342 | please suggest |
77
+ | Check node_modules disk usage | 1619 | please suggest |
78
+ | Analyze node_modules directory sizes | 521 | please suggest |
73
79
 
74
- `pnpm global add rev-dep`
80
+ >Benchmark run on WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU @ 2.80GHz
75
81
 
76
- ## Recipes 🌶️
82
+ # **Key Features 🚀**
77
83
 
78
- ### How to identify where a file is used in the project?
84
+ * 🔍 **Reverse dependency lookup** see all entry points that require a given file
85
+ * 🗂️ **Entry point discovery**
86
+ * 🧹 **Dead file detection**
87
+ * 📦 **Unused / missing / used node modules / dependencies analysis**
88
+ * 🔄 **Circular imports/dependencies detection**
89
+ * 🧭 **Trace all import paths between files**
90
+ * 📁 **List all files imported by any entry point**
91
+ * 📏 **Count actual lines of code (excluding comments and blanks)**
92
+ * 💽 **Node modules disk usage & size analysis**
93
+ * 💡 **Works with both JavaScript and TypeScript**
94
+ * ⚡ **Built for large codebases**
79
95
 
80
- Just use `rev-dep resolve --file path/to/file.ts`
96
+ # **Installation 📦**
81
97
 
82
- You will see all the entry points that implicitly require given file together with resolution path.
98
+ Install globally to use as a CLI tool:
83
99
 
84
- [`resolve` Command CLI reference](#rev-dep-resolve)
100
+ ```
101
+ yarn global add rev-dep
102
+ ```
85
103
 
86
- #### Getting more details about file resolution in given entry point
104
+ ```
105
+ npm install -g rev-dep
106
+ ```
87
107
 
88
- To find out all paths combination use `rev-dep resolve` with `-a` flag
108
+ ```
109
+ pnpm global add rev-dep
110
+ ```
89
111
 
90
- > You might be surprised how complex dependency tree can be!
91
112
 
92
- </details>
113
+ # **Quick Examples ⚡**
93
114
 
94
- ### How to check if a file is used in the project?
115
+ A few instant-use examples to get a feel for the tool:
95
116
 
96
- Use `rev-dep resolve --file path/to/file.ts --compact-summary`
117
+ ```bash
118
+ # Detect unused node modules
119
+ rev-dep node-modules unused
97
120
 
98
- As a result you will see total amount of entry points requiring a given file.
121
+ # Detect circular imports/dependencies
122
+ rev-dep circular
99
123
 
100
- > Note that among the entry points list there might be some dead files importing the searched file
124
+ # List all entry points in the project
125
+ rev-dep entry-points
101
126
 
102
- [`resolve` Command CLI reference](#rev-dep-resolve)
127
+ # Check which files an entry point imports
128
+ rev-dep files --entry-point src/index.ts
103
129
 
104
- ### How to identify dead files in the project?
130
+ # Find every entry point that depends on a file
131
+ rev-dep resolve --file src/utils/math.ts
105
132
 
106
- Use `rev-dep entry-points` to get list of all files that are not required by any other files in the project.
133
+ # Resolve dependency path between files
134
+ rev-dep resolve --file src/utils/math.ts --entry-point src/index.ts
107
135
 
108
- You might want to exclude some file paths that are meant to be actual entry point like `index.js` or `**/pages/**` in `next.js` projects using `--result-exclude` flag. The same for configuration files like `babel.config.js`
136
+ ```
109
137
 
110
- Review the list and look for suspicious files like `src/ui/components/SomeComponent/index.js`
138
+ # **Practical Examples 🔧**
111
139
 
112
- [`entry-points` command CLI reference](#rev-dep-entry-points)
113
140
 
114
- ### How to check which files are imported by a given file?
141
+ Practical examples show how to use rev-dep commands to build code quality checks for your project.
115
142
 
116
- To get a full list of files imported by given entry point use `rev-dep files --entry-point path/to/file.ts`.
143
+ ### **How to identify where a file is used in the project**
117
144
 
118
- You can use `--count` flag if you are interested in the amount.
145
+ ```
146
+ rev-dep resolve --file path/to/file.ts
147
+ ```
119
148
 
120
- This is a good indicator of how heavy a given entry point or component is
149
+ You’ll see all entry points that implicitly require that file, along with resolution paths.
121
150
 
122
- [`files` command CLI reference](#rev-dep-files)
151
+ ### **How to check if a file is used**
123
152
 
124
- ### How to reduce amount of files imported by entry point?
153
+ ```
154
+ rev-dep resolve --file path/to/file.ts --compact-summary
155
+ ```
125
156
 
126
- There is no easy how to for this process, but you can do it iteratively using `rev-dep` commands `files` and `resolve`
157
+ Shows how many entry points indirectly depend on the file.
127
158
 
128
- 1. Get the list of files imported by entry-point
159
+ ### **How to identify dead files**
129
160
 
130
- `rev-dep files --entry-point path/to/entry-point`
161
+ ```
162
+ rev-dep entry-points
163
+ ```
131
164
 
132
- 2. Identify some suspicious files on the list, components that should not be used on the given page or not related utility files
133
- 3. Get all resolution paths for a suspicious file
165
+ Exclude framework entry points if needed using `--result-exclude`.
134
166
 
135
- `rev-dep resolve --file path/to/suspicious-file --entry-points path/to/entry-point --all`
167
+ ### **How to list all files imported by an entry point**
136
168
 
137
- 4. You would usually find out that there is some file, like directory `index` file that given entry point is using, which is mandatory, but as a side effect it imports a few files that are redundant for your entry point. In most cases you should be able to decouple the imports or reverse the dependency to cut off the resolution path for the unwanted file
169
+ ```
170
+ rev-dep files --entry-point path/to/file.ts
171
+ ```
138
172
 
139
- ### How to detect circular dependencies in the project?
173
+ Useful for identifying heavy components or unintended dependencies.
140
174
 
141
- Use `rev-dep circular` to find all circular dependencies between modules in your project.
175
+ ### **How to reduce unnecessary imports for an entry point**
142
176
 
143
- Circular dependencies can cause runtime errors, memory leaks, and make code difficult to understand and maintain. It's important to identify and resolve them early.
177
+ 1. List all files imported:
144
178
 
145
- You can use `--ignore-type-imports` flag to exclude type-only imports from the analysis if they're not relevant to your use case.
179
+ ```
180
+ rev-dep files --entry-point path/to/entry.ts
181
+ ```
182
+ 2. Identify suspicious files.
183
+ 3. Trace why they are included:
146
184
 
147
- [`circular` command CLI reference](#rev-dep-circular)
185
+ ```
186
+ rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
187
+ ```
148
188
 
149
- ### How to find unused node modules?
189
+ ### **How to detect circular dependencies**
150
190
 
151
- Use `rev-dep node-modules unused` to identify packages that are installed but not actually imported in your code.
191
+ ```
192
+ rev-dep circular
193
+ ```
152
194
 
153
- This helps clean up your `package.json` and reduce the size of your `node_modules` directory. You might want to exclude type definitions using `--exclude-modules=@types/*` since they're often used indirectly.
195
+ ### **How to find unused node modules**
154
196
 
155
- [`node-modules unused` command CLI reference](#rev-dep-node-modules-unused)
197
+ ```
198
+ rev-dep node-modules unused
199
+ ```
156
200
 
157
- ### How to identify space-consuming node modules?
201
+ ### **How to find missing node modules**
158
202
 
159
- Use `rev-dep node-modules dirs-size` to calculate and display the size of `node_modules` directories.
203
+ ```
204
+ rev-dep node-modules missing
205
+ ```
160
206
 
161
- This helps identify which packages are taking up the most disk space, allowing you to make informed decisions about dependency management or look for lighter alternatives.
207
+ ### **How to check node_modules space usage**
162
208
 
163
- For detailed analysis of specific modules, use `rev-dep node-modules analyze-size` with the package names you want to investigate.
209
+ ```
210
+ rev-dep node-modules dirs-size
211
+ ```
164
212
 
165
- [`node-modules dirs-size` command CLI reference](#rev-dep-node-modules-dirs-size)
166
213
 
167
214
  ## Reimplemented to achieve 7x-37x speedup
168
215
 
@@ -177,7 +224,7 @@ Benchmark was run on TypeScript codebase with 507658 lines of code and 5977 sour
177
224
 
178
225
  Memory usage on Mac was measure using `/usr/bin/time` utility. Memory usage on Linux was not measured because I could't find reliable way to measure RAM usage on Linux. Subsequent runs had too much fluctuation.
179
226
 
180
- ### Mac book Pro M1 256GB, power save off;
227
+ ### MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of storage. Power save mode off
181
228
 
182
229
  | Command | V1 Time | V2 Time | Time Change | V1 RAM | V2 RAM | RAM Change |
183
230
  | ------------------------------------------------------------ | ------- | ------- | ----------- | ------ | ------ | ---------- |
@@ -273,9 +320,9 @@ Any other discrepancies between TypeScript module resolution and rev-dep should
273
320
 
274
321
  - Linux x64
275
322
  - MacOS Apple Silicon
323
+ - Windows x64
276
324
 
277
- There are the platforms I use and know. For these I build and tested binaries.
278
- Go allows for cross-compiling, so I'm happy to build and distribute binaries for other platforms as well, but I haven't tested it.
325
+ Go allows for cross-compiling, so I'm happy to build and distribute binaries for other platforms as well.
279
326
  Feel free to open an issue if you need support for another platform.
280
327
 
281
328
  ## CLI reference 📖
@@ -307,8 +354,8 @@ rev-dep circular --ignore-types-imports
307
354
  -c, --cwd string Working directory for the command (default "$PWD")
308
355
  -h, --help help for circular
309
356
  -t, --ignore-type-imports Exclude type imports from the analysis
310
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
311
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
357
+ --package-json string Path to package.json (default: ./package.json)
358
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
312
359
  ```
313
360
 
314
361
 
@@ -339,11 +386,11 @@ rev-dep entry-points --print-deps-count
339
386
  --graph-exclude strings Exclude files matching these glob patterns from analysis
340
387
  -h, --help help for entry-points
341
388
  -t, --ignore-type-imports Exclude type imports from the analysis
342
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
389
+ --package-json string Path to package.json (default: ./package.json)
343
390
  --print-deps-count Show the number of dependencies for each entry point
344
391
  --result-exclude strings Exclude files matching these glob patterns from results
345
392
  --result-include strings Only include files matching these glob patterns in results
346
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
393
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
347
394
  ```
348
395
 
349
396
 
@@ -374,8 +421,8 @@ rev-dep files --entry-point src/index.ts
374
421
  -p, --entry-point string Entry point file to analyze (required)
375
422
  -h, --help help for files
376
423
  -t, --ignore-type-imports Exclude type imports from the analysis
377
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
378
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
424
+ --package-json string Path to package.json (default: ./package.json)
425
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
379
426
  ```
380
427
 
381
428
 
@@ -575,9 +622,9 @@ rev-dep node-modules missing --entry-points=src/main.ts
575
622
  -h, --help help for missing
576
623
  -t, --ignore-type-imports Exclude type imports from the analysis
577
624
  -i, --include-modules strings list of modules to include in the output
578
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
625
+ --package-json string Path to package.json (default: ./package.json)
579
626
  --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
580
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
627
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
581
628
  --zero-exit-code Use this flag to always return zero exit code
582
629
  ```
583
630
 
@@ -613,9 +660,9 @@ rev-dep node-modules unused --exclude-modules=@types/*
613
660
  -h, --help help for unused
614
661
  -t, --ignore-type-imports Exclude type imports from the analysis
615
662
  -i, --include-modules strings list of modules to include in the output
616
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
663
+ --package-json string Path to package.json (default: ./package.json)
617
664
  --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
618
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
665
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
619
666
  --zero-exit-code Use this flag to always return zero exit code
620
667
  ```
621
668
 
@@ -653,9 +700,9 @@ rev-dep node-modules used -p src/index.ts --group-by-module
653
700
  -h, --help help for used
654
701
  -t, --ignore-type-imports Exclude type imports from the analysis
655
702
  -i, --include-modules strings list of modules to include in the output
656
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
703
+ --package-json string Path to package.json (default: ./package.json)
657
704
  --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
658
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
705
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
659
706
  ```
660
707
 
661
708
 
@@ -689,14 +736,93 @@ rev-dep resolve -p src/index.ts -f src/utils/helpers.ts
689
736
  --graph-exclude strings Glob patterns to exclude files from dependency analysis
690
737
  -h, --help help for resolve
691
738
  -t, --ignore-type-imports Exclude type imports from the analysis
692
- --package-json string Path to package.json (default: ./package.json) (default "package.json")
693
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json) (default "tsconfig.json")
739
+ --package-json string Path to package.json (default: ./package.json)
740
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
694
741
  ```
695
742
 
696
743
 
697
744
 
698
745
  <!-- cli-docs-end -->
699
746
 
747
+ ## Circular check performance comparison
748
+
749
+ Benchmark performed on TypeScript codebase with `6034` source code files and `518862` lines of code.
750
+
751
+ Benchmark performed on MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of Storage. Power save mode off.
752
+
753
+ Benchmark performed with `hyperfine` using 8 runs per test and 4 warm up runs, taking mean time values as a result. If single run was taking more than 10s, only 1 run was performed.
754
+
755
+ `rev-dep` circular check is **12 times** faster than the fastest alternative❗
756
+
757
+ | Tool | Version | Command to Run Circular Check | Time |
758
+ |------|---------|-------------------------------|------|
759
+ | 🥇 [rev-dep](https://github.com/jayu/rev-dep) | 2.0.0 | `rev-dep circular` | 397 ms |
760
+ | 🥈 [dpdm-fast](https://github.com/SunSince90/dpdm-fast) | 1.0.14 | `dpdm --no-tree --no-progress --no-warning` + list of directories with source code | 4960 ms |
761
+ | 🥉 [dpdm](https://github.com/acrazing/dpdm) | 3.14.0 | `dpdm --no-warning` + list of directories with source code | 5030 ms |
762
+ | [skott](https://github.com/antoine-coulon/skott) | 0.35.6 | node skoscript using `findCircularDependencies` function | 29575 ms |
763
+ | [madge](https://github.com/pahen/madge) | 8.0.0 | `madge --circular --extensions js,ts,jsx,tsx .` | 69328 ms |
764
+ | [circular-dependency-scanner](https://github.com/emosheeep/circular-dependency-scanner) | 2.3.0 | `ds` - out of memory error | n/a |
765
+
766
+ ## Glossary
767
+
768
+ Some of the terms used in the problem space that **rev-dep** covers can be confusing.
769
+ Here is a small glossary to help you navigate the concepts.
770
+
771
+ ### Dependency
772
+
773
+ A *dependency* can be understood literally. In the context of a project’s dependency graph, it may refer to:
774
+
775
+ * a **node module / package** (a package is a dependency of a project or file), or
776
+ * a **source code file** (a file is a dependency of another file if it imports it).
777
+
778
+ ### Entry point
779
+
780
+ An *entry point* is a source file that is **not imported by any other file**.
781
+ It can represent:
782
+
783
+ * the main entry of the application
784
+ * an individual page or feature
785
+ * configuration or test bootstrap files
786
+
787
+ — depending on the project structure.
788
+
789
+ ### Unused / Dead file
790
+
791
+ A file is considered *unused* or *dead* when:
792
+
793
+ * it is an **entry point** (nothing imports it), **and**
794
+ * running it does **not produce any meaningful output** or side effect.
795
+
796
+ In practice, such files can often be removed safely.
797
+
798
+ ### Circular dependency
799
+
800
+ A *circular dependency* occurs when a file **directly or indirectly imports itself** through a chain of imports.
801
+
802
+ This can lead to unpredictable runtime behavior, uninitialized values, or subtle bugs.
803
+ However, circular dependencies between **TypeScript type-only imports** are usually harmless.
804
+
805
+ ### Reverse dependency (or "dependents")
806
+
807
+ Files that *import* a given file.
808
+ Useful for answering: "What breaks if I change or delete this file?"
809
+
810
+ ### Import graph / Dependency graph
811
+
812
+ A visual representation of how files or modules import each other.
813
+
814
+ ### Missing dependency / unused node module
815
+
816
+ A module that your code imports but is **not listed in package.json**.
817
+
818
+ ### Unused dependency / unused node module
819
+
820
+ A dependency listed in **package.json** that is **never imported** in the source code.
821
+
822
+ ### Root directory / Project root
823
+
824
+ The top-level directory used as the starting point for dependency analysis.
825
+
700
826
  ## Made in 🇵🇱 and 🇯🇵 with 🧠 by [@jayu](https://github.com/jayu)
701
827
 
702
828
  I hope that this small piece of software will help you discover and understood complexity of your project hence make you more confident while refactoring. If this tool was useful, don't hesitate to give it a ⭐!
package/bin.js CHANGED
@@ -11,6 +11,7 @@ const nestedNodeModulesPath = path.join(__dirname, 'node_modules', binaryPackage
11
11
  const siblingNodeModulesPath = path.join(__dirname, '../', binaryPackageName)
12
12
 
13
13
  const checkedPaths = []
14
+ const fsRoot = path.parse(__dirname).root
14
15
 
15
16
  if (fs.existsSync(nestedNodeModulesPath)) {
16
17
  packageDir = nestedNodeModulesPath
@@ -27,7 +28,7 @@ else if (fs.existsSync(siblingNodeModulesPath)) {
27
28
  }
28
29
  else {
29
30
  checkedPaths.push(pathToCheck)
30
- if (lookupDir === '/') {
31
+ if (lookupDir === fsRoot) {
31
32
  lookupDir = undefined
32
33
  }
33
34
  else {
@@ -41,6 +42,7 @@ if (packageDir === '') {
41
42
  console.error("Could not locate rev-dep binary for your platform: ", binaryPackageName)
42
43
  console.log('Checked paths', checkedPaths)
43
44
  console.log('Please open an issue to request platform support')
45
+ console.log('https://github.com/jayu/rev-dep/issues')
44
46
  process.exit(1)
45
47
  }
46
48
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rev-dep",
3
- "version": "2.0.0",
4
- "description": "Dependency debugging tool for JavaScript and TypeScript projects",
3
+ "version": "2.2.0",
4
+ "description": "Trace imports, detect unused code, clean dependencies — all with a super-fast CLI",
5
5
  "bin": "bin.js",
6
6
  "files": [
7
7
  "bin.js"
@@ -17,28 +17,31 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "optionalDependencies": {
20
- "@rev-dep/darwin-arm64": "2.0.0",
21
- "@rev-dep/linux-x64": "2.0.0"
20
+ "@rev-dep/darwin-arm64": "2.2.0",
21
+ "@rev-dep/linux-x64": "2.2.0",
22
+ "@rev-dep/win32-x64": "2.2.0"
22
23
  },
23
24
  "keywords": [
24
- "dependencies",
25
- "deps",
26
- "dependency graph",
27
- "dependency debugging",
28
- "entry points",
29
- "dependency resolution",
30
- "reverse dependency resolution",
31
- "import path",
32
- "resolution path",
33
- "dependency optimization",
34
- "dependency analysis",
35
- "bundle",
36
- "dependency tree",
37
- "imports",
38
- "dependencies checking",
39
- "imports debugging",
40
- "imports analysis",
41
- "imports search",
42
- "file dependencies"
25
+ "dependency-analysis",
26
+ "reverse-dependencies",
27
+ "dependency-resolution",
28
+ "file-dependencies",
29
+ "unused-files",
30
+ "dead-files",
31
+ "unused-dependencies",
32
+ "missing-dependencies",
33
+ "used-dependencies",
34
+ "module-analysis",
35
+ "import-analysis",
36
+ "entry-point-analysis",
37
+ "dependency-path",
38
+ "circular-dependency-detection",
39
+ "node-modules-analysis",
40
+ "module-size-analysis",
41
+ "lines-of-code",
42
+ "project-audit",
43
+ "typescript-analysis",
44
+ "javascript-analysis",
45
+ "monorepo-analysis"
43
46
  ]
44
47
  }