babel-plugin-lodash-magic-import
v0.2.2
Published
Transforms lodash imports into tree-shakeable ones
Downloads
8
Maintainers
Readme
lodash-magic-import
Magic import 🍒 picks lodash 📦 for you.
Transforms
import _ from 'lodash';
_.forEach([], () => ({}));
into these
import _forEach from 'lodash/forEach';
_forEach([], () => ({}));
Removes every _
assignment .
So
import _forEach from 'lodash/fp/forEach';
const _ = {
forEach: _forEach
}
will be removed and replaced.
How to use
> npm i --save lodash
> npm i --save-dev babel-plugin-lodash-magic-import @babel/core @babel/preset-env
.babelrc
{
"plugins": ["lodash-magic-import"],
"presets": [["env", { "targets": { "node": true } }]],
}
if you want to use the lodash-magic-cache go for
{
"plugins": [["lodash-magic-import", { "cache": true }]],
"presets": [["env", { "targets": { "node": true } }]],
}
and make sure you've
npm i --save lodash-magic-cache
also check out eslint-plugin-lodash-magic-import.
How it differs from babel-plugin-lodash ?
It's much simpler.
We've got a lodash-magic-cache for CommonJS modules caching, and a eslint-plugin-lodash-magic-import for basic compatibility checks.
lodash-magic-import
is completely pointless with lodash-es
and prohibits usage of Seq and _.chain
methods, for the greater good 🎀.
Q&A
Feel free to ask some questions via Discord.
License
Licensed under MIT license, of course.