Skip to content

chore(deps): replace lodash with native JS equivalents#2070

Open
roli-lpci wants to merge 2 commits intojust-jeb:masterfrom
roli-lpci:chore/replace-lodash-with-native
Open

chore(deps): replace lodash with native JS equivalents#2070
roli-lpci wants to merge 2 commits intojust-jeb:masterfrom
roli-lpci:chore/replace-lodash-with-native

Conversation

@roli-lpci
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The project depends on lodash (and @types/lodash) across three packages (jest, custom-webpack, root) for a handful of utility functions: mergeWith, merge, get, pick, isArray, differenceWith, keyBy, and remove.

Lodash is a CJS-only dependency that hasn't been updated in four years, increases bundle size due to lack of tree-shaking support, and can cause optimization bailouts.

Issue Number: #1904

What is the new behavior?

All lodash functions replaced with native JS equivalents:

lodash function Native replacement Location
mergeWith Custom deepMergeWith with customizer callback merge-schemes.ts, jest-configuration-builder.ts
merge Custom deepMerge (recursive, plain-object aware) webpack-config-merger.ts
get Custom getByPath with dot/bracket path support custom-webpack-builder.ts
pick Object.fromEntries + filter default-config.resolver.ts
isArray Array.isArray jest-configuration-builder.ts
differenceWith Array.filter + some webpack-config-merger.ts
keyBy for...of loop building a record webpack-config-merger.ts
remove Array.filter (reassignment) custom-esbuild-schema.spec.ts

lodash and @types/lodash removed from root package.json, packages/jest/package.json, and packages/custom-webpack/package.json.

All existing unit tests pass unchanged (33 tests across jest + custom-webpack packages).

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The deep merge helpers (deepMergeWith in merge-schemes.ts and jest-configuration-builder.ts, deepMerge in webpack-config-merger.ts) are intentionally inlined in each file rather than shared, since they have slightly different signatures and the merge-schemes.ts build script runs outside the package dependency graph.

The schema merging __REPLACE__ / __DELETE__ marker behavior is preserved exactly as documented in AGENTS.md.

roli-lpci and others added 2 commits February 26, 2026 01:12
Replace all lodash usage across the monorepo with native JavaScript,
eliminating lodash and @types/lodash as dependencies. Closes just-jeb#1904.

Replacements:
- mergeWith → custom deepMergeWith (merge-schemes.ts, jest-configuration-builder.ts)
- merge → custom deepMerge (webpack-config-merger.ts)
- get → custom getByPath with dot/bracket notation (custom-webpack-builder.ts)
- pick → Object.fromEntries + filter (default-config.resolver.ts)
- isArray → Array.isArray (jest-configuration-builder.ts)
- differenceWith → Array.filter + some (webpack-config-merger.ts)
- keyBy → for...of loop (webpack-config-merger.ts)
- remove → Array.filter (custom-esbuild-schema.spec.ts)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous comment incorrectly stated arrays are replaced "to match
lodash.merge behavior." lodash.merge actually merges arrays by index.
The native deepMerge intentionally replaces arrays entirely, which is
the correct behavior for webpack plugin options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant