Skip to content

Commit 7600dc7

Browse files
shah-harshitclaude
andauthored
feat(ui): lazy-load all SettingsRouter, EntityRouter, and EntityImportRouter pages (PR #14) (open-metadata#28797)
Convert 47 eager page/component imports in SettingsRouter.tsx to React.lazy() + withSuspenseFallback() so the settings chunk is not part of the main bundle. Also lazify EntityVersionPage in EntityRouter and BulkEntityImportPage in EntityImportRouter. - SettingsRouter.tsx: 47 imports → React.lazy() with webpack chunk splitting - EntityRouter.tsx: EntityVersionPage → lazy - EntityImportRouter.tsx: BulkEntityImportPage → lazy - Named exports use .then((m) => ({ default: m.X })) pattern Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fd887fe commit 7600dc7

3 files changed

Lines changed: 307 additions & 51 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/components/AppRouter/EntityImportRouter.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010
* See the License for the specific language governing permissions and
1111
* limitations under the License.
1212
*/
13-
import { useCallback, useEffect, useState } from 'react';
13+
import React, { useCallback, useEffect, useState } from 'react';
1414
import { Navigate, Route, Routes, useNavigate } from 'react-router-dom';
1515
import { SUPPORTED_BULK_IMPORT_EDIT_ENTITY } from '../../constants/BulkImport.constant';
1616
import { ROUTES } from '../../constants/constants';
1717
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
1818
import { ResourceEntity } from '../../context/PermissionProvider/PermissionProvider.interface';
1919
import { useFqn } from '../../hooks/useFqn';
20-
import BulkEntityImportPage from '../../pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage';
2120
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
2221
import { useRequiredParams } from '../../utils/useRequiredParams';
22+
import withSuspenseFallback from './withSuspenseFallback';
23+
24+
const BulkEntityImportPage = withSuspenseFallback(
25+
React.lazy(
26+
() =>
27+
import(
28+
'../../pages/EntityImport/BulkEntityImportPage/BulkEntityImportPage'
29+
)
30+
)
31+
);
2332

2433
const EntityImportRouter = () => {
2534
const navigate = useNavigate();

openmetadata-ui/src/main/resources/ui/src/components/AppRouter/EntityRouter.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@
1010
* See the License for the specific language governing permissions and
1111
* limitations under the License.
1212
*/
13-
import { useMemo } from 'react';
13+
import React, { useMemo } from 'react';
1414
import { Navigate, Route, Routes } from 'react-router-dom';
1515
import {
1616
PLACEHOLDER_ROUTE_ENTITY_TYPE,
1717
ROUTES,
1818
} from '../../constants/constants';
1919
import { EntityType } from '../../enums/entity.enum';
20-
import EntityVersionPage from '../../pages/EntityVersionPage/EntityVersionPage.component';
2120
import entityUtilClassBase from '../../utils/EntityUtilClassBase';
2221
import { useRequiredParams } from '../../utils/useRequiredParams';
2322
import EntityImportRouter from './EntityImportRouter';
23+
import withSuspenseFallback from './withSuspenseFallback';
24+
25+
const EntityVersionPage = withSuspenseFallback(
26+
React.lazy(
27+
() => import('../../pages/EntityVersionPage/EntityVersionPage.component')
28+
)
29+
);
2430

2531
const EntityRouter = () => {
2632
const { entityType } = useRequiredParams<{ entityType: EntityType }>();

0 commit comments

Comments
 (0)