unrequired
find unused javascript files in your project
Last updated 3 months ago by spencermountain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unrequired 
SYNC missed versions from official npm registry.
unrequired
find unused javascript files

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:

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
}
*/

There are probably some caveats to this.

It atleast attempts to support esmodules, .mjs files, and some other things.

it won't catch any unrequired .json files.

running it may be helpful in a large javascript project! who knows.

It uses rollup ⭐️

MIT

Current Tags

  • 0.2.0                                ...           latest (3 months ago)

7 Versions

  • 0.2.0                                ...           3 months ago
  • 0.1.1                                ...           4 months ago
  • 0.1.0                                ...           5 months ago
  • 0.0.4                                ...           10 months ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 11
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |