Skip to content

Commit c306c3b

Browse files
committed
Reduce bundle size and changes to langflow method
1 parent a3db2ca commit c306c3b

8 files changed

Lines changed: 39 additions & 88 deletions

File tree

src/frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "@xyflow/react/dist/style.css";
12
import { Suspense, useEffect } from "react";
23
import { RouterProvider } from "react-router-dom";
34
import { LoadingPage } from "./pages/LoadingPage";
@@ -12,7 +13,6 @@ export default function App() {
1213
} else {
1314
document.getElementById("body")!.classList.add("dark");
1415
}
15-
import("@xyflow/react/dist/style.css").catch(console.error);
1616
}, [dark]);
1717
return (
1818
<Suspense fallback={<LoadingPage />}>
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1+
import dynamicIconImports from "lucide-react/dynamicIconImports";
12
import { categoryIcons } from "@/utils/styleUtils";
23

3-
export const checkLucideIcons =async (iconName: string):Promise<boolean> => {
4-
const [lucideIcons, dynamicIconImports] = await Promise.all([
5-
import("lucide-react"),
6-
import("lucide-react/dynamicIconImports").then((mod) => mod.default),
7-
]);
8-
return (
9-
!!lucideIcons[iconName] ||
10-
!!dynamicIconImports[iconName] ||
11-
!!categoryIcons[iconName]
12-
);
4+
export const checkLucideIcons = (iconName: string): boolean => {
5+
return !!dynamicIconImports[iconName] || !!categoryIcons[iconName];
136
};

src/frontend/src/components/core/jsonEditor/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { jsonquery } from "@jsonquerylang/jsonquery";
22
import { type KeyboardEvent, useEffect, useRef, useState } from "react";
3-
import type {
4-
Content,
3+
import {
4+
type Content,
55
createJSONEditor,
6-
MenuItem,
7-
Mode,
8-
JsonEditor as VanillaJsonEditor,
6+
type MenuItem,
7+
type Mode,
8+
type JsonEditor as VanillaJsonEditor,
99
} from "vanilla-jsoneditor";
1010
import useAlertStore from "../../../stores/alertStore";
1111
import { cn } from "../../../utils/utils";

src/frontend/src/components/core/jsonEditor/menuUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { faCopy } from "@fortawesome/free-solid-svg-icons";
2-
import type { MenuItem, Mode } from "vanilla-jsoneditor";
2+
import { type MenuItem, Mode } from "vanilla-jsoneditor";
33

44
export const filterTextModeItems = (items: MenuItem[]): MenuItem[] => {
55
return items.filter((item) => {

src/frontend/src/pages/AppWrapperPage/components/AuthenticatedAppWrapper.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
import { Suspense, lazy } from "react";
2-
import { LoadingPage } from "../LoadingPage";
3-
import { useLocation } from "react-router-dom";
4-
import Landing from "../LandingPage";
1+
import { ErrorBoundary } from "react-error-boundary";
2+
import { Outlet } from "react-router-dom";
3+
import AlertDisplayArea from "@/alerts/displayArea";
4+
import CrashErrorComponent from "@/components/common/crashErrorComponent";
5+
import { GenericErrorComponent } from "./components/GenericErrorComponent";
6+
import { useHealthCheck } from "./hooks/use-health-check";
57

6-
const AuthenticatedAppWrapper = lazy(() =>
7-
import("./components/AuthenticatedAppWrapper").then((module) => ({
8-
default: module.AuthenticatedAppWrapper,
9-
})),
10-
);
118
export function AppWrapperPage() {
12-
const { pathname } = useLocation();
13-
14-
// Render the marketing landing page when visitor hits the root route
15-
// regardless of authentication status
16-
if (pathname === "/") {
17-
return <Landing />;
18-
}
9+
const { healthCheckTimeout, fetchingHealth, refetch } = useHealthCheck();
1910

2011
return (
21-
<Suspense fallback={<LoadingPage />}>
22-
<AuthenticatedAppWrapper />
23-
</Suspense>
12+
<div className="flex h-full w-full flex-col">
13+
<ErrorBoundary
14+
onReset={() => {
15+
// any reset function
16+
}}
17+
FallbackComponent={CrashErrorComponent}
18+
>
19+
<>
20+
<GenericErrorComponent
21+
healthCheckTimeout={healthCheckTimeout}
22+
fetching={fetchingHealth}
23+
retry={refetch}
24+
/>
25+
<Outlet />
26+
</>
27+
</ErrorBoundary>
28+
<div className="app-div">
29+
<AlertDisplayArea />
30+
</div>
31+
</div>
2432
);
2533
}

src/frontend/src/utils/styleUtils.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { TwitterLogoIcon } from "@radix-ui/react-icons";
2+
import dynamicIconImports from "lucide-react/dynamicIconImports";
23
import { lazy } from "react";
34
import { FaApple, FaDiscord, FaGithub } from "react-icons/fa";
45
import { ENABLE_KNOWLEDGE_BASES } from "@/customization/feature-flags";
@@ -8,13 +9,6 @@ import { GradientSave } from "@/icons/GradientSparkles";
89

910
const iconCache = new Map<string, any>();
1011

11-
let lucideMapCache: Record<string, any> | null = null;
12-
const getDynamicIconImports = async (): Promise<Record<string, any>> => {
13-
if (!lucideMapCache) {
14-
lucideMapCache = (await import("lucide-react/dynamicIconImports")).default;
15-
}
16-
return lucideMapCache;
17-
};
1812
export const BG_NOISE =
1913
"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+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VqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==)";
2014

@@ -564,7 +558,6 @@ export const getNodeIcon = async (name: string) => {
564558
return cacheAndReturn(lazy(iconMappings[iconName || name]));
565559
}
566560

567-
const dynamicIconImports = await getDynamicIconImports();
568561
const lucideIconName = getLucideIconName(iconName || name);
569562
if (dynamicIconImports[lucideIconName]) {
570563
try {
@@ -587,7 +580,6 @@ export const getNodeIcon = async (name: string) => {
587580
export const iconExists = async (name: string): Promise<boolean> => {
588581
const iconName = nodeIconToDisplayIconMap[name] || name;
589582
const iconMappings = await iconMappingsPromise;
590-
const dynamicIconImports = await getDynamicIconImports();
591583

592584
return !!(
593585
eagerLoadedIconsMap[iconName] ||

src/frontend/src/utils/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import useAlertStore from "@/stores/alertStore";
44
import { ColDef, ColGroupDef, ValueParserParams } from "ag-grid-community";
55
import clsx, { ClassValue } from "clsx";
66
import { type ColumnField, FormatterType } from "@/types/utils/functions";
7+
import "moment-timezone";
78
import type { Cookies } from "react-cookie";
89
import { twMerge } from "tailwind-merge";
910
import {

0 commit comments

Comments
 (0)