Skip to content

Replace narrow lodash usage with native equivalents #4874

Description

@drernie

Sub-task of #4869.

Why

21 import sites, all using cherry-picked subpaths (`lodash/foo`). Most are trivially replaceable with native ES or one-liners — eliminates one supply-chain dependency.

Inventory

```
identity, isFunction, isEmpty, isEqual, isString, isNil,
isArrayBuffer, isBuffer, isTypedArray,
mapValues, defaultTo, deburr, sampleSize,
memoize, template
```

Native / trivial replacements:

  • `identity`, `isFunction`, `isEmpty`, `isEqual` (shallow), `isString`, `isNil` → one-liners
  • `isArrayBuffer`, `isBuffer`, `isTypedArray` → `instanceof ArrayBuffer`, `Buffer.isBuffer`, `ArrayBuffer.isView`
  • `mapValues`, `defaultTo` → `Object.fromEntries(Object.entries(o).map(...))`, `?? default`
  • `deburr` → `s.normalize('NFD').replace(/\\p{Diacritic}/gu, '')`
  • `sampleSize` → small util
  • `memoize` → small WeakMap-based util (used in 3 places)

Tricky one: `lodash/template` is non-trivial to replace cleanly (used in `app/embed/Overrides.tsx` and `app/utils/packageHandle.ts`). Consider keeping just `lodash.template` as a focused dep, or write a small interpolator if the templates are simple.

Scope

  • Add `catalog/app/utils/lodashReplacements.ts` with native versions of each helper.
  • Replace 21 imports.
  • Decide on `template`: keep `lodash.template` standalone, or replace.
  • Remove `lodash` from `catalog/package.json`.

Effort

~2–3 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions