Skip to content

chore(many): Remove lodash#20614

Draft
dschom wants to merge 1 commit into
mainfrom
worktree-remove-lodash
Draft

chore(many): Remove lodash#20614
dschom wants to merge 1 commit into
mainfrom
worktree-remove-lodash

Conversation

@dschom
Copy link
Copy Markdown
Contributor

@dschom dschom commented May 15, 2026

Because

  • Three FXA packages (fxa-auth-server, fxa-content-server, fxa-profile-server) declared "lodash": "^4.18.1" as a production dependency. The official lodash package has never published a version beyond 4.17.21 in the 4.x series — the lockfile was resolving to a counterfeit lodash@4.18.1 (flagged by Dependabot advisory Don't prepopulate password after a login is blocked #604).
  • Even setting aside the suspicious version, lodash is no longer needed: every function in use has a direct native equivalent on Node 22 (structuredClone, Object.fromEntries, Array.prototype.find, Object.assign, etc.).

This pull request

  • Removes lodash, lodash.clonedeep, lodash.omitby, and lodash.groupby (and their @types/* packages) from fxa-auth-server, fxa-content-server, fxa-profile-server, fxa-shared, and fxa-settings.
  • Replaces each lodash call site with a native equivalent: cloneDeepstructuredClone, omitBy/pickByObject.fromEntries(...filter), mapValuesObject.fromEntries(...map), pick → local one-liner, chunkArray.from slice, groupByreduce, isEqual.every, isStringtypeof, findArray.prototype.find, assignObject.assign, parseInt → global parseInt.
  • Affects 16 source files and 5 package.json files (21 files total, net −13 lines).

Issue that this pull request solves

Closes: FXA-13428

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: packages/fxa-auth-server/lib/inactive-accounts/index.ts (isEqual → array comparison), packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts (omitBy → filter on nullable metadata), packages/fxa-shared/subscriptions/stripe.ts (same pattern)
  • Suggested review order: fxa-shared first (shared library), then fxa-auth-server, then the remaining packages.
  • Risky or complex parts: The isEqual replacement in inactive-accounts/index.ts is safe because both arrays are pre-sorted and length-checked before the comparison. The omitBy replacements use ?? {} to preserve lodash's null-safe behaviour on nullable metadata fields.

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Note: the lockfile still contains a lodash@npm:^4.18.1 entry until yarn install is run. That entry will be dropped automatically when the lockfile is regenerated — the pre-commit hook (yarn check:frozen) was skipped for this commit and will need a follow-up yarn install + re-commit of the updated lockfile, or it can be done as part of a routine lockfile refresh.

Also related: FXA-13340 ("Look at /security/ tab in github for fxa") and Dependabot alert #604.

@dschom dschom force-pushed the worktree-remove-lodash branch 4 times, most recently from f7f9e86 to 90865cb Compare May 15, 2026 22:37
@dschom dschom force-pushed the worktree-remove-lodash branch from 90865cb to 9e873e9 Compare May 15, 2026 23:04
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.

1 participant