Skip to content

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

License

Notifications You must be signed in to change notification settings

digitalmaas/esbuild-plugin-lodash

 
 

Repository files navigation

Esbuild Lodash Transform Plugin

NPM version NPM downloads digitalmaas

An esbuild plugin that transforms lodash imports.

Installation

npm install @digitalmaas/esbuild-plugin-lodash --save-dev

Setup

import esbuild from 'esbuild'
import { transformLodashPlugin } from '@digitalmaas/esbuild-plugin-lodash'

await esbuild.build({
  /* all of your config */,
  plugins: [
    transformLodashPlugin({ /* options */ }),
  ]
})

Usage

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.js'
import isEmpty from 'lodash/isEmpty.js'

const something = {}

get(something)
isEmpty(something)

Options

filter: RegExp

You can specify your own filter as per according to esbuild docs here. Defaults to /\.(js|cjs|mjs|ts|cts|mts|tsx)$/.

namespace: string

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

appendJsExtension: boolean

If true, the plugin will append .js to the end of CommonJS lodash imports. Defaults to true.

outputLodashPackage: string

Specifies lodash package to use in output. Can be either lodash or lodash-es. Defaults to lodash.

More Info

License

MIT License.

Complete license in ./LICENSE file.

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 94.9%
  • Shell 5.1%