Skip to content

Replace lodash with es-toolkit#1562

Merged
smorimoto merged 1 commit intomainfrom
es-toolkit
Dec 31, 2025
Merged

Replace lodash with es-toolkit#1562
smorimoto merged 1 commit intomainfrom
es-toolkit

Conversation

@smorimoto
Copy link
Copy Markdown
Collaborator

@smorimoto smorimoto commented Dec 21, 2025

Note

Replaces lodash with es-toolkit throughout the codebase and removes custom helpers in favor of native/ES Toolkit utilities.

  • Core refactor: swap lodash usages for es-toolkit/es-toolkit/compat (compact, merge, uniq, omit, camelCase, get, startCase, upperFirst), replace objectAssign with Object.assign, and remove internal-case
  • New compatibility shim: add util/lodash-compat and export as _ to templates to preserve template compatibility
  • ID generation: remove nanoid and use crypto.randomUUID() (util/id.ts)
  • Functional adjustments: minor logic/iteration rewrites (e.g., Object.entries loops, compact checks, content-type handling), updated description formatting, and safer null/empty checks
  • Template/config updates: internalCase now camelCase; various schema parsers/routers/walkers updated to es-toolkit equivalents
  • Tests and stability: update snapshots (route/type outputs, descriptions, versions), add deterministic schema sorting in tests/utils.ts, increase vitest timeout
  • Tooling/deps: add es-toolkit; remove lodash, @types/lodash, nanoid; bump esbuild/rollup/vite and related transitive deps

Written by Cursor Bugbot for commit 0da40e4. This will update automatically on new commits. Configure here.

@smorimoto smorimoto self-assigned this Dec 21, 2025
@smorimoto smorimoto added the enhancement New feature or request label Dec 21, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 21, 2025

⚠️ No Changeset found

Latest commit: 0da40e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread src/util/request.ts Outdated
Comment thread src/configuration.ts
@smorimoto smorimoto force-pushed the es-toolkit branch 2 times, most recently from b7369c3 to 0d20549 Compare December 22, 2025 07:39
Signed-off-by: Sora Morimoto <sora@morimoto.io>
@smorimoto smorimoto merged commit d4b522e into main Dec 31, 2025
13 checks passed
@smorimoto smorimoto deleted the es-toolkit branch December 31, 2025 13:56
smorimoto added a commit that referenced this pull request Feb 14, 2026
…peConstructs

The lodash-to-es-toolkit migration (#1562) replaced the objectAssign
utility with Object.assign, which silently broke two behaviours:

1. Function-form arguments were no longer invoked with the current
   struct — they were merged as raw function objects instead.
2. Deep merging was lost — partially overriding a nested key like
   primitiveTypes.string would clobber sibling defaults ($default,
   date-time, etc.) and cause runtime crashes.

Restore objectAssign rewritten atop es-toolkit's merge, and widen the
public types for codeGenConstructs/primitiveTypeConstructs to accept
both function and plain-object forms.

Closes #1614
smorimoto added a commit that referenced this pull request Feb 14, 2026
…peConstructs

The lodash-to-es-toolkit migration (#1562) replaced the objectAssign
utility with Object.assign, which silently broke two behaviours:

1. Function-form arguments were no longer invoked with the current
   struct — they were merged as raw function objects instead.
2. Deep merging was lost — partially overriding a nested key like
   primitiveTypes.string would clobber sibling defaults ($default,
   date-time, etc.) and cause runtime crashes.

Restore objectAssign rewritten atop es-toolkit's merge, and widen the
public types for codeGenConstructs/primitiveTypeConstructs to accept
both function and plain-object forms.

Closes #1614
smorimoto added a commit that referenced this pull request Feb 14, 2026
…peConstructs (#1620)

* Restore objectAssign utility to fix codeGenConstructs and primitiveTypeConstructs

The lodash-to-es-toolkit migration (#1562) replaced the objectAssign
utility with Object.assign, which silently broke two behaviours:

1. Function-form arguments were no longer invoked with the current
   struct — they were merged as raw function objects instead.
2. Deep merging was lost — partially overriding a nested key like
   primitiveTypes.string would clobber sibling defaults ($default,
   date-time, etc.) and cause runtime crashes.

Restore objectAssign rewritten atop es-toolkit's merge, and widen the
public types for codeGenConstructs/primitiveTypeConstructs to accept
both function and plain-object forms.

Closes #1614

* Guard against nullish updater return in objectAssign

When a function-form updater returns undefined or null (e.g. a
callback that mutates in place without an explicit return),
Object.entries(update) would throw. Add a nullish check after
invoking the updater so these cases are treated as no-ops,
matching the original lodash-based behaviour.

* Use PartialDeep for codeGenConstructs and primitiveTypeConstructs options

Partial<T> is shallow, so nested override objects still required full
nested shapes (e.g. Keyword needed every keyword, string needed $default).
Since objectAssign deep-merges via es-toolkit's merge(), the types should
use PartialDeep from type-fest to match the runtime behavior and allow
common partial nested overrides without casting to any.
@github-actions github-actions Bot mentioned this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant