fix: replace full lodash imports with per-function imports

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.
This commit is contained in:
Yandi
2026-02-22 20:34:38 +07:00
parent 5435e1dac4
commit 0b1c1e8b8c
4 changed files with 6 additions and 6 deletions
@@ -1,6 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import copy from "copy-to-clipboard"; import copy from "copy-to-clipboard";
import { debounce } from "lodash"; import debounce from "lodash/debounce";
import { CheckIcon, ChevronsUpDown, Copy, RotateCcw } from "lucide-react"; import { CheckIcon, ChevronsUpDown, Copy, RotateCcw } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@@ -1,6 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import copy from "copy-to-clipboard"; import copy from "copy-to-clipboard";
import _ from "lodash"; import debounce from "lodash/debounce";
import { import {
CheckIcon, CheckIcon,
ChevronsUpDown, ChevronsUpDown,
@@ -236,7 +236,7 @@ export const RestoreBackup = ({
const currentDatabaseType = form.watch("databaseType"); const currentDatabaseType = form.watch("databaseType");
const metadata = form.watch("metadata"); const metadata = form.watch("metadata");
const debouncedSetSearch = _.debounce((value: string) => { const debouncedSetSearch = debounce((value: string) => {
setDebouncedSearchTerm(value); setDebouncedSearchTerm(value);
}, 350); }, 350);
@@ -1,5 +1,5 @@
import { Command as CommandPrimitive } from "cmdk"; import { Command as CommandPrimitive } from "cmdk";
import { debounce } from "lodash"; import debounce from "lodash/debounce";
import { CheckIcon, Hash } from "lucide-react"; import { CheckIcon, Hash } from "lucide-react";
import React, { useCallback, useRef } from "react"; import React, { useCallback, useRef } from "react";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
@@ -1,5 +1,5 @@
import { FancyAnsi } from "fancy-ansi"; import { FancyAnsi } from "fancy-ansi";
import _ from "lodash"; import escapeRegExp from "lodash/escapeRegExp";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { import {
Tooltip, Tooltip,
@@ -47,7 +47,7 @@ export function TerminalLine({ log, noTimestamp, searchTerm }: LogLineProps) {
} }
const htmlContent = fancyAnsi.toHtml(text); const htmlContent = fancyAnsi.toHtml(text);
const searchRegex = new RegExp(`(${_.escapeRegExp(term)})`, "gi"); const searchRegex = new RegExp(`(${escapeRegExp(term)})`, "gi");
const modifiedContent = htmlContent.replace( const modifiedContent = htmlContent.replace(
searchRegex, searchRegex,