Skip to content

fix(admin-ui): admin UI experiences a loading delay due to the large bundle size of a chunk in the production build#2320

Merged
moabu merged 9 commits intomainfrom
admin-ui-issue-2318
Oct 8, 2025
Merged

fix(admin-ui): admin UI experiences a loading delay due to the large bundle size of a chunk in the production build#2320
moabu merged 9 commits intomainfrom
admin-ui-issue-2318

Conversation

@duttarnab
Copy link
Contributor

closes #2318

Implementation Strategy

1. Webpack Configuration

Vendor Library Splitting

  • React Ecosystem: react, react-dom, react-router, react-router-dom
  • Material-UI: @mui/*, @emotion/*
  • Redux: @reduxjs/*, redux, redux-saga, redux-persist
  • Charts: recharts, react-ace, ace-builds
  • Utilities: lodash, moment, dayjs, axios, formik, yup

Plugin-based Splitting

  • Each plugin gets its own chunk
  • Dynamic loading of plugin components
  • Fallback mechanisms for failed loads

Common Code Splitting

  • Shared application code
  • Common vendor libraries
  • Reusable components

2. Route-based Code Splitting

Lazy Route Loading

// Pre-defined lazy routes
export const LazyRoutes = {
  DashboardPage: createLazyRoute(() => import('../routes/Dashboards/DashboardPage')),
  ProfilePage: createLazyRoute(() => import('../routes/Apps/Profile/ProfilePage')),
  // ... more routes
}

Usage in Routes

<Route
  path="/home/dashboard"
  element={
    <ProtectedRoute>
      <LazyRoutes.DashboardPage />
    </ProtectedRoute>
  }
/>

3. Plugin System Enhancement

Dynamic Plugin Loading

// Async plugin loading
export async function processRoutes() {
  const pluginPromises = plugins.map(async (item) => {
    try {
      const metadata = await import(`${item.metadataFile}`)
      return metadata.default.routes || []
    } catch (error) {
      console.warn(`Failed to load plugin routes: ${item.metadataFile}`, error)
      return []
    }
  })
  // ... handle results
}

Plugin Component Loading

// Dynamic plugin component loading
export const loadPluginComponent = (pluginName: string, componentName: string) => {
  return createLazyComponent(() => 
    import(`../../plugins/${pluginName}/components/${componentName}`)
  )
}

4. Component-based Code Splitting

Large Component Splitting

// Lazy loading for heavy components
export const LazyComponents = {
  MaterialTable: createLazyComponent(() => import('@material-table/core')),
  ReactAce: createLazyComponent(() => import('react-ace')),
  Recharts: createLazyComponent(() => import('recharts')),
  // ... more components
}

Conditional Loading

// Load components only when needed
<ConditionalComponent
  condition={showChart}
  component={LazyComponents.Recharts}
  fallback={<div>Loading chart...</div>}
/>

…e of a chunk in the production build

Signed-off-by: duttarnab <arnab.bdutta@gmail.com>
Signed-off-by: duttarnab <arnab.bdutta@gmail.com>
@duttarnab duttarnab requested a review from syntrydy as a code owner October 5, 2025 14:38
@duttarnab duttarnab mentioned this pull request Oct 5, 2025
@mo-auto mo-auto added area-documentation Documentation needs to change as part of issue or PR comp-admin-ui Component affected by issue or PR kind-bug Issue or PR is a bug in existing functionality labels Oct 5, 2025
syntrydy
syntrydy previously approved these changes Oct 6, 2025
Signed-off-by: duttarnab <arnab.bdutta@gmail.com>
@duttarnab duttarnab dismissed stale reviews from syntrydy and faisalsiddique4400 via fbba192 October 7, 2025 19:10
Signed-off-by: Arnab Dutta <arnab.bdutta@gmail.com>
Signed-off-by: Arnab Dutta <arnab.bdutta@gmail.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

moabu
moabu previously approved these changes Oct 8, 2025
Signed-off-by: Arnab Dutta <arnab.bdutta@gmail.com>
@duttarnab duttarnab force-pushed the admin-ui-issue-2318 branch from 2cdc21c to 14462e8 Compare October 8, 2025 12:16
@moabu moabu merged commit 644e1f1 into main Oct 8, 2025
5 checks passed
@moabu moabu deleted the admin-ui-issue-2318 branch October 8, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-documentation Documentation needs to change as part of issue or PR comp-admin-ui Component affected by issue or PR kind-bug Issue or PR is a bug in existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(admin-ui): admin UI experiences a loading delay due to the large bundle size of a chunk in the production build.

5 participants