npm install @digitalmaas/esbuild-plugin-lodash --save-dev
import esbuild from 'esbuild'
import { transformLodashPlugin } from '@digitalmaas/esbuild-plugin-lodash'
await esbuild.build({
/* all of your config */,
plugins: [
transformLodashPlugin({ /* options */ }),
]
})
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)
You can specify your own filter
as per according to esbuild docs here. Defaults to /\.(js|cjs|mjs|ts|cts|mts|tsx)$/
.
You can specify your own namespace
as per according to esbuild docs here.
If true
, the plugin will append .js
to the end of CommonJS lodash imports. Defaults to true
.
Specifies lodash package to use in output. Can be either lodash
or lodash-es
. Defaults to lodash
.
MIT License.
Complete license in ./LICENSE file.