Uh oh!
There was an error while loading. Please reload this page.
Replace lodash with native JS equivalents - #522
Conversation
Removes lodash (and @types/lodash) as a dependency. All usages are replaced with native ES2020 equivalents: optional chaining, Array methods, Object.entries/spread, and typeof checks. A shared isPlainObject helper is extracted to src/utils/objectutils.js.
| ].forEach((name) => { | ||
| exports[name] = function (spec, config) { | ||
| const mware = require("./" + _.kebabCase(name))(spec, config); | ||
| const mware = require("./" + name)(spec, config); |
There was a problem hiding this comment.
All names in the array are unchanged when passed through kebabCase.
| ); | ||
| } | ||
| module.exports = { isPlainObject }; |
There was a problem hiding this comment.
Can this be done in Typescript instead?
bkendall
commented
Feb 26, 2026
I've slowly tilted at this similarly before - honestly, a nice PR :) Looks like something will need adjustment for the license check, but this is great! |
Replaces the CommonJS module with a typed ES module export. Adds a `val is Record<string, unknown>` type predicate so callers get proper type narrowing when using `isPlainObject`.
Frank3K
commented
Feb 28, 2026
Thanks! I've added the license in 5a1c257. |
Frank3K
commented
Feb 28, 2026
Created #524. |
bkendall
commented
Mar 19, 2026
Sorry it took me so long to come back to this. It looks good. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Description
Removes
lodash(and@types/lodash) as a dependency. All usages are replaced with native ES2020 equivalents: optional chaining, Array methods, Object.entries/spread, and typeof checks. A sharedisPlainObjecthelper is extracted tosrc/utils/objectutils.js.Why
Lodash was a sensible utility belt in the Node.js 4.x era, but the language has long since caught up. Every lodash function used in this codebase now has a direct, readable native equivalent available in Node 20+ (which is already the minimum required by our engines field).
Reasons to drop it:
What changed
All lodash calls replaced with native equivalents across all files.
A shared
isPlainObjecthelper is extracted tosrc/utils/objectutils.jsto avoid duplication betweensrc/responder.jsandsrc/loaders/config-file.js.Bundle size
Lodash itself remains in
node_modulesas a transitive dependency via glob-slasher, so the production install footprint is unchanged for now. I'm planning on creating a separate PR to replace glob-slasher, which is unmaintained for about 12 years, also to take a second look at #249.@types/lodashis fully removed.Verification
Tests are passing.