Skip to content

CON-2075: replace merge-deep with deepmerge#145

Open
PavelLoparev wants to merge 3 commits intomasterfrom
CON-2075-replace-merge-deep-with-deepmerge
Open

CON-2075: replace merge-deep with deepmerge#145
PavelLoparev wants to merge 3 commits intomasterfrom
CON-2075-replace-merge-deep-with-deepmerge

Conversation

@PavelLoparev
Copy link
Copy Markdown
Contributor

@PavelLoparev PavelLoparev commented Apr 17, 2026

Summary

  • Swap unmaintained merge-deep@3.0.3 for deepmerge@^4.3.1 (CON-2075, #144)
  • Drops 15 transitive CommonJS micro-packages from package-lock.json (merge-deep, arr-union, clone-deep, kind-of + deps); adds ~4 KB, zero-dep, ESM-friendly deepmerge with built-in TS types
  • Preserves ordered-unique-concat (union) array semantics via a custom arrayMerge option so existing callers see zero behavior change
  • Adds test/base-api-merge.spec.ts with 19 characterization tests (13 library-level + 6 SmartlingBaseApi integration) that pin the deep-merge contract across the swap

Why array semantics matter

merge-deep delegates array handling to arr-union, which de-duplicates while preserving order ([1,2,3] + [2,3,4] → [1,2,3,4]). deepmerge's default is plain concat ([1,2,3,2,3,4]). The custom arrayMerge in mergeOptions reproduces the old union behavior exactly, so any caller that passed header/option arrays and relied on dedup stays correct.

Test plan

  • New characterization tests green on old merge-deep (before swap)
  • Same tests green on new deepmerge (after swap) — proves parity
  • Full npm test (lint + build + coverage) — 234 passing, 0 failures
  • npm run pretest — no new lint errors (3 pre-existing warnings on sensitiveReplacer unchanged)

🤖 Generated with Claude Code

Drops the unmaintained merge-deep dependency (along with 15 transitive
CommonJS micro-packages) in favor of deepmerge — a zero-dependency,
ESM-friendly library with built-in TypeScript types.

A custom arrayMerge option preserves the ordered-unique-concat (union)
semantics that merge-deep exposed via arr-union, so callers that rely on
the old array handling see no behavior change. New characterization
tests in test/base-api-merge.spec.ts pin the deep-merge contract
(library-level + SmartlingBaseApi integration) and all 234 tests pass
on both the old and new dependency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PavelLoparev PavelLoparev requested a review from dimitrystd April 17, 2026 16:06
PavelLoparev and others added 2 commits April 17, 2026 19:25
…verage

Move the deep-merge helper out of base-api.ts into api/base/merge.ts so it
no longer looks like a public symbol on the main API surface. Tighten its
signature from any to a generic T & U to drop the eslint-disable.

Strip ticket-id and migration framing from comments so they stay useful
after the merge-deep swap is ancient history.

Extend test coverage with null/undefined source values, array vs object
type mismatches, reference-based array-of-objects dedup, two prototype
pollution cases, and an integration test that flows array-valued headers
through setOptions to prove the arrayMerge option is reached in production.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…erge

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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