Skip to content

Conversation

@sudo-suhas
Copy link
Owner

Overview

This PR removes lodash as a runtime dependency by implementing lean, purpose-specific utility functions, resulting in a 39.8% bundle size reduction.

Bundle Size Improvement 📦

  • Before: 180,599 bytes (176 KiB)
  • After: 108,670 bytes (106 KiB)
  • Reduction: 71,929 bytes (70.2 KiB) - 39.8% smaller 🎉

Changes

Custom Utilities Implemented

Created eight lean utility functions in src/_/ directory:

  • isNil(value) - Null/undefined check
  • isEmpty(value) - Empty value check
  • has(object, key) - Own property check
  • hasIn(object, key) - Inherited property check
  • isString(value) - String type check
  • isObject(value) - Object type check
  • head(array) - Array first element
  • omit(object, keys) - Object key exclusion

Migration Details

  • Updated 93 lodash imports across src/ directory
  • Moved lodash from dependencies to devDependencies
  • Retained lodash for test files only
  • All utilities follow lean implementation philosophy (5-15 lines each)

Verification ✅

  • All 477 tests pass with 100% code coverage
  • Linting passes without errors
  • TypeScript definitions remain valid
  • No functionality regressions
  • Comprehensive test coverage for all new utilities

Impact

This change significantly reduces the bundle size for all elastic-builder users while maintaining full backward compatibility and test coverage.

Replace lodash with lean custom utility functions, reducing bundle
size by 39.8% (71,929 bytes). Implemented eight purpose-specific
utilities in src/_/ directory to handle null checks, type validation,
object manipulation, and collection operations.

Bundle Size Improvement:
- Before: 180,599 bytes (176 KiB)
- After: 108,670 bytes (106 KiB)
- Reduction: 71,929 bytes (39.8%)

Custom Utilities Implemented:
- isNil(value) - Null/undefined check
- isEmpty(value) - Empty value check
- has(object, key) - Own property check
- hasIn(object, key) - Inherited property check
- isString(value) - String type check
- isObject(value) - Object type check
- head(array) - Array first element
- omit(object, keys) - Object key exclusion

Implementation Details:
- Updated 93 lodash imports across src/ directory
- Replaced lodash calls with _.functionName() pattern
- Moved lodash from dependencies to devDependencies
- Maintained for test files only
- All 477 tests pass with 100% coverage
- No functionality regressions
- TypeScript definitions remain valid
@sudo-suhas sudo-suhas merged commit 377e727 into master Nov 24, 2025
8 checks passed
@sudo-suhas sudo-suhas deleted the feat/remove-lodash-dependency branch November 24, 2025 04:36
@github-actions
Copy link

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant