diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EdgeStyleUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/EdgeStyleUtils.ts index 5f3442d8d69b..91c94365dc72 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EdgeStyleUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EdgeStyleUtils.ts @@ -11,7 +11,9 @@ * limitations under the License. */ import { Theme } from '@mui/material'; -import { Edge } from 'reactflow'; +// `Edge` is only used as a parameter type — keep this type-only so the file doesn't drag +// reactflow into whatever chunk imports it. +import type { Edge } from 'reactflow'; export interface EdgeStyle { stroke: string; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx index 75438c7c27c7..038c49b7781a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx @@ -16,7 +16,10 @@ import { isEmpty, isUndefined, lowerCase, startCase } from 'lodash'; import { EntityDetailUnion } from 'Models'; import { Fragment } from 'react'; import { Link } from 'react-router-dom'; -import { Node } from 'reactflow'; +// Type-only import — `Node` is used solely as a type annotation in this file. A value import +// would force `reactflow` into the eager chunk because EntityUtils.tsx is on the universal +// page-load path (Header, Search, every entity page imports from here). +import type { Node } from 'reactflow'; import { TitleLink } from '../components/common/TitleBreadcrumb/TitleBreadcrumb.interface'; import { DataAssetsWithoutServiceField } from '../components/DataAssets/DataAssetsHeader/DataAssetsHeader.interface'; import { QueryVoteType } from '../components/Database/TableQueries/TableQueries.interface'; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.ts index 19e49b4e956a..cb887f84bf01 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/NodeUtils.ts @@ -11,7 +11,8 @@ * limitations under the License. */ -import { Node } from 'reactflow'; +// Type-only — `Node` is used solely as a type annotation here. +import type { Node } from 'reactflow'; import { CONNECTION_MODAL_RULES, NODE_TYPE_MAPPINGS, diff --git a/openmetadata-ui/src/main/resources/ui/vite.config.ts b/openmetadata-ui/src/main/resources/ui/vite.config.ts index b9f07569fb99..2477cb6eea76 100644 --- a/openmetadata-ui/src/main/resources/ui/vite.config.ts +++ b/openmetadata-ui/src/main/resources/ui/vite.config.ts @@ -202,6 +202,41 @@ export default defineConfig(({ mode }) => { if (id.includes('@untitledui/icons')) { return 'vendor-untitled-icons'; } + // Heavy tab-specific libraries split into named vendor chunks. Without these + // explicit rules Rollup's auto-chunking lumped reactflow, recharts, rjsf, + // react-grid-layout, and codemirror into a single ~8.87 MB grab-bag chunk + // (named after the first lazy entry to pull them in). Splitting them here + // gives each library its own cacheable chunk so the browser can fetch them + // in parallel and skip the ones a given page doesn't use. + // `reactflow` is a meta-package that re-exports from `@reactflow/*` sub-packages + // (core, background, controls, minimap, node-resizer, node-toolbar). The heavy + // code lives in @reactflow/core, so we need to match both prefixes — matching + // only `node_modules/reactflow` misses the bulk of the bytes. + if ( + id.includes('node_modules/reactflow') || + id.includes('node_modules/@reactflow') + ) { + return 'vendor-reactflow'; + } + if ( + id.includes('node_modules/recharts') || + id.includes('node_modules/d3-') + ) { + return 'vendor-recharts'; + } + if (id.includes('node_modules/react-grid-layout')) { + return 'vendor-grid-layout'; + } + if (id.includes('node_modules/@rjsf')) { + return 'vendor-rjsf'; + } + if ( + id.includes('node_modules/codemirror') || + id.includes('node_modules/@codemirror') || + id.includes('node_modules/@uiw/react-codemirror') + ) { + return 'vendor-codemirror'; + } } }, },