Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-plugin-lodash

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-lodash

Similar babel-plugin-lodash for esbuild

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

esbuild-plugin-lodash

npm

This plugin is for esbuild, similar to how babel-plugin-lodash works for babel.

Thoughts

The non-es lodash package is not tree-shakeable, this plugin is only for direct import workaround.

For better coding practices, you can use instead lodash-es directly or strictly import the required lodash function manually.

Installation

npm install --save-dev esbuild-plugin-lodash

Usage

Define plugin in the plugins section of esbuild config like this:

const esbuild = require('esbuild');
const lodashTransformer = require('esbuild-plugin-lodash');

esbuild.build({
  // ...
  plugins: [
    lodashTransformer(),
  ],
})

Result

Having this input file:

import { get, isEmpty }  from 'lodash';

const something = {};

get(something);
isEmpty(something);

It will output this following file content:

import get  from 'lodash/get';
import isEmpty  from 'lodash/isEmpty';

const something = {};

get(something);
isEmpty(something);

Options

You can specify your own filter as per according to esbuild docs here.

You can specify outLodashPackage which by default is lodash. An example of this would be specifying calls to be rewritten to use lodash-es.

Keywords

FAQs

Package last updated on 22 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc