Voltar ao ranking

lodash/babel-plugin-lodash

JavaScript

Modular Lodash builds without the hassle.

lodashbabel
Crescimento de estrelas
Estrelas
1.9k
Forks
95
Crescimento semanal
Issues
15
5001k1.5k
jan. de 2023mar. de 2024mai. de 2025jul. de 2026
Artefatosnpmnpm install babel-plugin-lodash
README

babel-plugin-lodash

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

Combine with lodash-webpack-plugin for even smaller cherry-picked builds!

Install

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

Example

Transforms

import _ from 'lodash'
import { add } from 'lodash/fp'

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

roughly to

import _add from 'lodash/fp/add'
import _map from 'lodash/map'

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

Usage

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

Set plugin options using an array of [pluginName, optionsObject].

{
  "plugins": [["lodash", { "id": "lodash-compat", "cwd": "some/path" }]],
  "presets": [["@babel/env", { "targets": { "node": 6 } }]]
}

The options.id can be an array of ids.

{
  "plugins": [["lodash", { "id": ["async", "lodash-bound"] }]],
  "presets": [["@babel/env", { "targets": { "node": 6 } }]]
}
Babel CLI
$ babel --plugins lodash --presets @babel/es2015 script.js
Babel API
require('babel-core').transform('code', {
  'plugins': ['lodash'],
  'presets': [['@babel/env', { 'targets': { 'node': 6 } }]]
})
webpack.config.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 plugin, which is included in the @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 for alternatives.
  • Modularized method packages aren’t supported
Repositórios relacionados
lodash/lodash

A modern JavaScript utility library delivering modularity, performance, & extras.

JavaScriptnpmOtherlodashutilities
lodash.com
61.2k7.2k
typicode/lowdb

Simple and fast JSON database

JavaScriptnpmMIT Licensedatabaselodash
22.6k964
samber/lo

💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)

GoGo ModulesMIT Licenselodashgolang
lo.samber.dev
21.4k944
you-dont-need/You-Dont-Need-Lodash-Underscore

List of JavaScript methods which you can use natively + ESLint Plugin

JavaScriptnpmMIT Licenselodashunderscore
19.1k814
duke-git/lancet

A comprehensive, efficient, and reusable util function library of Go.

GoGo ModulesMIT Licensegogolang
golancet.cn/en/
5.3k520
dflemstr/rq

Record Query - A tool for doing record analysis and transformation

Rustcrates.ioApache License 2.0rustprotobuf
2.3k59
NathanWalker/angular-seed-advanced

Advanced Angular seed project with support for ngrx/store, ngrx/effects, ngx-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.

TypeScriptnpmMIT Licenseangularnativescript
2.2k432
selfrefactor/rambda

Typescript focused FP library similar to Remeda and Ramda

JavaScriptnpmMIT Licensefpramda
selfrefactor.github.io/rambda/
1.8k89
dgilland/pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.

PythonPyPIMIT Licenselodashutility
pydash.readthedocs.io
1.4k99
graphql-kit/graphql-lodash

🛠 Data manipulation for GraphQL queries with lodash syntax

TypeScriptnpmMIT Licensegraphqlfunctional-programming
apis.guru/graphql-lodash/
1.2k48
APIs-guru/graphql-lodash

🛠 Data manipulation for GraphQL queries with lodash syntax

TypeScriptnpmMIT Licensegraphqlfunctional-programming
apis.guru/graphql-lodash/
1.2k47
lodash/lodash-webpack-plugin

Smaller modular Lodash builds.

JavaScriptnpmOtherlodashwebpack
1.2k59