An esbuild plugin (v1.2.0) that rewrites named imports from 'lodash' to direct module imports like 'lodash/get' to enable tree-shaking. Released on npm, with active maintenance. Similar to babel-plugin-lodash but for esbuild, offering a filter option and support for custom output package (e.g., lodash-es). Distinct from alternatives like manual import optimization or using lodash-es directly. Works with both CJS and ESM, handles quotes, and fixes edge cases like 'lodash/last' imports.
npm install esbuild-plugin-lodashVerified import paths — ran on the pinned version, not inferred.
Shows how to use the plugin in an esbuild build, including options for filter and output package.
Use named imports only, or manually rewrite to path-based imports.
Use direct imports per method, or avoid lodash chaining.
Import from 'lodash-es' instead and use esbuild's built-in tree-shaking.
Ensure esbuild version matches peer dependency range (check package.json). For esbuild >=0.17, consider updating the plugin.
Use require('esbuild-plugin-lodash').default or import the ESM version.Use lodash v4.x or set outLodashPackage to 'lodash-es'.