fix: replace full lodash imports with per-function imports#3776
Open
karyanayandi wants to merge 1 commit intoDokploy:canaryfrom
Open
fix: replace full lodash imports with per-function imports#3776karyanayandi wants to merge 1 commit intoDokploy:canaryfrom
karyanayandi wants to merge 1 commit intoDokploy:canaryfrom
Conversation
Importing the entire lodash library adds ~70kb to the bundle. Switch to specific imports (lodash/debounce, lodash/escapeRegExp) so only the used functions are included.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce client bundle size by replacing full lodash imports with per-function imports so only the required utilities are included in the build.
Changes:
- Replaced
import _ from "lodash"+_.escapeRegExpwithimport escapeRegExp from "lodash/escapeRegExp". - Replaced
import { debounce } from "lodash"/_.debouncewithimport debounce from "lodash/debounce"across several components.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/dokploy/components/dashboard/docker/logs/terminal-line.tsx | Switches to lodash/escapeRegExp for regex escaping used in log highlighting. |
| apps/dokploy/components/dashboard/docker/logs/line-count-filter.tsx | Switches debounce import to lodash/debounce to avoid full lodash import. |
| apps/dokploy/components/dashboard/database/backups/restore-backup.tsx | Replaces lodash default import with lodash/debounce and updates usage. |
| apps/dokploy/components/dashboard/application/volume-backups/restore-volume-backups.tsx | Switches debounce import to lodash/debounce. |
Comments suppressed due to low confidence (1)
apps/dokploy/components/dashboard/database/backups/restore-backup.tsx:243
debouncedSetSearchis created on every render. Because lodash debounce maintains internal timers, this can defeat debouncing (multiple independent timers can fire) and may cause state updates after unmount. Make the debounced function stable (e.g., viauseMemo/useRef) and cancel it in an effect cleanup.
const debouncedSetSearch = debounce((value: string) => {
setDebouncedSearchTerm(value);
}, 350);
const handleSearchChange = (value: string) => {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What is this PR about?
Importing the entire lodash library adds ~70kb to the bundle. Switch to specific imports (lodash/debounce, lodash/escapeRegExp) so only the used functions are included.
Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
Screenshots (if applicable)
Greptile Summary
Replaced full lodash imports with specific function imports (
lodash/debounce,lodash/escapeRegExp) across 4 frontend component files to reduce bundle size by approximately 70kb.Confidence Score: 5/5
Last reviewed commit: 0b1c1e8
(2/5) Greptile learns from your feedback when you react with thumbs up/down!