chore(deps): replace lodash cloneDeep with structuredClone#145
chore(deps): replace lodash cloneDeep with structuredClone#145andrerfneves wants to merge 1 commit into
Conversation
- Replace lodash/cloneDeep import with native structuredClone in src/lib/bolt11.js - Remove lodash from package.json dependencies - Update package-lock.json structuredClone is supported in all modern browsers (per browserslist config) and jsdom v29.1.1 used in tests. Reduces bundle size by ~36 KB.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a6c169a70
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function encode (inputData, addDefaults) { | ||
| // we don't want to affect the data being passed in, so we copy the object | ||
| let data = cloneDeep(inputData) | ||
| let data = structuredClone(inputData) |
There was a problem hiding this comment.
Preserve Buffer instances when cloning inputs
When encode receives Buffer-valued fields, structuredClone converts them to plain Uint8Arrays in Node/browser Buffer implementations, unlike lodash cloneDeep. This API already accepts Buffers for hex fields because hexToBuffer returns non-strings unchanged, and the later validation/serialization relies on Buffer behavior such as equals, toString('hex'), and instanceof Buffer; invoices with Buffer payeeNodeKey, tag data, or routing fields now either fail validation or serialize comma-separated bytes instead of hex.
Useful? React with 👍 / 👎.
Summary
Replaces the single lodash usage (
cloneDeep) with the nativestructuredCloneAPI, allowing lodash to be removed from dependencies.Changes
import cloneDeep from 'lodash/cloneDeep'insrc/lib/bolt11.jswithstructuredClonelodashfrompackage.jsondependenciespackage-lock.jsonRationale
structuredCloneis supported in all modern browsers (per the project'sbrowserslistconfig) and in jsdom v29.1.1 used for testing. The BOLT11 data objects being cloned are plain JSON-serializable objects, whichstructuredClonehandles correctly.Verification
npm run buildcompletes successfully