Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to integrate a lodash custom build into a project

lodash supports custom builds with only a subset of the functionality / size. Creating a custom build is a breeze with lodash-cli.

What's the recommended way to take this custom build and integrate it into the project? (using npm / browserify).

Do I create a custom build command that creates the custom build and places it somewhere? (where?)

Is there a canonical way to specify the dependency and integrate into the project?

like image 395
gingerlime Avatar asked Jun 04 '15 07:06

gingerlime


1 Answers

There are several approaches you can take to use a subset of lodash:

  • Use the CLI to generate a custom build (a file within your projects codebase) of the features you need
  • Use npm modules or the lodash modules within your code base (i.e. instead of doing _ = require('lodash'); _.each(...) you would do each = require('lodash/collections/each'))
  • Use the lodash-modularize tool to create and maintain a custom lodash build for a given project and use lodash as otherwise documented. This is essentially automating the two/three methods above.

Each approach is 100% valid and has their pros and cons

Disclaimer, I'm the author of lodash-modularize

like image 151
megawac Avatar answered Dec 20 '22 18:12

megawac