1.0.0 • Published 1 year ago

@digitalmaas/esbuild-plugin-lodash v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.

1.0.0

1 year ago