Skip to content

차트 컴포넌트 Lazy Loading 및 성능 최적화 리팩토링#341

Open
Copilot wants to merge 21 commits intodevelopfrom
copilot/optimize-chart-library
Open

차트 컴포넌트 Lazy Loading 및 성능 최적화 리팩토링#341
Copilot wants to merge 21 commits intodevelopfrom
copilot/optimize-chart-library

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

개요

ALLCLL 서비스 내 차트 컴포넌트들의 성능을 최적화하고, 프로젝트 아키텍처를 견고하게 개선하기 위한 리팩토링입니다. @allcll/charts 패키지를 독립적으로 고도화하고, 각 애플리케이션의 번들 최적화를 수행했습니다.

🚀 배경

현재 ALLCLL에서 차트(chart.js)는 다음과 같은 문제가 있었습니다.

📦 차트 라이브러리(chart.js, react-chartjs-2)가 번들에 포함되어 초기 로딩이 무거움
🔁 여러 페이지에서 동일 라이브러리를 중복 로딩
⚙️ 차트 사용할 때마다 Suspense 설정 필요 (개발 불편)

🚀 주요 변경 사항

1. @allcll/charts 패키지 분리

  • charts 라이브러리를 패키지로 분리
  • 내부 Lazy/Suspense 적용: 차트 컴포넌트에 React.lazySuspense를 내장했습니다.

2. 코드 스플리팅 - 번들 최적화 (Manual Chunks)

  • adminclient 패키지의 vite.config.tsmanualChunks 설정을 추가
  • chart.jsreact-chartjs-2vendor-chartjs 청크로 강제 분리하여, 페이지 간 중복 로딩을 줄이고 캐싱 효율을 극대화
    • 한 번 로딩하면 다른 곳에서 재사용 할 수 있음.

3. 이미지 크기 최적화 (레이아웃 이동 방지)

  • packages/client/src/widgets/home/ui/MainBanner.tsx: spring-banner-min.png 이미지에 width={740} height={788} 속성 추가 (CLS 방지)
    • 실제 이미지 크기 740×788px 기반
    • 브라우저가 이미지 로드 전 aspect-ratio(740:788)를 계산하여 공간 미리 확보
    • CSS width(w-[320px] lg:w-[370px])는 유지, height는 브라우저가 aspect-ratio로 자동 계산
  • packages/client/src/shared/ui/Image.tsx: width/height는 이미 React.ImgHTMLAttributes로 지원됨 (변경 불필요)

4. (참고) index.html 탭 변경

  • lint 로 인해 탭 개수가 변경되었습니다. 리뷰하실 때 참고하시면 좋을 것 같습니다.

⚙️ 아키텍처 개선 효과

  • 개발 편의성: Suspense 설정 없이 컴포넌트만 사용해도 자동으로 성능 최적화가 적용됩니다.
  • 성능: 번들 분리를 통한 메인 스레드 부담 완화 및 공통 라이브러리 캐싱 최적화.
  • 결합도 완화: client 패키지가 외부 라이브러리 타입에 직접 의존하지 않게 되어, 향후 라이브러리 교체 시 영향 범위가 대폭 줄어들었습니다.

인프라 변화

  • http 1.1 -> http 2.0 으로 변경 (파일이 여러개 인 경우 성능 향상)
Original prompt

react chart 2 와, chart js 가 너무 무거워서, 이걸 우리가 필요한 것 만 따로 라이브러리 화 하려고 해. 최종적인 목표는 chart library 를 우리것으로 만들고, 최종 번들의 크기를 최적화 하는게 목표야.
먼저 client package 에서 react chart 2와 chart js 중에 어떤 기능을 쓰고 있는지 알아봐주고 먼저 그걸 정리해줘.
그 뒤에 사용하는 차트 항목이 모두 구현되도록 라이브러리화 해주고, 그걸 현재 사용하고 있는 react chart 2 나 chart js 부분을 대체해주면 돼.
최종적으로 확인했을 때 react-chart-2 나 chart-js 가 없어져야 하고, 빌드했을 때 오류가 나지 않아야 해.

최종적으로 PR을 생성하면, 설명은 한국어로 써줘.


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

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Copilot AI changed the title [WIP] Chart library 최적화 및 통합 구현 chore: replace react-chartjs-2/chart.js with lightweight custom SVG chart library Mar 20, 2026
Copilot AI requested a review from hyunwoo0081 March 20, 2026 13:53
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 21, 2026

🚀 Preview Deployment

This preview is automatically updated on each push.

… comparison

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Agent-Logs-Url: https://github.com/allcll/allcll-frontend/sessions/10d1c785-dec8-4385-93f9-2227e6cbe889
Copilot AI changed the title chore: replace react-chartjs-2/chart.js with lightweight custom SVG chart library feat: chart.js/react-chartjs-2 제거 + 커스텀 SVG 차트 라이브러리 도입 + uplot/visx 번들 크기 POC Mar 21, 2026
Copilot AI and others added 2 commits March 21, 2026 09:36
Copilot AI changed the title feat: chart.js/react-chartjs-2 제거 + 커스텀 SVG 차트 라이브러리 도입 + uplot/visx 번들 크기 POC feat: replace @allcll/chart with visx in client — bundle size POC Mar 21, 2026
Copilot AI and others added 2 commits March 21, 2026 11:25
Copilot AI changed the title feat: replace @allcll/chart with visx in client — bundle size POC refactor(@allcll/chart): extract shared internals, memoize SVG computations, improve maintainability Mar 21, 2026
…ayout fixes

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Agent-Logs-Url: https://github.com/allcll/allcll-frontend/sessions/50c3a544-1335-4bef-b126-dce519f5a67d
Copilot AI changed the title refactor(@allcll/chart): extract shared internals, memoize SVG computations, improve maintainability feat(@allcll/chart): entry animations, dark tooltip, legend toggle, RadarChart overflow & MixedChart layout fixes Mar 21, 2026
…arChart overflow fix

Co-authored-by: hyunwoo0081 <76638365+hyunwoo0081@users.noreply.github.com>
Agent-Logs-Url: https://github.com/allcll/allcll-frontend/sessions/2ca75e12-45e8-44e0-be77-5fc7ab1b74a4
Copilot AI changed the title feat(@allcll/chart): entry animations, dark tooltip, legend toggle, RadarChart overflow & MixedChart layout fixes feat(@allcll/chart): value-based entry/update animations + RadarChart overflow fix Mar 22, 2026
Copilot AI changed the title fix(DoughnutChart): value-based chart animations and full-circle arc rendering bug refactor(chart): accessibility, stable keys, and depth reduction Mar 24, 2026
Copilot stopped work on behalf of hyunwoo0081 due to an error March 25, 2026 15:43
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@hyunwoo0081 hyunwoo0081 changed the title refactor(chart): accessibility, stable keys, and depth reduction 차트 컴포넌트 Lazy Loading 및 성능 최적화 리팩토링 Apr 14, 2026
@hyunwoo0081 hyunwoo0081 marked this pull request as ready for review April 14, 2026 05:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59b7c3fd1c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +27 to +28
function MixedChart({ data, options }: MixedChartProps) {
return <Chart type="bar" data={data} options={options} />;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Forward sizing props to loaded MixedChart

StatisticsChart now passes height={288}, but this wrapper drops that prop when the lazy chunk resolves because MixedChart only accepts { data, options } and renders <Chart> without forwarding sizing props. This means the fallback skeleton honors the height while the real chart does not, causing avoidable layout shift and inconsistent chart sizing after load.

Useful? React with 👍 / 👎.

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