chore: replace lodash.debounce with inline implementation#236
Open
roli-lpci wants to merge 2 commits intosplinetool:mainfrom
Open
chore: replace lodash.debounce with inline implementation#236roli-lpci wants to merge 2 commits intosplinetool:mainfrom
roli-lpci wants to merge 2 commits intosplinetool:mainfrom
Conversation
Replace lodash.debounce with a lightweight inline debounce utility, removing the lodash.debounce and @types/lodash.debounce dependencies. The inline implementation supports the same options used by ParentSize (delay and leading), handles leading+trailing edge calls correctly, provides cancel(), and resets state before invoking callbacks to support re-entrant calls safely. - New src/debounce.ts (0.46KB gzip vs external package) - Updated ParentSize.tsx import - Removed lodash.debounce from rollup externals in vite.config.ts - Removed lodash.debounce + @types/lodash.debounce from package.json
907f6b8 to
0238061
Compare
- Reset lastThis in cancel() to prevent memory leak when used in useEffect cleanup (captured component instance was never GC'd) - Replace non-null assertion with defensive undefined guard - Add JSDoc documenting supported/unsupported debounce features Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lodash.debounceruntime dependency with a small (~0.4KB) inline debounce utilityleadingoption and.cancel()API used byParentSizelodash.debounce,@types/lodash.debounce, transitive deps)Changes
src/debounce.ts— new inline debounce utility with TypeScript typessrc/ParentSize.tsx— import changed fromlodash.debounceto local./debouncepackage.json— removedlodash.debouncefrom dependencies,@types/lodash.debouncefrom devDependenciesvite.config.ts— removedlodash.debouncefrom rollup externals (now bundled inline at 0.38KB)Testing
yarn buildpasses — all 5 modules transformed, clean outputyarn build-typespasses — TypeScript declarations emit cleanlydebounce.jsis 0.38KB (gzip: 0.22KB), smaller than the external lodash.debounce package