00mjk / deps

πŸ“¦πŸ” Analyze which package.json dependencies are in-use with V8 Coverage πŸ”₯

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“¦πŸ” deps


Analyze which package.json dependencies are in-use with V8 Coverage πŸ”₯

πŸ™‹ Why?

  • 🧹 Tidy package.json Find out which dependencies are used/unused
  • πŸ”₯ V8 Coverage Uses Node's Coverage feature to accurately identify which modules are loaded
  • πŸ’… Pretty output View the results in a readable table. Save the output in JSON to view later
  • πŸš€ Ready-to-go Designed to be easy to use with npxβ€”No installation required!

πŸ‘‰ Try it out!

$ npx deps [...Node command]

eg. npx deps npm run build

πŸš€ Install

Install globally if you don't want to use it via npx.

npm i -g deps

Usage

πŸ”¬ Quick analysis

Prefix your Node command with deps and it will analyze and output the dependencies it used

$ deps ...

eg. deps npm run build

πŸ‘©β€πŸ”¬ Analyzing dependency usage across commands

Prerequisite: install deps globally

  1. Start recording dependecy usage (note the dot-space at the beginning)
$ . deps-start
  1. Run a series of Node scripts eg.
  • npm run dev
  • npm run build
  • npm run lint
  • etc.
  1. Analyze used dependencies
$ deps analyze
  • Save data to file:
    deps analyze -o output.json
  • Read later with:
    deps -f output.json
  1. When you're done, stop recording
$ . deps-stop

πŸ’β€β™‚οΈ FAQ

How does deps work?

deps detects which modules are loaded by using V8's code coverage feature, so it's very accurate. However, it doesn't detect file-system reads, as they are simply read as text rather than actually being parsed and executed. That means it can't detect what files are statically analyzed by bundlers (eg. Webpack, Rollup, etc.). I am considering supporting FS reads in the future.

How does deps compare to depcheck?

depcheck statically analyzes your project to see which dependencies are imported, avoiding the need to execute code. In contrast, deps executes code to analyze which dependencies were loaded during run-time. They work in completely different ways, but a major drawback for me is that depcheck requires a "special" for supporting whether a module was loaded via dev-tools.

πŸ’Ό License

MIT

About

πŸ“¦πŸ” Analyze which package.json dependencies are in-use with V8 Coverage πŸ”₯

License:MIT License


Languages

Language:TypeScript 95.4%Language:Shell 3.6%Language:JavaScript 1.0%