Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spencermountain/unrequired
find unused javascript files in your project
https://github.com/spencermountain/unrequired
code-quality
Last synced: 2 months ago
JSON representation
find unused javascript files in your project
- Host: GitHub
- URL: https://github.com/spencermountain/unrequired
- Owner: spencermountain
- Created: 2018-02-21T18:45:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-29T15:49:33.000Z (over 3 years ago)
- Last Synced: 2024-10-14T21:06:03.339Z (3 months ago)
- Topics: code-quality
- Language: JavaScript
- Size: 71.3 KB
- Stars: 108
- Watchers: 3
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
in a big javascript project, sometimes you can forget to delete a unused file.
`linters` and `tree-shakers` are good at finding unused **code** in a module, but they can allow you to have a whole unused file somewhere in your project.
This script follows the require graph, and compares it to the `ls` output, to find any files that are potentially not being used.
`npm install -g unrequired`
`unrequired ./path/to/my/index.js`
or from a node script:
```js
const unrequired = require('unrequired')
let result = unrequired('./tests/mjs/index.js')
console.log(result)
/*
{
all:[ ... ], // all javascript files from a 'ls'
used:[ ... ], // all files in the sourcemap bundle
unused:[], // the diff between the two
}
*/
```running it may be helpful in a large javascript project! who knows.
It uses [rollup](https://rollupjs.org) ⭐️
### Caveats
JSX, and other variants are not currently supported.It atleast attempts to support `esmodules`, `.mjs files`, and some other things.
it won't catch any unrequired `.json` files.
## See Also
* [unused-webpack-plugin](https://github.com/MatthieuLemoine/unused-webpack-plugin) by Matthieu Lemoine
* [node-trucker](https://github.com/davidmfoley/node-trucker) by Dave FoleyMIT