rev-dep 2.7.1 → 2.8.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 (2) hide show
  1. package/Readme.md +65 -13
  2. package/package.json +4 -4
package/Readme.md CHANGED
@@ -1,3 +1,5 @@
1
+ # Rev-dep
2
+
1
3
  <p align="center">
2
4
  <img src="https://github.com/jayu/rev-dep/raw/master/logo.png" width="400" alt="Rev-dep logo">
3
5
  </p>
@@ -12,11 +14,11 @@
12
14
  <p align="center">
13
15
  Dependency analysis and optimization toolkit for modern JavaScript and TypeScript codebases.
14
16
  <br>
15
- Enforce dependency graph hygiene and remove unused bits with a very fast CLI.
17
+ Enforce dependency graph hygiene and remove unused code with a very fast CLI.
16
18
  </p>
17
19
 
18
20
  <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">
21
+ <img src="https://github.com/jayu/rev-dep/raw/master/demo.png" alt="Rev-dep config execution CLI output" width="400">
20
22
  </p>
21
23
 
22
24
  ---
@@ -25,7 +27,7 @@
25
27
 
26
28
  ## **About 📣**
27
29
 
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.
30
+ As codebases scale, maintaining a mental map of dependencies becomes impossible. **Rev-dep** is a high-speed static analysis tool designed to enforce architecture integrity and dependency hygiene across large-scale JS/TS projects.
29
31
 
30
32
  <p align="center"><b>Think of Rev-dep as a high-speed linter for your dependency graph.</b></p>
31
33
 
@@ -61,7 +63,7 @@ Implemented in **Go** to eliminate the performance tax of Node-based analysis. B
61
63
 
62
64
  ## Capabilities 🚀
63
65
 
64
- ## Governance and maintenance (config-based) 🛡️
66
+ ### Governance and maintenance (config-based) 🛡️
65
67
 
66
68
  Use `rev-dep config run` to execute multiple checks in one pass for all packages.
67
69
 
@@ -75,8 +77,9 @@ Available checks:
75
77
  - `missingNodeModulesDetection` - detect imports missing from package json.
76
78
  - `unresolvedImportsDetection` - detect unresolved import requests.
77
79
  - `circularImportsDetection` - detect circular imports.
80
+ - `devDepsUsageOnProdDetection` - detect dev dependencies used in production code.
78
81
 
79
- ## Exploratory analysis (CLI-based) 🔍
82
+ ### Exploratory analysis (CLI-based) 🔍
80
83
 
81
84
  Use CLI commands for ad-hoc dependency exploration:
82
85
 
@@ -164,6 +167,7 @@ Available checks are:
164
167
  - `missingNodeModulesDetection` - detect imports missing from package json.
165
168
  - `unresolvedImportsDetection` - detect unresolved import requests.
166
169
  - `circularImportsDetection` - detect circular imports.
170
+ - `devDepsUsageOnProdDetection` - detect dev dependencies used in production code.
167
171
 
168
172
  Checks are grouped in rules. You can have multiple rules, eg. for each monorepo package.
169
173
 
@@ -209,8 +213,8 @@ The configuration file (`rev-dep.config.json(c)` or `.rev-dep.config.json(c)`) a
209
213
 
210
214
  ```jsonc
211
215
  {
212
- "configVersion": "1.3",
213
- "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.3.schema.json?raw=true",
216
+ "configVersion": "1.4",
217
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.4.schema.json?raw=true",
214
218
  "rules": [
215
219
  {
216
220
  "path": ".",
@@ -230,6 +234,10 @@ The configuration file (`rev-dep.config.json(c)` or `.rev-dep.config.json(c)`) a
230
234
  "circularImportsDetection": {
231
235
  "enabled": true
232
236
  },
237
+ "devDepsUsageOnProdDetection": {
238
+ "enabled": true,
239
+ "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx"]
240
+ }
233
241
  }
234
242
  ]
235
243
  }
@@ -241,8 +249,8 @@ Here's a comprehensive example showing all available properties:
241
249
 
242
250
  ```jsonc
243
251
  {
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
252
+ "configVersion": "1.4",
253
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.4.schema.json?raw=true", // enables json autocompletion
246
254
  "conditionNames": ["import", "default"],
247
255
  "ignoreFiles": ["**/*.test.*"],
248
256
  "rules": [
@@ -321,6 +329,10 @@ Here's a comprehensive example showing all available properties:
321
329
  },
322
330
  "ignoreFiles": ["**/*.generated.ts"],
323
331
  "ignoreImports": ["@internal/dev-only"]
332
+ },
333
+ "devDepsUsageOnProdDetection": {
334
+ "enabled": true,
335
+ "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx", "src/server.ts"]
324
336
  }
325
337
  }
326
338
  ]
@@ -348,6 +360,7 @@ Each rule can contain the following properties:
348
360
  - **`missingNodeModulesDetection`** (optional): Missing node modules detection configuration
349
361
  - **`unusedExportsDetection`** (optional): Unused exports detection configuration
350
362
  - **`unresolvedImportsDetection`** (optional): Unresolved imports detection configuration
363
+ - **`devDepsUsageOnProdDetection`** (optional): Restricted dev dependencies usage detection configuration
351
364
  - **`importConventions`** (optional): Array of import convention rules
352
365
 
