rev-dep 2.6.1 → 2.7.1

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 (2) hide show
  1. package/Readme.md +434 -416
  2. package/package.json +4 -4
package/Readme.md CHANGED
@@ -3,100 +3,115 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
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;
6
+ <a href="#capabilities-">Capabilities</a>&nbsp;&nbsp;•&nbsp;&nbsp;
7
+ <a href="#installation-">Installation</a>&nbsp;&nbsp;•&nbsp;&nbsp;
8
+ <a href="#exploratory-toolkit-">Exploratory Toolkit</a>&nbsp;&nbsp;•&nbsp;&nbsp;
9
9
  <a href="#cli-reference-">CLI Reference</a>
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- Dependency analysis and optimization toolkit for modern JavaScript and TypeScript projects.
13
+ Dependency analysis and optimization toolkit for modern JavaScript and TypeScript codebases.
14
14
  <br>
15
- Trace imports, identify circular dependencies, find unused code, clean node modules — all from a blazing-fast CLI.
15
+ Enforce dependency graph hygiene and remove unused bits with a very fast CLI.
16
+ </p>
17
+
18
+ <p align="center">
19
+ <img src="https://github.com/jayu/rev-dep/raw/master/demo.png" alt="Rev-dep config execution CLI output"width="400">
16
20
  </p>
17
21
 
18
22
  ---
19
23
 
20
24
  <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">
21
25
 
26
+ ## **About 📣**
22
27
 
28
+ As codebases scale, maintaining a mental map of dependencies becomes impossible. **Rev-dep** is a high-speed governance engine designed to enforce architecture integrity and dependency hygiene across large-scale JS/TS projects.
23
29
 
24
- # **About 📣**
30
+ <p align="center"><b>Think of Rev-dep as a high-speed linter for your dependency graph.</b></p>
25
31
 
26
- Working in large JS/TS projects makes it difficult to answer simple but crucial questions:
32
+ **Consolidate fragmented, sequential checks from multiple slow tools into a single, high-performance engine.** Rev-dep executes a full suite of governance checks—including circularity, orphans, module boundaries and more, in one parallelized pass. Implemented in **Go** to bypass the performance bottlenecks of Node-based analysis, it can audit a **500k+ LoC project in approximately 500ms**.
27
33
 
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?
34
+ ### **Automated Codebase Governance**
34
35
 
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.
36
+ Rev-dep moves beyond passive scanning to active enforcement, answering (and failing CI for) the hard questions:
36
37
 
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
38
+ * **Architecture Integrity:** "Is my 'Domain A' illegally importing from 'Domain B'?".
39
+ * **Dead Code & Bloat:** "Are these files unreachable, or are these `node_modules` unused?".
40
+ * **Refactoring Safety:** "Which entry points actually use this utility, and are there circular chains?".
41
+ * **Workspace Hygiene:** "Are my imports consistent and are all dependencies declared?".
38
42
 
43
+ Rev-dep serves as a **high-speed gatekeeper** for your CI, ensuring your dependency graph remains lean and your architecture stays intact as you iterate.
39
44
 
40
45
  ## **Why Rev-dep? 🤔**
41
46
 
42
- Rev-dep is designed for **fast iteration** and **minimal, actionable results** — no noise, just answers.
47
+ ### 🏗️ **First-class monorepo support**
48
+ Designed for modern workspaces (`pnpm`, `yarn`, `npm`). Rev-dep natively resolves `package.json` **exports/imports** maps, TypeScript aliases and traces dependencies across package boundaries.
43
49
 
44
- ### **Results in milliseconds**
50
+ ### 🛡️ **Config-Based Codebase Governance**
51
+ Move beyond passive scanning. Use the configuration engine to enforce **Module Boundaries** and **Import Conventions**. Execute a full suite of hygiene checks (circularity, orphans, unused modules and more) in a **single, parallelized pass** that serves as a high-speed gatekeeper for your CI.
45
52
 
46
- Built in Go for speed. Even on large codebases, rev-dep responds almost instantly.
53
+ ### 🔍 **Exploratory Toolkit**
54
+ CLI toolkit that helps debug issues with dependencies between files. Understand transitive relation between files and fix issues.
47
55
 
48
- ### **Actionable, list-based output**
56
+ ### **Built for Speed and CI Efficiency**
57
+ Implemented in **Go** to eliminate the performance tax of Node-based analysis. By processing files in parallel, Rev-dep offers **10x-200x faster execution** than alternatives, significantly **reducing CI costs** and developer wait-states.
49
58
 
