# babel-plugin-lodash

> Modular Lodash builds without the hassle.

Latest version **3.3.4** (published 2018-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-lodash
pnpm add babel-plugin-lodash
yarn add babel-plugin-lodash
bun add babel-plugin-lodash
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.4 |
| Published | 2018-06-11 |
| First published | 2015-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1946 |
| Author | Graeme Yeates |
| Maintainers | jdalton, mathias |
| Keywords | babel-plugin, cherry-pick, lodash, modules |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-lodash
- Repository: https://github.com/lodash/babel-plugin-lodash
- Homepage: https://github.com/lodash/babel-plugin-lodash#readme
- Issues: https://github.com/lodash/babel-plugin-lodash/issues
- npm.io page: https://npm.io/package/babel-plugin-lodash

## Dependencies (5)

- [glob](https://npm.io/package/glob.md) ^7.1.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.0.0-beta.49
- [require-package-name](https://npm.io/package/require-package-name.md) ^2.0.1
- [@babel/helper-module-imports](https://npm.io/package/@babel/helper-module-imports.md) ^7.0.0-beta.49

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 3.3.4 (latest) — 2018-06-11
- 3.3.3 — 2018-06-06
- 3.3.2 — 2017-11-12
- 3.3.1 — 2017-11-12
- 3.3.0 — 2017-11-12
- 3.2.11 — 2016-12-16
- 3.2.10 — 2016-11-22
- 3.2.9 — 2016-09-19
- 3.2.8 — 2016-08-16
- 3.2.7 — 2016-08-15
- 3.2.6 — 2016-07-22
- 3.2.5 — 2016-07-19
- 3.2.4 — 2016-07-17
- 3.2.3 — 2016-07-15
- 3.2.2 — 2016-07-13
- … 29 more at https://npm.io/package/babel-plugin-lodash/versions

## README

# babel-plugin-lodash

A simple transform to cherry-pick Lodash modules so you don’t have to.

Combine with [lodash-webpack-plugin](https://www.npmjs.com/package/lodash-webpack-plugin)
for even smaller cherry-picked builds!

## Install

```shell
$ npm i --save lodash
$ npm i --save-dev babel-plugin-lodash @babel/cli @babel/preset-env
```

## Example

Transforms
```js
import _ from 'lodash'
import { add } from 'lodash/fp'

const addOne = add(1)
_.map([1, 2, 3], addOne)
```

roughly to
```js
import _add from 'lodash/fp/add'
import _map from 'lodash/map'

const addOne = _add(1)
_map([1, 2, 3], addOne)
```

## Usage

###### .babelrc
```json
{
  "plugins": ["lodash"],
  "presets": [["@babel/env", { "targets": { "node": 6 } }]]
}
```

Set plugin options using an array of `[pluginName, optionsObject]`.
```json
{
  "plugins": [["lodash", { "id": "lodash-compat", "cwd": "some/path" }]],
  "presets": [["@babel/env", { "targets": { "node": 6 } }]]
}
```

The `options.id` can be an array of ids.
```json
{
  "plugins": [["lodash", { "id": ["async", "lodash-bound"] }]],
  "presets": [["@babel/env", { "targets": { "node": 6 } }]]
}
```

###### Babel CLI
```sh
$ babel --plugins lodash --presets @babel/es2015 script.js
```

###### Babel API
```js
require('babel-core').transform('code', {
  'plugins': ['lodash'],
  'presets': [['@babel/env', { 'targets': { 'node': 6 } }]]
})
```

###### webpack.config.js
```js
'module': {
  'loaders': [{
    'loader': 'babel-loader',
    'test': /\.js$/,
    'exclude': /node_modules/,
    'query': {
      'plugins': ['lodash'],
      'presets': [['@babel/env', { 'targets': { 'node': 6 } }]]
    }
  }]
}
```

## FAQ

> Can this plugin produce ES2015 imports rather than CommonJS imports?

This plugin produces ES2015 imports by default. The
[`@babel/plugin-transform-modules-commonjs`](https://www.npmjs.com/package/@babel/plugin-transform-modules-commonjs)
plugin, which is included in the [`@babel/preset-es2015`](https://www.npmjs.com/package/@babel/preset-es2015)
preset, transforms ES2015 `import` statements to CommonJS. Omit it from your
preset to preserve ES2015 style imports.

## Limitations

* You must use ES2015 imports to load Lodash
* Babel < 6 & Node.js < 4 aren’t supported
* Chain sequences aren’t supported. See [this blog post](https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba) for alternatives.
* Modularized [method packages](https://www.npmjs.com/browse/keyword/lodash-modularized) aren’t supported

---
_Source: https://npm.io/package/babel-plugin-lodash · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
