v2 beta - switch from lodash to es-toolkit and add features#133
Merged
v2 beta - switch from lodash to es-toolkit and add features#133
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes broken ESM consumption by replacing lodash (CJS-only) imports with es-toolkit/compat (dual ESM+CJS), and bumps the package major version to reflect the peer dependency change.
Changes:
- Replace
lodashimports withes-toolkit/compatin the omit-related winston formats. - Swap the peer dependency from
lodashtoes-toolkitand remove@types/lodash. - Update README to reference
es-toolkitomit docs and bump package major version.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/omit-nil-format.ts | Switch isNil/omitBy import to es-toolkit/compat for ESM compatibility. |
| src/omit-format.ts | Switch omit import to es-toolkit/compat for ESM compatibility. |
| package.json | Major version bump; peer dep swap from lodash to es-toolkit; remove @types/lodash. |
| package-lock.json | Reflect peer dep swap and lockfile package entries. |
| README.md | Update docs link/wording to reference es-toolkit compat omit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mderriey
approved these changes
Apr 19, 2026
vatsalyagoel
approved these changes
Apr 20, 2026
mderriey
approved these changes
Apr 20, 2026
c211d39 to
76f7924
Compare
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.
1 Problem: ESM output does not work, only CJS works
The prior PR adding dual ESM + CJS output does not actually work for ESM due to the continued use of CJS only lodash.
Lodash does not have a single dual output library, lodash-es is ESM only.
We cannot just replace lodash with a simple function because the omit-by-dot-notation keys functionality is important and is used for omit logging config.
Solution
Swap to es-toolkit which provides modern dual ESM + CJS output with 100% lodash compatibility.
Implementation notes
2 Problem: formats (e.g. for
omitPathsapplied to console transport)... however OTEL does not receive log data at the transport level, so this would not apply for OTEL received log data
omitPathsand other format-based options apply equally to all log output regardless of transport3 Add functionality we normally use:
redactPaths/redactedValueoptions replace values at dot-notation paths across every transport. Also available as the standaloneredactFormat, and theredactValues/redactValuesWithhelpers for direct use.flatten/flattenReplaceroptions serialise every top-level value on the log info to a JSON string, producing a flat{ key: string }shape suited to OTEL + Azure Log Analytics and other scalar-only aggregators..serializeErrorFormat. It walks the whole info object — including nested objects and arrays — replacing everyErrorwith a plain object that carriesname,messageandstack.auditlog level by defaultcreateLoggeris now generic over the level map. When you passloggerOptions.levels, the returned logger's method signatures narrow to your level keys (logger.fatal(...)becomes valid,logger.auditbecomes a type error).