Skip to content

Switch from lodash to es-toolkit for esm support#133

Open
cuzzlor wants to merge 1 commit intomainfrom
use-es-toolkit-not-lodash-for-esm-support
Open

Switch from lodash to es-toolkit for esm support#133
cuzzlor wants to merge 1 commit intomainfrom
use-es-toolkit-not-lodash-for-esm-support

Conversation

@cuzzlor
Copy link
Copy Markdown
Collaborator

@cuzzlor cuzzlor commented Apr 19, 2026

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

  • Bumping to the next major version, since consumers will no longer get "full lodash" installed automatically via the peer dep.
  • Keeping use of es-toolkit as a peer dep vs hard dep, since:
    • we don't want to force version numbers or constantly update this package past vulnerabilities
    • we expect ESM consumers may prefer opting in to control and use the version of es-toolkit at the consumer level (no loss)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lodash imports with es-toolkit/compat in the omit-related winston formats.
  • Swap the peer dependency from lodash to es-toolkit and remove @types/lodash.
  • Update README to reference es-toolkit omit 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.

Comment thread src/omit-nil-format.ts
Comment thread README.md
Comment thread src/omit-format.ts
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.

3 participants