How to integrate a custom lodash assembly into a project

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

.

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

Create a custom build command that creates a custom build and places it somewhere? (Where?)

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

+3


source to share


1 answer


There are several approaches to using a subset of lodash:

  • Using the CLI to create a custom assembly (a file in your project codebase) of the required functionality
  • Use npm modules or lodash modules in your codebase (i.e. instead _ = require('lodash'); _.each(...)

    you would do each = require('lodash/collections/each')

    )
  • Use a tool lodash-modularize

    to create and maintain a custom lodash build for a given project and use lodash

    as described elsewhere. This will essentially automate the two / three methods above.


Each approach is 100% valid and has its own pros and cons.

Disclaimer, I am the author lodash-modularize

+6


source







All Articles