chore(deps): replace lodash with native JS equivalents#2070
Open
roli-lpci wants to merge 2 commits intojust-jeb:masterfrom
Open
chore(deps): replace lodash with native JS equivalents#2070roli-lpci wants to merge 2 commits intojust-jeb:masterfrom
roli-lpci wants to merge 2 commits intojust-jeb:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
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, andremove.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:
mergeWithdeepMergeWithwith customizer callbackmerge-schemes.ts,jest-configuration-builder.tsmergedeepMerge(recursive, plain-object aware)webpack-config-merger.tsgetgetByPathwith dot/bracket path supportcustom-webpack-builder.tspickObject.fromEntries+filterdefault-config.resolver.tsisArrayArray.isArrayjest-configuration-builder.tsdifferenceWithArray.filter+somewebpack-config-merger.tskeyByfor...ofloop building a recordwebpack-config-merger.tsremoveArray.filter(reassignment)custom-esbuild-schema.spec.tslodashand@types/lodashremoved from rootpackage.json,packages/jest/package.json, andpackages/custom-webpack/package.json.All existing unit tests pass unchanged (33 tests across jest + custom-webpack packages).
Does this PR introduce a breaking change?
Other information
The deep merge helpers (
deepMergeWithin merge-schemes.ts and jest-configuration-builder.ts,deepMergein 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.