Skip to content

gajus/babel-plugin-lodash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-lodash Build Status

The goal of this package is to be an alternative/augmentation of lodash-modularize which is designed with slightly different goals.

This plugin is a simple transform to remove unused lodash code, without forcing the user to cherry pick methods manually. This lets you use lodash naturally (aka as documented) without worrying about bundling parts you're not using.

Example

Converts

import lodash from 'lodash';

lodash.map([1, 2, 3], function(x) {
    // ...
});

(roughly) to

import _map from 'lodash/collection/map';

_map([1, 2, 3], function(x) {
    // ...
});

FAQ

Where's my npm module support?

It will be implemented when plugins can support options (babel/babel#1833).

For now use lodash-modularize.

Do import specifiers work (import {x} from 'lodash')

You know it! You can also use both specifiers and direct imports (import _, {y} from 'lodash').

What about lodash-fp?

We've got ya covered (#3).

Limitations

  • You must be using ES6 imports to load lodash.

  • Chaining syntax is not supported

Usage

Via .babelrc (Recommended)
{
  "plugins": ["lodash"]
}
Via CLI
$ babel --plugins lodash script.js
Via Node API
require("babel-core").transform("code", {
  plugins: ["lodash"]
});

About

Modular lodash builds without the hassle

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%