0.2.0 • Published 3 years ago
unplugin-lodash-to-lodashes v0.2.0
unplugin-lodash-to-lodashes
Replace lodash with lodash-es, support use in vite, webpack
Installation
npm i unplugin-lodash-to-lodashes// vite.config.ts
import lodashToLodashes from 'unplugin-lodash-to-lodashes/vite';
export default defineConfig({
plugins: [
lodashToLodashes({ /* options */ }),
],
})const lodashToLodashes = require('unplugin-lodash-to-lodashes/webpack');
// webpack.config.js
module.exports = {
/* ... */
plugins: [
lodashToLodashes({ /* options */ }),
],
}Usage
It will automatically transform:
import isNull from 'lodash/isNull'
const isNumber = require('lodash/isNumber');
// ↓ ↓ ↓ ↓ ↓ ↓
import isNull from 'lodash-es/isNull'
const isNumber = require('lodash-es/isNumber.js').default;Options
lib
type Lib = stringdefault: lodash-es
// lib: '../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es'
import isNull from 'lodash/isNull'
const isNumber = require('lodash/isNumber');
// ↓ ↓ ↓ ↓ ↓ ↓
import isNull from '../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNull'
const isNumber = require('../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNumber.js').default;