Skip to content

feat(client): route lazy loading, vendor chunk splitting, defer analytics init#339

Draft
Copilot wants to merge 12 commits intodevelopfrom
copilot/optimize-frontend-lazy-loading
Draft

feat(client): route lazy loading, vendor chunk splitting, defer analytics init#339
Copilot wants to merge 12 commits intodevelopfrom
copilot/optimize-frontend-lazy-loading

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

POC for reducing initial JS parse/execution cost in the client SPA. Two sessions of changes: (1) route-level lazy loading + deferred analytics, (2) stable Rollup vendor chunk splitting + removing @allcll/sejong-ui from the / dependency chain.

Route lazy loading (routing.tsx, main.tsx)

  • All page components converted to React.lazy() dynamic imports; layout components and error pages remain synchronous
  • SimulationLayout converted to lazy import — was the primary path pulling @allcll/sejong-ui into the initial bundle
  • Added shared PageLoader component as the common <Suspense> fallback (layout stays visible, only page body suspends)
  • Analytics (Clarity, Sentry, ReactGA) initialization deferred via requestIdleCallback / setTimeout(200ms) fallback to avoid blocking first render

Vendor chunk splitting (vite.config.ts)

Added manualChunks with stable named output chunks for long-term cache stability:

manualChunks(id) {
  if (id.includes('/packages/allcll-ui/') || id.includes('@allcll/allcll-ui')) return 'vendor-allcll-ui';
  if (id.includes('/packages/sejong-ui/') || id.includes('@allcll/sejong-ui'))  return 'vendor-sejong-ui';
  if (!id.includes('node_modules')) return undefined;
  if (/node_modules\/(react|react-dom|scheduler)\//.test(id)) return 'vendor-react';
  if (id.includes('/react-router') || id.includes('/@remix-run/router'))        return 'vendor-router';
  if (id.includes('/@tanstack/'))                                                return 'vendor-tanstack';
  return 'vendor';
}

Resulting chunks: vendor-react (46 kB gz), vendor-router (30 kB gz), vendor-tanstack (11 kB gz), vendor-allcll-ui (6 kB gz), vendor-sejong-ui (4 kB gz), vendor (308 kB gz).

Removing sejong-ui from / import chain (SimulationSection.tsx, Landing.tsx)

  • SimulationSection (rendered on /) had a direct @allcll/sejong-ui import for a single captcha <Input> — replaced with an inline native <input> styled to match
  • SimulationSection is now lazy-loaded inside Landing.tsx with <Suspense fallback={null}>
  • Result: vendor-sejong-ui is not requested on initial / load; it loads on-demand only when navigating to /simulation

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…tics init

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Copilot AI changed the title [WIP] Update frontend for route lazy loading and performance improvements feat(client): POC – route lazy loading + deferred analytics init Mar 17, 2026
Copilot AI requested a review from hyunwoo0081 March 17, 2026 03:42
… dependency chain

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Copilot AI changed the title feat(client): POC – route lazy loading + deferred analytics init feat(client): route lazy loading, vendor chunk splitting, defer analytics init Mar 17, 2026
@hyunwoo0081 hyunwoo0081 changed the base branch from chore/img-optim to develop March 21, 2026 03:42
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

🚀 Preview Deployment

This preview is automatically updated on each push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants