babel-plugin-lodash-legacy

0.4.0 • Public • Published

babel-plugin-lodash-legacy 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.

Deprecated

babel5 is no longer officially supported. This plugin is for the rare few who are still on babel5 but have yet to (and should) update to latest. Use at your own risk!

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"]
});

Package Sidebar

Install

npm i babel-plugin-lodash-legacy

Weekly Downloads

1

Version

0.4.0

License

WTFPL

Last publish

Collaborators

  • aabenoja