es-toolkit-webpack-plugin
v0.2.0
Published
Webpack 5 plugin for replacing lodash with es-toolkit
Downloads
4
Readme
Webpack 5 plugin for replacing lodash with es-toolkit, inspired by vite-plugin-es-toolkit.
[!NOTE] Most of the time, using this plugin can reduce the size of the bundle (especially when using ES modules). However, it may also increase the size of the bundle in some cases. Please test it in your project before using it in production.
Usage
npm install es-toolkit
npm install es-toolkit-webpack-plugin --save-dev
// webpack.config.js
const WebpackEsToolkitPlugin = require("es-toolkit-webpack-plugin");
module.exports = {
plugins: [new WebpackEsToolkitPlugin.default({
excludes: ["isEqual"],
})],
};
// webpack.config.mjs
import WebpackEsToolkitPlugin from "es-toolkit-webpack-plugin";
export default {
plugins: [new WebpackEsToolkitPlugin({
excludes: ["isEqual"],
})],
};
Options (Optional)
excludes
: An array of lodash methods that should not be replaced. Default:[]
.
Supported situations
// lodash
import _ from "lodash"; // supported
import { debounce, isEqual } from "lodash"; // supported
import { debounce as _debounce } from "lodash"; // supported
import lodashIsEqual from "lodash/isEqual.js"; // supported
import _, { debounce, isEqual } from "lodash"; // supported
const _ = require("lodash"); // supported
const isEqual = require("lodash/isEqual.js"); // supported
// lodash-es
import _ from "lodash-es"; // supported
import { debounce, isEqual } from "lodash-es"; // supported
import { debounce as _debounce } from "lodash-es"; // supported
import lodashIsEqual from "lodash-es/isEqual.js"; // supported
import _, { debounce, isEqual } from "lodash-es"; // supported
const _ = require("lodash-es"); // supported
const isEqual = require("lodash-es/isEqual.js"); // supported
// lodash.*
import lodashIsEqual from "lodash.isequal"; // supported
const lodashIsEqual = require("lodash.isequal"); // supported
License
MIT