Get the number of used modules within a directory
npm install get-module-count
Works for AMD, CommonJS, and ES6 codebases.
var getModuleCount = require('get-module-count');
getModuleCount({
directory: 'path/to/my/js',
success: function(err, count) {
}
});- You may pass additional options supported by
get-driver-scriptsto handle pulling driver scripts from a RequireJS build config or resolving aliased paths via a requirejs config.
This module works by getting the driver script (i.e., entry points) from the given directory. For each driver script, it will generate the memoized dependency tree for that script and then sum the number of unique modules across all the trees.
You can invoke this as a shell command with a global install npm install -g get-module-count
get-module-count <directory>