find-used-lodash
v1.2.0
Published
Use esprima to find and detect used lodash packages
Downloads
25
Maintainers
Readme
find-used-lodash
Use Esprima to find and detect used Lodash packages
Useful for preparing an array to pass to a build task in order to build only used packages.
- Please see Lodash for usable packages.
- Checkout Lodash custom build tool for possible uses.
Important notice Chained Lodash packages are currently not detected.
Install
npm install --save-dev find-used-lodash
Example
General Usage
var findUsedLodash = require('find-used-lodash');
console.log(findUsedLodash('_.each(["a", "b"], doSomething)');
//=> ['each']
Use in a build task (grunt,gulp)...
var findUsedLodash = require('find-used-lodash');
var fileContents = fs.readFileSync('targetFile.js', 'utf8'); //or get it from file stream
var results = findUsedLodash(fileContents);
var commaResults = results.join(',');
//then execute lodash command line with **lodash include=commaResults**
Options
@param {String} jsFileContents - the js file contents as a string
@return {String[]} array of used Lodash packages.
License
MIT @Gilad Peleg