All Projects → lodash → Babel Plugin Lodash

lodash / Babel Plugin Lodash

Licence: other
Modular Lodash builds without the hassle.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Babel Plugin Lodash

Webpack Boilerplate
A minimal webpack 5 boilerplate with only Babel, SASS and lodash (optional) on board
Stars: ✭ 404 (-78.77%)
Mutual labels:  babel, lodash
Eslint Config Auto
Automatically configure ESLint based on project dependencies
Stars: ✭ 302 (-84.13%)
Mutual labels:  babel, lodash
Book
《现代化前端工程师权威指南》https://guoyongfeng.github.io/book/
Stars: ✭ 141 (-92.59%)
Mutual labels:  babel
Generator Phaser Plus
[🛑 DISCONTINUED] It has been a long journey but development of `generator-phaser-plus` is now over. I recommend you have a look and fork `yandeu/phaser-project-template` instead.
Stars: ✭ 148 (-92.22%)
Mutual labels:  babel
Breko Hub
Babel React Koa Hot Universal Boilerplate
Stars: ✭ 145 (-92.38%)
Mutual labels:  babel
Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (-92.59%)
Mutual labels:  babel
Koa Restful Boilerplate
Koa 2 RESTful API boilerplate
Stars: ✭ 146 (-92.33%)
Mutual labels:  babel
Rq
Record Query - A tool for doing record analysis and transformation
Stars: ✭ 1,808 (-4.99%)
Mutual labels:  lodash
Lighthouse Badges
🚦Generate badges (shields.io) based on Lighthouse performance.
Stars: ✭ 150 (-92.12%)
Mutual labels:  babel
Js Stack Boilerplate
Final boilerplate code of the JavaScript Stack from Scratch tutorial –
Stars: ✭ 145 (-92.38%)
Mutual labels:  babel
Rambdax
Extended version of Rambda
Stars: ✭ 148 (-92.22%)
Mutual labels:  lodash
React Starter Kit
完美使用 React, Redux, and React-Router!超好用的脚手架
Stars: ✭ 1,755 (-7.78%)
Mutual labels:  babel
Babel Plugin Transform Typescript Metadata
Babel plugin to emit decorator metadata like typescript compiler
Stars: ✭ 142 (-92.54%)
Mutual labels:  babel
Keepformac
keep for mac
Stars: ✭ 147 (-92.28%)
Mutual labels:  babel
Frr
The FRRouting Protocol Suite
Stars: ✭ 2,009 (+5.57%)
Mutual labels:  babel
Webpack Babel Multi Target Plugin
A Webpack plugin that works with Babel to allow differential loading - production deployment of ES2015 builds targeted to modern browsers, with an ES5 fallback for legacy browsers.
Stars: ✭ 150 (-92.12%)
Mutual labels:  babel
Kickup
🚚 Boilerplate for your perfect front-end environment (utilizing Gulp.js, Babel, and more)
Stars: ✭ 139 (-92.7%)
Mutual labels:  babel
Iceberg
Front-End Boilerplate built with React + Babel + Webpack + SASS
Stars: ✭ 144 (-92.43%)
Mutual labels:  babel
Swc
swc is a super-fast compiler written in rust; producing widely-supported javascript from modern standards and typescript.
Stars: ✭ 18,627 (+878.82%)
Mutual labels:  babel
Babel Plugin Webpack Alias
babel 6 plugin which allows to use webpack resolve options
Stars: ✭ 151 (-92.07%)
Mutual labels:  babel

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].