50
- You get **exact file paths**, **import chains**, and **clear dependency relationships** — the kind of information you can fix or clean up right away.
59
+ > **Rev-dep can audit a 500k+ LoC project in around 500ms.**
60
+ > [See the performance comparison](#performance-comparison-)
51
61
 
52
- ### **Designed for real-world JS/TS with first class monorepo support**
62
+ ## Capabilities 🚀
53
63
 
54
- Works with mixed JS/TS projects, path aliases and thousands of files without configuration hassles.
64
+ ## Governance and maintenance (config-based) 🛡️
55
65
 
56
- ### **Deep analysis, one CLI**
66
+ Use `rev-dep config run` to execute multiple checks in one pass for all packages.
57
67
 
58
- Unused files, unused or missing dependencies, reverse-imports, entry point detection, node_modules insights, dependency paths — everything in one tool.
68
+ Available checks:
59
69
 
70
+ - `moduleBoundaries` - enforce architecture boundaries between modules.
71
+ - `importConventions` - enforce import style conventions (offers autofix).
72
+ - `unusedExportsDetection` - detect exports that are never used (offers autofix).
73
+ - `orphanFilesDetection` - detect dead/orphan files (offers autofix).
74
+ - `unusedNodeModulesDetection` - detect dependencies declared but not used.
75
+ - `missingNodeModulesDetection` - detect imports missing from package json.
76
+ - `unresolvedImportsDetection` - detect unresolved import requests.
77
+ - `circularImportsDetection` - detect circular imports.
60
78
 
61
- ### **Much faster than alternatives**
79
+ ## Exploratory analysis (CLI-based) 🔍
62
80
 
63
- Rev-dep outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
81
+ Use CLI commands for ad-hoc dependency exploration:
64
82
 
65
- For large project with 500k+ lines of code and 6k+ source code files get checks as fast as:
83
+ - `entry-points` - discover project entry points.
84
+ - `files` - list dependency tree files for a given entry point.
85
+ - `resolve` - trace dependency paths between files (who imports this file).
86
+ - `imported-by` - list direct importers of a file.
87
+ - `circular` - list circular dependency chains.
88
+ - `node-modules` - inspect `used`, `unused`, `missing`, and `installed` node modules.
89
+ - `lines-of-code` - count effective LOC.
90
+ - `list-cwd-files` - list all source code files in CWD
66
91
 
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 |
92
+ ## **Installation 📦**
79
93
 
80
- >Benchmark run on WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU @ 2.80GHz
94
+ **Install locally to set up project check scripts**
81
95
 
82
- # **Key Features 🚀**
96
+ ```
97
+ yarn add -D rev-dep
98
+ ```
83
99
 
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 and monorepos**
95
- * 🏗️ **Supports TypeScript path aliases and package.json imports and exports map**
100
+ ```
101
+ npm install -D rev-dep
102
+ ```
96
103
 
97
- # **Installation 📦**
104
+ ```
105
+ pnpm add -D rev-dep
106
+ ```
98
107
 
99
- Install globally to use as a CLI tool:
108
+ Create config file for a quick start:
109
+
110
+ ```
111
+ npx rev-dep config init
112
+ ```
113
+
114
+ **Install globally to use as a CLI tool:**
100
115
 
101
116
  ```
102
117
  yarn global add rev-dep
@@ -110,8 +125,7 @@ npm install -g rev-dep
110
125
  pnpm global add rev-dep
111
126
  ```
112
127
 
113
-
114
- # **Quick Examples ⚡**
128
+ ## **Quick Examples 💡**
115
129
 
116
130
  A few instant-use examples to get a feel for the tool:
117
131
 
@@ -136,178 +150,20 @@ rev-dep resolve --file src/utils/math.ts --entry-point src/index.ts
136
150
 
137
151
  ```
138
152
 
139
- # **Practical Examples 🔧**
140
-
141
-
142
- Practical examples show how to use rev-dep commands to build code quality checks for your project.
143
-
144
- ### **How to identify where a file is used in the project**
145
-
146
- ```
147
- rev-dep resolve --file path/to/file.ts
148
- ```
149
-
150
- You’ll see all entry points that implicitly require that file, along with resolution paths.
151
-
152
- ### **How to check if a file is used**
153
-
154
- ```
155
- rev-dep resolve --file path/to/file.ts --compact-summary
156
- ```
157
-
158
- Shows how many entry points indirectly depend on the file.
159
-
160
- ### **How to identify dead files**
161
-
162
- ```
163
- rev-dep entry-points
164
- ```
165
-
166
- Exclude framework entry points if needed using `--result-exclude`.
167
-
168
- For example exclude Next.js valid entry points when using pages router, exclude scripts directory - scripts are valid entry-points and exclude all test files:
169
-
170
- ```
171
- rev-dep entry-points --result-exclude "pages/**","scripts/**","**/*.test.*"
172
- ```
173
-
174
- ### **How to list all files imported by an entry point**
175
-
176
- ```
177
- rev-dep files --entry-point path/to/file.ts
178
- ```
179
-
180
- Useful for identifying heavy components or unintended dependencies.
181
-
182
- ### **How to reduce unnecessary imports for an entry point**
183
-
184
- 1. List all files imported:
185
-
186
- ```
187
- rev-dep files --entry-point path/to/entry.ts
188
- ```
189
- 2. Identify suspicious files.
190
- 3. Trace why they are included:
191
-
192
- ```
193
- rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
194
- ```
195
-
196
- ### **How to detect circular dependencies**
197
-
198
- ```
199
- rev-dep circular
200
- ```
201
-
202
- ### **How to find unused node modules**
203
-
204
- ```
205
- rev-dep node-modules unused
206
- ```
207
-
208
- ### **How to find missing node modules**
209
-
210
- ```
211
- rev-dep node-modules missing
212
- ```
213
-
214
- ### **How to check node_modules space usage**
215
-
216
- ```
217
- rev-dep node-modules dirs-size
218
- ```
219
-
220
- ## Working with Monorepo
221
-
222
- Rev-dep provides first-class support for monorepo projects, enabling accurate dependency analysis across workspace packages.
223
-
224
- ### followMonorepoPackages Flag
225
-
226
- The `--follow-monorepo-packages` flag enables resolution of imports from monorepo workspace packages. By default, this flag is set to `false` to maintain compatibility with single-package projects.
227
-
228
- ```bash
229
- # Enable monorepo package resolution
230
- rev-dep circular --follow-monorepo-packages
231
- rev-dep resolve --file src/utils.ts --follow-monorepo-packages
232
- rev-dep entry-points --follow-monorepo-packages
233
- ```
234
-
235
- When enabled, rev-dep will:
236
-
237
- - **Detect workspace packages** automatically by scanning for monorepo configuration
238
- - **Resolve imports between packages** within the workspace
239
- - **Follow package.json exports** for proper module resolution
240
-
241
- ### Exports Map Support
242
-
243
- Rev-dep fully supports the `exports` field in package.json files, which is the standard way to define package entry points in modern Node.js projects.
244
-
245
- The exports map support includes:
246
-
247
- - **Conditional exports** using conditions like `node`, `import`, `default`, and custom conditions
248
- - **Wildcard patterns** for flexible subpath mapping
249
- - **Sugar syntax** for simple main export definitions
250
- - **Nested conditions** for complex resolution scenarios
251
-
252
- ### Condition Names Flag
253
-
254
- To control which conditional exports are resolved, use the `--condition-names` flag. This allows you to specify the priority of conditions when resolving package exports:
255
-
256
- ```bash
257
- # Resolve exports for different environments
258
- rev-dep circular --condition-names=node,import,default
259
- rev-dep resolve --file src/utils.ts --condition-names=import,node
260
- rev-dep entry-points --condition-names=default,node,import
261
- ```
262
-
263
- The conditions are processed in the order specified, with the first matching condition being used. Common conditions include:
264
- - `node` - Node.js environment
265
- - `import` - ES modules
266
- - `require` - CommonJS
267
- - `default` - Fallback condition
268
- - Custom conditions specific to your project or build tools
269
-
270
- Example package.json with exports:
271
-
272
- ```json
273
- {
274
- "name": "@myorg/utils",
275
- "exports": {
276
- ".": {
277
- "import": "./dist/index.mjs",
278
- "require": "./dist/index.js",
279
- "default": "./dist/index.js"
280
- },
281
- "./helpers": "./dist/helpers.js",
282
- "./types/*": "./dist/types/*.d.ts"
283
- }
284
- }
285
- ```
286
-
287
- ### How It Works
288
-
289
- 1. **Monorepo Detection**: When `followMonorepoPackages` is enabled, rev-dep scans for workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.)
290
-
291
- 2. **Package Resolution**: Imports to workspace packages are resolved using the package's exports configuration, falling back to main/module fields when exports are not defined
292
-
293
- 3. **Dependency Validation**: The tool validates that cross-package imports are only allowed when the target package is listed in the consumer's dependencies or devDependencies
294
-
295
- 4. **Path Resolution**: All paths are resolved relative to their respective package roots, ensuring accurate dependency tracking across the entire monorepo
296
-
297
- This makes rev-dep particularly effective for large-scale monorepo projects where understanding cross-package dependencies is crucial for maintaining code quality and architecture.
298
-
299
- ## Config-Based Checks
153
+ ## Config-Based Checks 🛡️
300
154
 
301
155
  Rev-dep provides a configuration system for orchestrating project checks. The config approach is **designed for speed** and is the **preferred way** of implementing project checks because it can execute all checks in a single pass, significantly faster than multiple running individual commands separately.
302
156
 
303
157
  Available checks are:
304
158
 
305
- - **module boundaries** - check if imports respect module boundaries
306
- - **import conventions** - enforce syntactic consistency for imports (includes autofix capability)
307
- - **circular imports** - check if there are circular imports
308
- - **orphan files** - check if there are orphan/dead files
309
- - **unused node modules** - check against unused node modules
310
- - **missing node modules** - check against missing node modules
159
+ - `moduleBoundaries` - enforce architecture boundaries between modules.
160
+ - `importConventions` - enforce import style conventions (offers autofix).
161
+ - `unusedExportsDetection` - detect exports that are never used (offers autofix).
162
+ - `orphanFilesDetection` - detect dead/orphan files (offers autofix).
163
+ - `unusedNodeModulesDetection` - detect dependencies declared but not used.
164
+ - `missingNodeModulesDetection` - detect imports missing from package json.
165
+ - `unresolvedImportsDetection` - detect unresolved import requests.
166
+ - `circularImportsDetection` - detect circular imports.
311
167
 
312
168
  Checks are grouped in rules. You can have multiple rules, eg. for each monorepo package.
313
169
 
@@ -325,7 +181,7 @@ Behavior of `rev-dep config init`:
325
181
  - Monorepo root: Running `rev-dep config init` at the workspace root creates a root rule and a rule for each discovered workspace package.
326
182
  - Monorepo workspace package or regular projects: Running `rev-dep config init` inside a directory creates config with a single rule with `path: "."` for this directory.
327
183
 
328
- Run all configured checks:
184
+ Run all configured checks (dry run, not fixes applied yet):
329
185
 
330
186
  ```bash
331
187
  # Execute all rules and checks defined in the config
@@ -349,12 +205,44 @@ rev-dep config run --fix
349
205
 
350
206
  The configuration file (`rev-dep.config.json(c)` or `.rev-dep.config.json(c)`) allows you to define multiple rules, each targeting different parts of your codebase with specific checks enabled.
351
207
 
208
+ #### Quick Start Configuration
209
+
210
+ ```jsonc
211
+ {
212
+ "configVersion": "1.3",
213
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.3.schema.json?raw=true",
214
+ "rules": [
215
+ {
216
+ "path": ".",
217
+ "unusedExportsDetection": {
218
+ "enabled": true,
219
+ "autofix": true,
220
+ "validEntryPoints": ["src/index.ts" ]
221
+ },
222
+ "orphanFilesDetection": {
223
+ "enabled": true,
224
+ "autofix": true,
225
+ "validEntryPoints": ["src/index.ts"]
226
+ },
227
+ "unusedNodeModulesDetection": {
228
+ "enabled": true
229
+ },
230
+ "circularImportsDetection": {
231
+ "enabled": true
232
+ },
233
+ }
234
+ ]
235
+ }
236
+ ```
237
+
238
+ #### Comprehensive Config Example
239
+
352
240
  Here's a comprehensive example showing all available properties:
353
241
 
354
242
  ```jsonc
355
243
  {
356
- "configVersion": "1.2",
357
- "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.2.schema.json?raw=true", // enables json autocompletion
244
+ "configVersion": "1.3",
245
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.3.schema.json?raw=true", // enables json autocompletion
358
246
  "conditionNames": ["import", "default"],
359
247
  "ignoreFiles": ["**/*.test.*"],
360
248
  "rules": [
@@ -401,7 +289,8 @@ Here's a comprehensive example showing all available properties:
401
289
  "enabled": true,
402
290
  "validEntryPoints": ["src/index.ts", "src/app.ts"],
403
291
  "ignoreTypeImports": true,
404
- "graphExclude": ["**/*.test.*", "**/stories/**/*"]
292
+ "graphExclude": ["**/*.test.*", "**/stories/**/*"],
293
+ "autofix": true
405
294
  },
406
295
  "unusedNodeModulesDetection": {
407
296
  "enabled": true,
@@ -417,6 +306,21 @@ Here's a comprehensive example showing all available properties:
417
306
  "includeModules": ["lodash", "axios"],
418
307
  "excludeModules": ["@types/**"],
419
308
  "outputType": "groupByFile"
309
+ },
310
+ "unusedExportsDetection": {
311
+ "enabled": true,
312
+ "validEntryPoints": ["src/index.ts"],
313
+ "ignoreTypeExports": true,
314
+ "graphExclude": ["**/*.stories.tsx"],
315
+ "autofix": true
316
+ },
317
+ "unresolvedImportsDetection": {
318
+ "enabled": true,
319
+ "ignore": {
320
+ "src/index.ts": "legacy-unresolved-module"
321
+ },
322
+ "ignoreFiles": ["**/*.generated.ts"],
323
+ "ignoreImports": ["@internal/dev-only"]
420
324
  }
421
325
  }
422
326
  ]
@@ -442,6 +346,8 @@ Each rule can contain the following properties:
442
346
  - **`orphanFilesDetection`** (optional): Orphan files detection configuration
443
347
  - **`unusedNodeModulesDetection`** (optional): Unused node modules detection configuration
444
348
  - **`missingNodeModulesDetection`** (optional): Missing node modules detection configuration
349
+ - **`unusedExportsDetection`** (optional): Unused exports detection configuration
350
+ - **`unresolvedImportsDetection`** (optional): Unresolved imports detection configuration
445
351
  - **`importConventions`** (optional): Array of import convention rules
446
352
 
447
353
  #### Module Boundary Properties
@@ -469,6 +375,7 @@ Each rule can contain the following properties:
469
375
  - **`validEntryPoints`** (optional): Array of valid entry point patterns (eg. ["src/index.ts", "src/main.ts"])
470
376
  - **`ignoreTypeImports`** (optional): Exclude type-only imports when building graph (default: false)
471
377
  - **`graphExclude`** (optional): File patterns to exclude from graph analysis
378
+ - **`autofix`** (optional): Delete detected orphan files automatically when running `rev-dep config run --fix` (default: false)
472
379
 
473
380
  **UnusedNodeModulesDetection:**
474
381
  - **`enabled`** (required): Enable/disable unused modules detection
@@ -483,7 +390,19 @@ Each rule can contain the following properties:
483
390
  - **`enabled`** (required): Enable/disable missing modules detection
484
391
  - **`includeModules`** (optional): Module patterns to include in analysis
485
392
  - **`excludeModules`** (optional): Module patterns to exclude from analysis
486
- - **`outputType`** (optional): Output format - "list", "groupByModule", "groupByFile"
393
+ - **`outputType`** (optional): Output format - "list", "groupByModule", "groupByFile", "groupByModuleFilesCount"
394
+
395
+ **UnusedExportsDetection:**
396
+ - **`enabled`** (required): Enable/disable unused exports detection
397
+ - **`validEntryPoints`** (optional): Glob patterns for files whose exports are never reported as unused (eg. ["index.ts", "src/public-api.ts"])
398
+ - **`ignoreTypeExports`** (optional): Skip `export type` / `export interface` from analysis (default: false)
399
+ - **`graphExclude`** (optional): File patterns to exclude from unused exports analysis
400
+
401
+ **UnresolvedImportsDetection:**
402
+ - **`enabled`** (required): Enable/disable unresolved imports detection
403
+ - **`ignore`** (optional): Map of file path (relative to rule path directory) to exact import request to suppress
404
+ - **`ignoreFiles`** (optional): File path globs; all unresolved imports from matching files are suppressed
405
+ - **`ignoreImports`** (optional): Import requests to suppress globally in unresolved results
487
406
 
488
407
  ### Performance Benefits
489
408
 
@@ -496,92 +415,206 @@ The configuration approach provides significant performance advantages:
496
415
 
497
416
  This makes config-based checks faster than running individual commands sequentially, especially for large codebases with multiple sub packages.
498
417
 
418
+ ## **Exploratory Toolkit 🔧**
499
419
 
420
+ Practical examples show how to use rev-dep CLI commands to explore, debug or build code quality checks for your project.
500
421
 
501
- ## Reimplemented to achieve 7x-37x speedup
422
+ ### **How to identify where a file is used in the project**
502
423
 
503
- Rev-dep@2.0.0 was reimplemented in Go from scratch to leverage it's concurrency features and better memory management of compiled languages.
424
+ ```
425
+ rev-dep resolve --file path/to/file.ts
426
+ ```
504
427
 
505
- As a result v2 is up to 37x faster than v1 and consumes up to 13x less memory.
428
+ You’ll see all entry points that implicitly require that file, along with resolution paths.
506
429
 
507
- ### Performance comparison
430
+ ### **How to check if a file is used**
508
431
 
509
- To compare performance rev-dep was benchmarked with hyperfine using 8 runs per test, taking mean time values as a result.
510
- Benchmark was run on TypeScript codebase with 507658 lines of code and 5977 source code files.
432
+ ```
433
+ rev-dep resolve --file path/to/file.ts --compact-summary
434
+ ```
435
+
436
+ Shows how many entry points indirectly depend on the file.
511
437
 
512
- 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.
438
+ ### **How to identify dead files**
513
439
 
514
- ### MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of storage. Power save mode off
440
+ ```
441
+ rev-dep entry-points
442
+ ```
515
443
 
516
- | Command | V1 Time | V2 Time | Time Change | V1 RAM | V2 RAM | RAM Change |
517
- | ------------------------------------------------------------ | ------- | ------- | ----------- | ------ | ------ | ---------- |
518
- | List entry-points `rev-dep entry-points` | 6500ms | 347ms | 19x | ~680MB | ~51MB | 13x |
519
- | List entry-points with dependent files count `-pdc` | 8333ms | 782ms | 11x | ~885MB | ~110MB | 8x |
520
- | List entry-point files `rev-dep files` | 2729ms | 400ms | 7x | ~330MB | ~36MB | 9x |
521
- | Resolve dependency path `rev-dep resolve` | 2984ms | 359ms | 8x | ~330MB | ~35MB | 9x |
444
+ Exclude framework entry points if needed using `--result-exclude`.
522
445
 
523
- ### WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU @ 2.80GHz
446
+ For example exclude Next.js valid entry points when using pages router, exclude scripts directory - scripts are valid entry-points and exclude all test files:
524
447
 
525
- | Command | V1 Time | V2 Time | Time Change |
526
- | ----------------------------------------------------------------------- | ------- | ------- | ----------- |
527
- | List entry-points `rev-dep entry-points` | 9904ms | 270ms | 37x |
528
- | List entry-points with dependent files count `--print-deps-count` | 10562ms | 458ms | 23x |
529
- | List entry-point files `rev-dep files` | 3097ms | 230ms | 13x |
530
- | Resolve dependency path `rev-dep resolve` | 3146ms | 230ms | 14x |
448
+ ```
449
+ rev-dep entry-points --result-exclude "pages/**","scripts/**","**/*.test.*"
450
+ ```
531
451
 
532
- ### New features
452
+ ### **How to list all files imported by an entry point**
533
453
 
534
- V2 comes with bunch of new commands
454
+ ```
455
+ rev-dep files --entry-point path/to/file.ts
456
+ ```
535
457
 
536
- - `circular` - detects circular dependencies in the project
537
- - `lines-of-code` - counts actual lines of code in the project excluding comments and blank lines
538
- - `list-cwd-files` - lists all files in the current working directory
539
- - `node-modules used` - lists all used node modules
540
- - `node-modules unused` - lists all unused node modules
541
- - `node-modules missing` - lists all missing node modules
542
- - `node-modules installed` - lists all installed node modules
543
- - `node-modules installed-duplicates` - lists all installed node modules that exist in file system with the same version multiple times
544
- - `node-modules analyze-size` - analyzes size of specific node modules and helps to identify space-hogging dependencies
545
- - `node-modules dirs-size` - calculates cumulative files size in node_modules directories
458
+ Useful for identifying heavy components or unintended dependencies.
546
459
 
547
- ### ⚠️ What's not supported
460
+ ### **How to reduce unnecessary imports for an entry point**
548
461
 
549
- Comparing to previous versions, these tsconfig features are not supported
462
+ 1. List all files imported:
550
463
 
551
- #### Multiple path aliases
464
+ ```
465
+ rev-dep files --entry-point path/to/entry.ts
466
+ ```
467
+ 2. Identify suspicious files.
468
+ 3. Trace why they are included:
552
469
 
553
- Only first path will be used in resolution.
470
+ ```
471
+ rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
472
+ ```
473
+
474
+ ### **How to detect circular dependencies**
475
+
476
+ ```
477
+ rev-dep circular
478
+ ```
479
+
480
+ ### **How to find unused node modules**
481
+
482
+ ```
483
+ rev-dep node-modules unused
484
+ ```
485
+
486
+ ### **How to find missing node modules**
487
+
488
+ ```
489
+ rev-dep node-modules missing
490
+ ```
491
+
492
+ ### **How to check node_modules space usage**
493
+
494
+ ```
495
+ rev-dep node-modules dirs-size
496
+ ```
497
+ ## Working with Monorepo 🏗️
498
+
499
+ Rev-dep provides first-class support for monorepo projects, enabling accurate dependency analysis across workspace packages.
500
+
501
+ ### followMonorepoPackages Flag
502
+
503
+ The `--follow-monorepo-packages` flag enables resolution of imports from monorepo workspace packages. By default, this flag is set to `false` to maintain compatibility with single-package projects.
504
+
505
+ ```bash
506
+ # Enable monorepo package resolution
507
+ rev-dep circular --follow-monorepo-packages
508
+ rev-dep resolve --file src/utils.ts --follow-monorepo-packages
509
+ rev-dep entry-points --follow-monorepo-packages
510
+ ```
511
+
512
+ When enabled, rev-dep will:
513
+
514
+ - **Detect workspace packages** automatically by scanning for monorepo configuration
515
+ - **Resolve imports between packages** within the workspace
516
+ - **Follow package.json exports** for proper module resolution
517
+
518
+ ### Exports Map Support
519
+
520
+ Rev-dep fully supports the `exports` field in package.json files, which is the standard way to define package entry points in modern Node.js projects.
521
+
522
+ The exports map support includes:
523
+
524
+ - **Conditional exports** using conditions like `node`, `import`, `default`, and custom conditions
525
+ - **Wildcard patterns** for flexible subpath mapping
526
+ - **Sugar syntax** for simple main export definitions
527
+ - **Nested conditions** for complex resolution scenarios
528
+
529
+ ### Condition Names Flag
530
+
531
+ To control which conditional exports are resolved, use the `--condition-names` flag. This allows you to specify the priority of conditions when resolving package exports:
532
+
533
+ ```bash
534
+ # Resolve exports for different environments
535
+ rev-dep circular --condition-names=node,import,default
536
+ rev-dep resolve --file src/utils.ts --condition-names=import,node
537
+ rev-dep entry-points --condition-names=default,node,import
538
+ ```
539
+
540
+ The conditions are processed in the order specified, with the first matching condition being used. Common conditions include:
541
+ - `node` - Node.js environment
542
+ - `import` - ES modules
543
+ - `require` - CommonJS
544
+ - `default` - Fallback condition
545
+ - Custom conditions specific to your project or build tools
546
+
547
+ Example package.json with exports:
554
548
 
555
549
  ```json
556
- // tsconfig.json
557
550
  {
558
- "paths": {
559
- "@/components": ["src/components/*", "src/components2/*"]
551
+ "name": "@myorg/utils",
552
+ "exports": {
553
+ ".": {
554
+ "import": "./dist/index.mjs",
555
+ "require": "./dist/index.js",
556
+ "default": "./dist/index.js"
557
+ },
558
+ "./helpers": "./dist/helpers.js",
559
+ "./types/*": "./dist/types/*.d.ts"
560
560
  }
561
561
  }
562
562
  ```
563
563
 
564
- Imports that should resolve to `src/components2/*` will be considered unresolved.
564
+ ### How It Works
565
+
566
+ 1. **Monorepo Detection**: When `followMonorepoPackages` is enabled, rev-dep scans for workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.)
567
+
568
+ 2. **Package Resolution**: Imports to workspace packages are resolved using the package's exports configuration, falling back to main/module fields when exports are not defined
569
+
570
+ 3. **Dependency Validation**: The tool validates that cross-package imports are only allowed when the target package is listed in the consumer's dependencies or devDependencies
571
+
572
+ 4. **Path Resolution**: All paths are resolved relative to their respective package roots, ensuring accurate dependency tracking across the entire monorepo
573
+
574
+ This makes rev-dep particularly effective for large-scale monorepo projects where understanding cross-package dependencies is crucial for maintaining code quality and architecture.
575
+ ## Performance comparison ⚡
576
+
577
+ Rev-dep can perform multiple checks on 500k+ LoC monorepo with several sub-packages in around 500ms.
578
+
579
+ It outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
580
+
581
+ Here is a performance comparison of specific tasks between rev-dep and alternatives:
582
+
583
+ | Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep |
584
+ |------|-------|--------------|------|----|
585
+ | Find circular dependencies | 289 | dpdm-fast | 7061| 24x|
586
+ | Find unused files | 588 | knip | 6346 | 11x |
587
+ | Find unused node modules | 594 | knip | 6230 | 10x |
588
+ | Find missing node modules | 553 | knip| 6226 | 11x |
589
+ | List all files imported by an entry point | 229 | madge | 4467 | 20x |
590
+ | Discover entry points | 323 | madge | 67000 | 207x
591
+ | Resolve dependency path between files | 228 | please suggest |
592
+ | Count lines of code | 342 | please suggest |
593
+ | Check node_modules disk usage | 1619 | please suggest |
594
+ | Analyze node_modules directory sizes | 521 | please suggest |
595
+
596
+ >Benchmark run on WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU @ 2.80GHz
565
597
 
566
- Why it's not supported? I consider this typescript capability as an anti-pattern. It introduces unnecessary ambiguity in module resolution.
567
- Implementing this would make code more complex, less maintainable and slower.
598
+ ### Circular check performance comparison
568
599
 
569
- #### Using rev-dep as node module
600
+ Benchmark performed on TypeScript codebase with `6034` source code files and `518862` lines of code.
570
601
 
571
- Importing rev-dep in JS/TS is no longer supported. Preferred way is to run rev-dep using child process.
602
+ Benchmark performed on MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of Storage. Power save mode off.
572
603
 
573
- #### Other discrepancies
604
+ 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.
574
605
 
575
- Any other discrepancies between TypeScript module resolution and rev-dep should be considered as a bug.
606
+ `rev-dep` circular check is **12 times** faster than the fastest alternative❗
576
607
 
577
- ### Supported Platforms
608
+ | Tool | Version | Command to Run Circular Check | Time |
609
+ |------|---------|-------------------------------|------|
610
+ | 🥇 [rev-dep](https://github.com/jayu/rev-dep) | 2.0.0 | `rev-dep circular` | 397 ms |
611
+ | 🥈 [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 |
612
+ | 🥉 [dpdm](https://github.com/acrazing/dpdm) | 3.14.0 | `dpdm --no-warning` + list of directories with source code | 5030 ms |
613
+ | [skott](https://github.com/antoine-coulon/skott) | 0.35.6 | node script using skott `findCircularDependencies` function | 29575 ms |
614
+ | [madge](https://github.com/pahen/madge) | 8.0.0 | `madge --circular --extensions js,ts,jsx,tsx .` | 69328 ms |
615
+ | [circular-dependency-scanner](https://github.com/emosheeep/circular-dependency-scanner) | 2.3.0 | `ds` - out of memory error | n/a |
578
616
 
579
- - Linux x64
580
- - MacOS Apple Silicon
581
- - Windows x64
582
617
 
583
- Go allows for cross-compiling, so I'm happy to build and distribute binaries for other platforms as well.
584
- Feel free to open an issue if you need support for another platform.
585
618
 
586
619
  ## CLI reference 📖
587
620
 
@@ -609,14 +642,14 @@ rev-dep circular --ignore-types-imports
609
642
  #### Options
610
643
 
611
644
  ```
612
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
613
- -c, --cwd string Working directory for the command (default "$PWD")
614
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
615
- -h, --help help for circular
616
- -t, --ignore-type-imports Exclude type imports from the analysis
617
- --package-json string Path to package.json (default: ./package.json)
618
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
619
- -v, --verbose Show warnings and verbose output
645
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
646
+ -c, --cwd string Working directory for the command (default "$PWD")
647
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
648
+ -h, --help help for circular
649
+ -t, --ignore-type-imports Exclude type imports from the analysis
650
+ --package-json string Path to package.json (default: ./package.json)
651
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
652
+ -v, --verbose Show warnings and verbose output
620
653
  ```
621
654
 
622
655
 
@@ -651,15 +684,16 @@ rev-dep config run [flags]
651
684
  #### Options
652
685
 
653
686
  ```
654
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
655
- -c, --cwd string Working directory (default "$PWD")
656
- --fix Automatically fix fixable issues
657
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
658
- -h, --help help for run
659
- --list-all-issues List all issues instead of limiting output
660
- --package-json string Path to package.json (default: ./package.json)
661
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
662
- -v, --verbose Show warnings and verbose output
687
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
688
+ -c, --cwd string Working directory (default "$PWD")
689
+ --fix Automatically fix fixable issues
690
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
691
+ -h, --help help for run
692
+ --list-all-issues List all issues instead of limiting output
693
+ --package-json string Path to package.json (default: ./package.json)
694
+ --rules strings Subset of rules to run (comma-separated list of rule paths)
695
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
696
+ -v, --verbose Show warnings and verbose output
663
697
  ```
664
698
 
665
699
 
@@ -705,19 +739,19 @@ rev-dep entry-points --print-deps-count
705
739
  #### Options
706
740
 
707
741
  ```
708
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
709
- -n, --count Only display the number of entry points found
710
- -c, --cwd string Working directory for the command (default "$PWD")
711
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
712
- --graph-exclude strings Exclude files matching these glob patterns from analysis
713
- -h, --help help for entry-points
714
- -t, --ignore-type-imports Exclude type imports from the analysis
715
- --package-json string Path to package.json (default: ./package.json)
716
- --print-deps-count Show the number of dependencies for each entry point
717
- --result-exclude strings Exclude files matching these glob patterns from results
718
- --result-include strings Only include files matching these glob patterns in results
719
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
720
- -v, --verbose Show warnings and verbose output
742
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
743
+ -n, --count Only display the number of entry points found
744
+ -c, --cwd string Working directory for the command (default "$PWD")
745
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
746
+ --graph-exclude strings Exclude files matching these glob patterns from analysis
747
+ -h, --help help for entry-points
748
+ -t, --ignore-type-imports Exclude type imports from the analysis
749
+ --package-json string Path to package.json (default: ./package.json)
750
+ --print-deps-count Show the number of dependencies for each entry point
751
+ --result-exclude strings Exclude files matching these glob patterns from results
752
+ --result-include strings Only include files matching these glob patterns in results
753
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
754
+ -v, --verbose Show warnings and verbose output
721
755
  ```
722
756
 
723
757
 
@@ -743,16 +777,16 @@ rev-dep files --entry-point src/index.ts
743
777
  #### Options
744
778
 
745
779
  ```
746
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
747
- -n, --count Only display the count of files in the dependency tree
748
- -c, --cwd string Working directory for the command (default "$PWD")
749
- -p, --entry-point string Entry point file to analyze (required)
750
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
751
- -h, --help help for files
752
- -t, --ignore-type-imports Exclude type imports from the analysis
753
- --package-json string Path to package.json (default: ./package.json)
754
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
755
- -v, --verbose Show warnings and verbose output
780
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
781
+ -n, --count Only display the count of files in the dependency tree
782
+ -c, --cwd string Working directory for the command (default "$PWD")
783
+ -p, --entry-point string Entry point file to analyze (required)
784
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
785
+ -h, --help help for files
786
+ -t, --ignore-type-imports Exclude type imports from the analysis
787
+ --package-json string Path to package.json (default: ./package.json)
788
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
789
+ -v, --verbose Show warnings and verbose output
756
790
  ```
757
791
 
758
792
 
@@ -778,16 +812,16 @@ rev-dep imported-by --file src/utils/helpers.ts
778
812
  #### Options
779
813
 
780
814
  ```
781
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
782
- -n, --count Only display the count of importing files
783
- -c, --cwd string Working directory for the command (default "$PWD")
784
- -f, --file string Target file to find importers for (required)
785
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
786
- -h, --help help for imported-by
787
- --list-imports List the import identifiers used by each file
788
- --package-json string Path to package.json (default: ./package.json)
789
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
790
- -v, --verbose Show warnings and verbose output
815
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
816
+ -n, --count Only display the count of importing files
817
+ -c, --cwd string Working directory for the command (default "$PWD")
818
+ -f, --file string Target file to find importers for (required)
819
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
820
+ -h, --help help for imported-by
821
+ --list-imports List the import identifiers used by each file
822
+ --package-json string Path to package.json (default: ./package.json)
823
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
824
+ -v, --verbose Show warnings and verbose output
791
825
  ```
792
826
 
793
827
 
@@ -976,24 +1010,25 @@ rev-dep node-modules missing --entry-points=src/main.ts
976
1010
  #### Options
977
1011
 
978
1012
  ```
979
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
980
- -n, --count Only display the count of modules
981
- -c, --cwd string Working directory for the command (default "$PWD")
982
- -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
983
- -e, --exclude-modules strings list of modules to exclude from the output
984
- -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
985
- -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
986
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
987
- --group-by-file Organize output by project file path
988
- --group-by-module Organize output by npm package name
989
- -h, --help help for missing
990
- -t, --ignore-type-imports Exclude type imports from the analysis
991
- -i, --include-modules strings list of modules to include in the output
992
- --package-json string Path to package.json (default: ./package.json)
993
- --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
994
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
995
- -v, --verbose Show warnings and verbose output
996
- --zero-exit-code Use this flag to always return zero exit code
1013
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1014
+ -n, --count Only display the count of modules
1015
+ -c, --cwd string Working directory for the command (default "$PWD")
1016
+ -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1017
+ -e, --exclude-modules strings list of modules to exclude from the output
1018
+ -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1019
+ -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1020
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1021
+ --group-by-file Organize output by project file path
1022
+ --group-by-module Organize output by npm package name
1023
+ --group-by-module-files-count Organize output by npm package name and show count of files using it
1024
+ -h, --help help for missing
1025
+ -t, --ignore-type-imports Exclude type imports from the analysis
1026
+ -i, --include-modules strings list of modules to include in the output
1027
+ --package-json string Path to package.json (default: ./package.json)
1028
+ --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
1029
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1030
+ -v, --verbose Show warnings and verbose output
1031
+ --zero-exit-code Use this flag to always return zero exit code
997
1032
  ```
998
1033
 
999
1034
 
@@ -1019,22 +1054,22 @@ rev-dep node-modules unused --exclude-modules=@types/*
1019
1054
  #### Options
1020
1055
 
1021
1056
  ```
1022
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1023
- -n, --count Only display the count of modules
1024
- -c, --cwd string Working directory for the command (default "$PWD")
1025
- -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1026
- -e, --exclude-modules strings list of modules to exclude from the output
1027
- -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1028
- -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1029
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
1030
- -h, --help help for unused
1031
- -t, --ignore-type-imports Exclude type imports from the analysis
1032
- -i, --include-modules strings list of modules to include in the output
1033
- --package-json string Path to package.json (default: ./package.json)
1034
- --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
1035
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1036
- -v, --verbose Show warnings and verbose output
1037
- --zero-exit-code Use this flag to always return zero exit code
1057
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1058
+ -n, --count Only display the count of modules
1059
+ -c, --cwd string Working directory for the command (default "$PWD")
1060
+ -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1061
+ -e, --exclude-modules strings list of modules to exclude from the output
1062
+ -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1063
+ -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1064
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1065
+ -h, --help help for unused
1066
+ -t, --ignore-type-imports Exclude type imports from the analysis
1067
+ -i, --include-modules strings list of modules to include in the output
1068
+ --package-json string Path to package.json (default: ./package.json)
1069
+ --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
1070
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1071
+ -v, --verbose Show warnings and verbose output
1072
+ --zero-exit-code Use this flag to always return zero exit code
1038
1073
  ```
1039
1074
 
1040
1075
 
@@ -1060,23 +1095,24 @@ rev-dep node-modules used -p src/index.ts --group-by-module
1060
1095
  #### Options
1061
1096
 
1062
1097
  ```
1063
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1064
- -n, --count Only display the count of modules
1065
- -c, --cwd string Working directory for the command (default "$PWD")
1066
- -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1067
- -e, --exclude-modules strings list of modules to exclude from the output
1068
- -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1069
- -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1070
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
1071
- --group-by-file Organize output by project file path
1072
- --group-by-module Organize output by npm package name
1073
- -h, --help help for used
1074
- -t, --ignore-type-imports Exclude type imports from the analysis
1075
- -i, --include-modules strings list of modules to include in the output
1076
- --package-json string Path to package.json (default: ./package.json)
1077
- --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
1078
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1079
- -v, --verbose Show warnings and verbose output
1098
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1099
+ -n, --count Only display the count of modules
1100
+ -c, --cwd string Working directory for the command (default "$PWD")
1101
+ -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1102
+ -e, --exclude-modules strings list of modules to exclude from the output
1103
+ -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1104
+ -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1105
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1106
+ --group-by-file Organize output by project file path
1107
+ --group-by-module Organize output by npm package name
1108
+ --group-by-module-files-count Organize output by npm package name and show count of files using it
1109
+ -h, --help help for used
1110
+ -t, --ignore-type-imports Exclude type imports from the analysis
1111
+ -i, --include-modules strings list of modules to include in the output
1112
+ --package-json string Path to package.json (default: ./package.json)
1113
+ --pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
1114
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1115
+ -v, --verbose Show warnings and verbose output
1080
1116
  ```
1081
1117
 
1082
1118
 
@@ -1102,45 +1138,27 @@ rev-dep resolve -p src/index.ts -f src/utils/helpers.ts
1102
1138
  #### Options
1103
1139
 
1104
1140
  ```
1105
- -a, --all Show all possible resolution paths, not just the first one
1106
- --compact-summary Display a compact summary of found paths
1107
- --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1108
- -c, --cwd string Working directory for the command (default "$PWD")
1109
- -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1110
- -f, --file string Target file to check for dependencies
1111
- --follow-monorepo-packages Enable resolution of imports from monorepo workspace packages
1112
- --graph-exclude strings Glob patterns to exclude files from dependency analysis
1113
- -h, --help help for resolve
1114
- -t, --ignore-type-imports Exclude type imports from the analysis
1115
- --package-json string Path to package.json (default: ./package.json)
1116
- --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1117
- -v, --verbose Show warnings and verbose output
1141
+ -a, --all Show all possible resolution paths, not just the first one
1142
+ --compact-summary Display a compact summary of found paths
1143
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1144
+ -c, --cwd string Working directory for the command (default "$PWD")
1145
+ -p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
1146
+ -f, --file string Target file to check for dependencies
1147
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1148
+ --graph-exclude strings Glob patterns to exclude files from dependency analysis
1149
+ -h, --help help for resolve
1150
+ -t, --ignore-type-imports Exclude type imports from the analysis
1151
+ --package-json string Path to package.json (default: ./package.json)
1152
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1153
+ -v, --verbose Show warnings and verbose output
1118
1154
  ```
1119
1155
 
1120
1156
 
1121
1157
 
1122
1158
  <!-- cli-docs-end -->
1123
1159
 
1124
- ## Circular check performance comparison
1125
-
1126
- Benchmark performed on TypeScript codebase with `6034` source code files and `518862` lines of code.
1127
-
1128
- Benchmark performed on MacBook Pro with Apple M1 chip, 16GB of RAM and 256GB of Storage. Power save mode off.
1129
-
1130
- 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.
1131
-
1132
- `rev-dep` circular check is **12 times** faster than the fastest alternative❗
1133
-
1134
- | Tool | Version | Command to Run Circular Check | Time |
1135
- |------|---------|-------------------------------|------|
1136
- | 🥇 [rev-dep](https://github.com/jayu/rev-dep) | 2.0.0 | `rev-dep circular` | 397 ms |
1137
- | 🥈 [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 |
1138
- | 🥉 [dpdm](https://github.com/acrazing/dpdm) | 3.14.0 | `dpdm --no-warning` + list of directories with source code | 5030 ms |
1139
- | [skott](https://github.com/antoine-coulon/skott) | 0.35.6 | node script using skott `findCircularDependencies` function | 29575 ms |
1140
- | [madge](https://github.com/pahen/madge) | 8.0.0 | `madge --circular --extensions js,ts,jsx,tsx .` | 69328 ms |
1141
- | [circular-dependency-scanner](https://github.com/emosheeep/circular-dependency-scanner) | 2.3.0 | `ds` - out of memory error | n/a |
1142
1160
 
1143
- ## Glossary
1161
+ ## Glossary 📚
1144
1162
 
1145
1163
  Some of the terms used in the problem space that **rev-dep** covers can be confusing.
1146
1164
  Here is a small glossary to help you navigate the concepts.
@@ -1202,4 +1220,4 @@ The top-level directory used as the starting point for dependency analysis.
1202
1220
 
1203
1221
  ## Made in 🇵🇱 and 🇯🇵 with 🧠 by [@jayu](https://github.com/jayu)
1204
1222
 
1205
- 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 ⭐!
1223
+ 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rev-dep",
3
- "version": "2.6.1",
3
+ "version": "2.7.1",
4
4
  "description": "Trace imports, detect unused code, clean dependencies — all with a super-fast CLI",
5
5
  "bin": "bin.js",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "optionalDependencies": {
20
- "@rev-dep/darwin-arm64": "2.6.1",
21
- "@rev-dep/linux-x64": "2.6.1",
22
- "@rev-dep/win32-x64": "2.6.1"
20
+ "@rev-dep/darwin-arm64": "2.7.1",
21
+ "@rev-dep/linux-x64": "2.7.1",
22
+ "@rev-dep/win32-x64": "2.7.1"
23
23
  },
24
24
  "keywords": [
25
25
  "dependency-analysis",