353
366
  #### Module Boundary Properties
@@ -404,6 +417,10 @@ Each rule can contain the following properties:
404
417
  - **`ignoreFiles`** (optional): File path globs; all unresolved imports from matching files are suppressed
405
418
  - **`ignoreImports`** (optional): Import requests to suppress globally in unresolved results
406
419
 
420
+ **DevDepsUsageOnProd:**
421
+ - **`enabled`** (required): Enable/disable restricted dev dependencies usage detection
422
+ - **`prodEntryPoints`** (optional): Production entry point patterns to trace dependencies from (eg. ["src/pages/**/*.tsx", "src/main.tsx"])
423
+
407
424
  ### Performance Benefits
408
425
 
409
426
  The configuration approach provides significant performance advantages:
@@ -583,9 +600,10 @@ Here is a performance comparison of specific tasks between rev-dep and alternati
583
600
  | Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep |
584
601
  |------|-------|--------------|------|----|
585
602
  | 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 |
603
+ | Find unused exports | 303 | knip| 6606 | 22x |
604
+ | Find unused files | 277 | knip | 6596 | 23x |
605
+ | Find unused node modules | 287 | knip | 6572 | 22x |
606
+ | Find missing node modules | 270 | knip| 6568 | 24x |
589
607
  | List all files imported by an entry point | 229 | madge | 4467 | 20x |
590
608
  | Discover entry points | 323 | madge | 67000 | 207x
591
609
  | Resolve dependency path between files | 228 | please suggest |
@@ -616,6 +634,35 @@ Benchmark performed with `hyperfine` using 8 runs per test and 4 warm up runs, t
616
634
 
617
635
 
618
636
 
637
+ ### **How to detect dev dependencies used in production code**
638
+
639
+ ```
640
+ rev-dep config run
641
+ ```
642
+
643
+ When `devDepsUsageOnProdDetection` is enabled in your config, rev-dep will:
644
+
645
+ 1. Trace dependency graphs from your specified production entry points
646
+ 2. Identify all files reachable from those entry points
647
+ 3. Check if any imported modules are listed in `devDependencies` in package.json
648
+ 4. Report violations showing which dev dependencies are used where
649
+
650
+ **Example Output:**
651
+ ```
652
+ ❌ Restricted Dev Dependencies Usage Issues (2):
653
+ lodash (dev dependency)
654
+ - src/components/Button.tsx (from entry point: src/pages/index.tsx)
655
+ - src/utils/helpers.ts (from entry point: src/pages/index.tsx)
656
+ eslint (dev dependency)
657
+ - src/config/eslint-config.js (from entry point: src/server.ts)
658
+ ```
659
+
660
+ **Important Notes:**
661
+ - Type-only imports (e.g., `import type { ReactNode } from 'react'`) are automatically ignored
662
+ - Only dependencies from `devDependencies` in package.json are flagged
663
+ - Production dependencies from `dependencies` are allowed
664
+ - Helps prevent runtime failures in production builds
665
+
619
666
  ## CLI reference 📖
620
667
 
621
668
  <!-- cli-docs-start -->
@@ -1103,9 +1150,13 @@ rev-dep node-modules used -p src/index.ts --group-by-module
1103
1150
  -b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
1104
1151
  -m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
1105
1152
  --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1153
+ --group-by-entry-point Organize output by entry point file path
1154
+ --group-by-entry-point-modules-count Organize output by entry point and show count of unique modules
1106
1155
  --group-by-file Organize output by project file path
1107
1156
  --group-by-module Organize output by npm package name
1157
+ --group-by-module-entry-points-count Organize output by npm package name and show count of entry points using it
1108
1158
  --group-by-module-files-count Organize output by npm package name and show count of files using it
1159
+ --group-by-module-show-entry-points Organize output by npm package name and list entry points using it
1109
1160
  -h, --help help for used
1110
1161
  -t, --ignore-type-imports Exclude type imports from the analysis
1111
1162
  -i, --include-modules strings list of modules to include in the output
@@ -1142,12 +1193,13 @@ rev-dep resolve -p src/index.ts -f src/utils/helpers.ts
1142
1193
  --compact-summary Display a compact summary of found paths
1143
1194
  --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
1144
1195
  -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)
1196
+ -p, --entry-points strings Entry point file(s) or glob pattern(s) to start analysis from (default: auto-detected)
1146
1197
  -f, --file string Target file to check for dependencies
1147
1198
  --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
1148
1199
  --graph-exclude strings Glob patterns to exclude files from dependency analysis
1149
1200
  -h, --help help for resolve
1150
1201
  -t, --ignore-type-imports Exclude type imports from the analysis
1202
+ --module string Target node module name to check for dependencies
1151
1203
  --package-json string Path to package.json (default: ./package.json)
1152
1204
  --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
1153
1205
  -v, --verbose Show warnings and verbose output
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rev-dep",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
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.7.1",
21
- "@rev-dep/linux-x64": "2.7.1",
22
- "@rev-dep/win32-x64": "2.7.1"
20
+ "@rev-dep/darwin-arm64": "2.8.0",
21
+ "@rev-dep/linux-x64": "2.8.0",
22
+ "@rev-dep/win32-x64": "2.8.0"
23
23
  },
24
24
  "keywords": [
25
25
  "dependency-analysis",