npm.io
0.2.0 • Published 3 years ago

unplugin-lodash-to-lodashes

Licence
ISC
Version
0.2.0
Deps
2
Size
8 kB
Vulns
0
Weekly
0

unplugin-lodash-to-lodashes

npm package npm downloads npm downloads package size

Replace lodash with lodash-es, support use in vite, webpack

Installation

npm i unplugin-lodash-to-lodashes
Vite
// vite.config.ts
import lodashToLodashes from 'unplugin-lodash-to-lodashes/vite';

export default defineConfig({
  plugins: [
    lodashToLodashes({ /* options */ }),
  ],
})


Webpack
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 = string

default: 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;

Keywords