Vite Plugin: es-toolkit

raw JSON →
1.1.0 verified Mon Apr 27 auth: no javascript

A Vite plugin that automatically replaces Lodash imports with es-toolkit equivalents during the build process. Current stable version is 1.1.0, maintained actively with support for Vite 2.3 to 8.x. Key differentiators: no manual code changes required, supports all import patterns (named, default, star, deep paths including .js extensions), and handles renaming. Alternative to manual migration scripts; integrates seamlessly into existing Vite projects using Lodash.

error Error: Cannot find module 'vite-plugin-es-toolkit'
cause Package not installed or not in node_modules.
fix
Run npm install vite-plugin-es-toolkit --save-dev
error TypeError: vitePluginEsToolkit is not a function
cause Using the plugin incorrectly as a configuration object instead of calling it.
fix
Use esToolkitPlugin() (with parentheses) in the plugins array.
error Error: The plugin does not support CommonJS imports. Use ESM import instead.
cause Using require() to import the plugin itself or trying to transform require() calls.
fix
Use import esToolkitPlugin from 'vite-plugin-es-toolkit' and ensure all Lodash imports are ESM.
breaking Version 1.0.0 requires Vite >=5.0.0. Older Vite versions are not supported.
fix Upgrade to Vite 5+ or use vite-plugin-es-toolkit@0.x with Vite 4.
breaking The plugin only works with ESM imports. Any CommonJS require() of Lodash will not be transformed.
fix Convert require() to import statements in your source files.
gotcha The plugin assumes es-toolkit has an equivalent for every Lodash function used. If a function is missing, your build may break or silently keep the original import.
fix Check es-toolkit's coverage; consider fallback lodash imports or manual replacement for missing functions.
deprecated Support for Vite 5 is deprecated; future versions will require Vite 6+.
fix Upgrade to Vite 6 or later to ensure compatibility.
npm install vite-plugin-es-toolkit
yarn add vite-plugin-es-toolkit
pnpm add vite-plugin-es-toolkit

Installs and configures the plugin to replace Lodash with es-toolkit in a Vite project.

// vite.config.js
import { defineConfig } from 'vite';
import esToolkitPlugin from 'vite-plugin-es-toolkit';

export default defineConfig({
  plugins: [
    esToolkitPlugin(),
  ],
});