Skip to content

chore(deps): replace lodash cloneDeep with structuredClone#145

Closed
andrerfneves wants to merge 1 commit into
mainfrom
maintenance/reduce-deps-20260603
Closed

chore(deps): replace lodash cloneDeep with structuredClone#145
andrerfneves wants to merge 1 commit into
mainfrom
maintenance/reduce-deps-20260603

Conversation

@andrerfneves

Copy link
Copy Markdown
Owner

Summary

Replaces the single lodash usage (cloneDeep) with the native structuredClone API, allowing lodash to be removed from dependencies.

Changes

  • Replace import cloneDeep from 'lodash/cloneDeep' in src/lib/bolt11.js with structuredClone
  • Remove lodash from package.json dependencies
  • Update package-lock.json

Rationale

structuredClone is supported in all modern browsers (per the project's browserslist config) and in jsdom v29.1.1 used for testing. The BOLT11 data objects being cloned are plain JSON-serializable objects, which structuredClone handles correctly.

Verification

  • All 52 tests pass
  • npm run build completes successfully
  • Bundle size reduced by ~36 KB (1,778 KB vs 1,814 KB before)
  • No application behavior changes

- 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.
@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightning-decoder Ready Ready Preview, Comment Jun 3, 2026 10:05pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/lib/bolt11.js
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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