Simple util to find deadcode and unused files in any JavaScript project (ES5, ES6, React, Vue, ...).
This project uses optional chaining, so you need to use Node v14.0 + to be able to use it.
Install deadfile cli with the following command:
npm
$ npm install -g deadfile
yarn
$ yarn global add deadfile
npx
$ npx deadfile <file>
simple:
deadfile ./src/index.js
multiple entry:
deadfile ./src/index.js ./src/entry2.js
with custom directory:
deadfile ./src/index.js --dir /path/to/other/folder
with exclude:
deadfile ./src/index.js --exclude tests utils/webpack
without the report server or in CI scripts:
deadfile ./src/index.js --ci
All major ES Module imports are supported (including dynamic import):
Also the following export (aggregation) syntaxes are also supported:
You can use deadfile
for any JavaScript project, and go crazy with you code, use the latest features and it still works. Here are some examples:
deadfile
look for import declarations and calls of the require
function. As a result, if you assign require
to another var and use it to load a dependency, it will not handle it.
deadfile
are considered as entries (yes, deadfile supports multiple entries)
deadfile ./src/index.js ./src/entry2.js
deadfile <file> --dir /path/to/other/folder
Paths or files to exclude from search. It supports any valid RegExp expression to exclude:
deadfile <file> --exclude ^(\w)png$
deadfile <file> --exclude webpack utils docs
---output: used to write report results in .json
file
You can specify the file to write, a json file including file lists:
deadfile <file> --output report.json