migrate-to-lodash-es
v1.0.1
Published
CLI tool to migrate JavaScript/TypeScript imports from lodash to lodash-es automatically.
Maintainers
Readme
migrate-to-lodash-es
Easily migrate your JavaScript/TypeScript imports from lodash to lodash-es in seconds.
This CLI tool scans your project files and rewrites:
// Before
import { isEmpty, omitBy, pickBy, without } from 'lodash'into:
// After
import isEmpty from 'lodash-es/isEmpty'
import omitBy from 'lodash-es/omitBy'
import pickBy from 'lodash-es/pickBy'
import without from 'lodash-es/without'✨ Features
- Recursively scans directories
- Works on
.js,.ts,.tsxfiles - Supports both named and single imports
- Can migrate entire projects or a single file
- Keeps all other code intact
📦 Installation
npm install -g migrate-to-lodash-es🚀 Usage
Migrate a whole project
migrate-to-lodash-es ./srcMigrate a single file
migrate-to-lodash-es src/pages/component/component.tsx💡 Example
Before
import { isEmpty, omitBy } from 'lodash'
import without from 'lodash'After
import isEmpty from 'lodash-es/isEmpty'
import omitBy from 'lodash-es/omitBy'
import without from 'lodash-es/without'⚙️ Options (coming soon)
--dry-run→ Show what would change without modifying files--backup→ Save.bakfiles before migration
📂 Supported File Types
.js.jsx.ts.tsx
🛠 How it works
The tool:
- Reads your file(s)
- Finds imports from
lodash - Converts them into individual ESM imports from
lodash-es - Writes the changes in place
📝 License
MIT © Petros Demetriou
