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.
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!
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) {
// ...
});
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).
-
You must be using ES6 imports to load lodash.
-
Chaining syntax is not supported
{
"plugins": ["lodash"]
}
$ babel --plugins lodash script.js
require("babel-core").transform("code", {
plugins: ["lodash"]
});