Skip to content

chore(react): internalize lodash.debounce (KNO-13811)#1022

Closed
kylemcd wants to merge 1 commit into
kyle-kno-13812-internalize-jwt-decode-in-knocklabsclient-and-drop-thefrom
kyle-kno-13811-internalize-lodashdebounce-in-knocklabsreact-and-drop-the
Closed

chore(react): internalize lodash.debounce (KNO-13811)#1022
kylemcd wants to merge 1 commit into
kyle-kno-13812-internalize-jwt-decode-in-knocklabsclient-and-drop-thefrom
kyle-kno-13811-internalize-lodashdebounce-in-knocklabsreact-and-drop-the

Conversation

@kylemcd

@kylemcd kylemcd commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

Internalizes lodash.debounce in @knocklabs/react and drops both the lodash.debounce runtime dependency and its @types/lodash.debounce dev dependency.

The single call site (useOnBottomScroll) uses debounce(callback, 200) with default options (trailing-edge, no leading/maxWait) and never calls .cancel()/.flush(), so a minimal trailing-edge debounce matches current behavior exactly.

What changed

  • Added packages/react/src/modules/core/debounce/ — a dedicated folder containing the trailing-edge debounce util (with a cancel() for good measure).
  • Repointed the import in useOnBottomScroll.ts, and updated its test to mock the new debounce module.
  • Added packages/react/test/core/debounce.test.ts covering the wait delay, single trailing invocation, call coalescing, latest-args behavior, and cancel().
  • Dropped lodash.debounce and @types/lodash.debounce from packages/react/package.json and updated the lockfile.

lodash.debounce remains in the lockfile only as a transitive dependency of a Babel helper — it is no longer a direct dependency of ours.

Why: Part of the npm supply chain hardening effort. @knocklabs/react is published, so this also removes the dependency from consumers' install graphs.

Linear: KNO-13811


Stack (bottom → top) — npm supply chain hardening:

  1. chore(react): remove clsx dependency (KNO-13814) #1020 — remove clsx from @knocklabs/react
  2. chore(client): internalize jwt-decode (KNO-13812) #1021 — internalize jwt-decode in @knocklabs/client
  3. chore(react): internalize lodash.debounce (KNO-13811) #1022 — internalize lodash.debounce in @knocklabs/react ◀ this PR
  4. chore(react-core): internalize fast-deep-equal (KNO-13810) #1023 — internalize fast-deep-equal in @knocklabs/react-core

Checklist

  • Tests have been added (test/core/debounce.test.ts) and useOnBottomScroll.test.tsx passes against the internalized debounce.

@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

KNO-13811

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview, Comment Jun 17, 2026 2:41pm
javascript-nextjs-example Ready Ready Preview, Comment Jun 17, 2026 2:41pm
javascript-slack-connect-example Ready Ready Preview, Comment Jun 17, 2026 2:41pm
javascript-slack-kit-example Ready Ready Preview, Comment Jun 17, 2026 2:41pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 29f99c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@knocklabs/react Patch
ms-teams-connect-example Patch
nextjs-app-dir-example Patch
slack-connect-example Patch
slack-kit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

kylemcd commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (kyle-kno-13812-internalize-jwt-decode-in-knocklabsclient-and-drop-the@66bf33e). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                                           Coverage Diff                                            @@
##             kyle-kno-13812-internalize-jwt-decode-in-knocklabsclient-and-drop-the    #1022   +/-   ##
========================================================================================================
  Coverage                                                                         ?   63.64%           
========================================================================================================
  Files                                                                            ?      210           
  Lines                                                                            ?    10081           
  Branches                                                                         ?     1303           
========================================================================================================
  Hits                                                                             ?     6416           
  Misses                                                                           ?     3640           
  Partials                                                                         ?       25           
Files with missing lines Coverage Δ
packages/react/src/modules/core/debounce/index.ts 100.00% <100.00%> (ø)
.../react/src/modules/core/hooks/useOnBottomScroll.ts 100.00% <100.00%> (ø)

@kylemcd

kylemcd commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Combined into #1024.

@kylemcd kylemcd closed this Jun 17, 2026
@kylemcd kylemcd deleted the kyle-kno-13811-internalize-lodashdebounce-in-knocklabsreact-and-drop-the branch June 17, 2026 14:51
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