Skip to content

Conversation

@seongwon030
Copy link
Member

@seongwon030 seongwon030 commented Dec 13, 2025

#️⃣연관된 이슈

ex) #926

📝작업 내용

청크 분리에 대해

webpack이든 vite는 빌드를 하면 라이브러리 의존성 + 어플리케이션 모든 코드를 하나로 합쳐 하나의 JS 코드로 합칩니다.

이렇게 하나로 합쳤을 때 성능적인 문제가 발생합니다.

캐시

하나로 합쳐진 index-*.js 내부에는 모든 라이브러리와 어플리케이션 코드가 합쳐져 있다고 앞전에 언급하였듯, 코드가 달라질 때마다 새롭게 빌드를 해야 합니다.

그렇다면 어플리케이션 코드 또는 라이브러리 의존성이 바뀔 때마다 index-*.js 의 해시값이 바뀌기 때문에,
항상 재다운로드된다고 볼 수 있습니다.

재다운로드 시점

하지만 재다운로드되는 시점은 개발 시점에서는 거의 없습니다. vite에서는 hmr로 변경된 부분만 감지하여 (웹소켓 기반으로) 업데이트하는데,
이 과정에서 만들어지는 빌드 산출물이 없기 때문입니다.

재다운로드는 배포 시점에만 발생합니다. 그것도 딱 한 번, 배포 시점에만 발생하게 됩니다. 프로덕션 환경에서도 직접 어플리케이션 코드를
수정하거나 의존성이 바뀌는 경우가 없을 것이기 때문입니다.

청크 분리의 의의

청크를 분리한다면 거의 바뀌지 않는 부분(라이브러리 의존성)과 자주 바뀌는 부분(어플리케이션 코드)를 나누어
자주 바뀌는 부분의 재다운로드 비율을 감소시킬 수 있습니다.

하지만 앞에서 말했듯 배포시점에만 의미가 있고, 배포가 더 자주 일어나는 서비스에서 더더욱 이점을 가지게 될 것 입니다.

분리한 이유

이번 PR에서 청크를 분리한 이유는 번들 구성과 캐싱 효율을 고려해서 분리하게 되었습니다.

프로덕션 환경에서는 해시기반 파일명과 장기 캐시 정책으로 동일 배포 내 재다운로드는 거의 발생하지 않으며,
변경이 있을 때는 해시가 변경된 chunk만 200으로 새로 내려받는 구조입니다.

재다운로드 비율 감소 자체가 목적이라기보다는, 변경 범위를 분리해 대용량 vendor 재다운로드를 방지가 목적이었습니다.

청크 나누기 전

스크린샷 2025-12-13 오후 4 22 39 스크린샷 2025-12-13 오후 4 57 02

index.js 파일이 1200kb가 넘어갑니다. visualizer로 봤을 때 파일도 두 개로만 분리되어 있네요.

기존에 AdminRoutes는 lazy 로드를 적용해놓아서 분리된 듯 합니다.

청크 나누기 후

스크린샷 2025-12-13 오후 5 12 26 스크린샷 2025-12-13 오후 5 12 53

청크로 나누니 index.js 파일이 154.81 kb로 줄었습니다. visualizer에서도 청크가 잘 분리된 것을 볼 수 있습니다.

결과

라이브러리 의존성은 거의 바뀌지 않는다고 가정했을 때, 어플리케이션 코드인 index.js의 재다운로드 용량이

1284.52 kb에서 154.81 kb로 줄어들었습니다.(-87.95%)

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

  • cursorrules 제거
  • 채널톡sdk 빌드에서 제거

Summary by CodeRabbit

릴리스 노트

  • 성능 개선
    • 번들 최적화 및 코드 분할 전략 강화로 초기 로딩 성능 개선
  • 개발 환경
    • 빌드 시 시각화 도구 추가(개발 의존성)
    • 버전관리 설정에 새 디렉터리 제외 규칙 추가
  • 문서
    • 상세한 프런트엔드 설계 가이드 문서 제거
  • 기타
    • 앱 초기화 흐름 일부 변경 (초기화 단계 조정)

✏️ Tip: You can customize this high-level summary in your review settings.

- manualChunks 설정으로 라이브러리별 청크 분리
- Windows/PNPM 환경 호환을 위한 경로 정규화 추가
- react-* 패키지 매칭 순서 조정으로 정확한 청크 분류
- zustand + react-query를 state 청크로 통합
- sentry를 analytics 청크로 통합
@seongwon030 seongwon030 self-assigned this Dec 13, 2025
@seongwon030 seongwon030 added 💻 FE Frontend 🚗 Chore 빌드 관련 labels Dec 13, 2025
@vercel
Copy link

vercel bot commented Dec 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
moadong Ready Ready Preview, Comment Dec 13, 2025 8:11am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 13, 2025

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

Vite 번들 분할(manualChunks)과 시각화 플러그인 추가, 앱 시작 시 채널 서비스 초기화 제거, .cursor/ 무시 항목 추가 및 프론트엔드 설계 문서 삭제 등 빌드·런타임 초기화·버전관리 관련 변경입니다.

Changes

Cohort / File(s) Summary
Build Configuration
frontend/config/vite.config.ts
build.rollupOptions.output.manualChunks(id) 추가로 node_modules 대상 패키지별(예: router, dates, markdown, react-vendor, state, react-query, analytics, sentry, motion, swiper 등) 청크 분리 로직 도입; rollup-plugin-visualizer import 추가(현재 미사용).
Dependency Management
frontend/package.json
개발 의존성 rollup-plugin-visualizer: ^5.14.0 추가
Initialization Logic
frontend/src/index.tsx
initializeChannelService의 import 및 호출 삭제(앱 시작 시 채널 서비스 초기화 생략)
Version Control & Docs
.gitignore
frontend/.cursorrules
.gitignore.cursor/ 항목 추가; 프론트엔드 설계 가이드 문서 frontend/.cursorrules 삭제

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • 집중 검토 항목:
    • frontend/config/vite.config.tsmanualChunks 패턴이 의도한 모듈을 실제로 분리하는지(빌드 출력·캐시 영향) 확인
    • 번들 시각화 산출물 검사(rollup-plugin-visualizer)로 청크 분할 및 크기 확인
    • frontend/src/index.tsx에서 채널 초기화 제거에 따른 런타임 영향(채널 의존 기능 여부) 검증
    • 삭제된 문서(frontend/.cursorrules)가 팀 규약·참조로 필요했는지 대체 위치 확인

Possibly related issues

Possibly related PRs

Suggested labels

🌏 Deploy, 🔨 Refactor

Suggested reviewers

  • seongje973
  • suhyun113
  • oesnuj

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning .cursorrules 파일 제거는 캐시 최적화 목표와 직접 관련이 없는 out-of-scope 변경입니다. cursorrules 파일 삭제를 별도 PR로 분리하거나 제외하여 청크 분리 최적화 목표에 집중하세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 청크 분리를 통한 캐시 최적화라는 주요 변경 사항을 명확하게 요약하고 있습니다.
Linked Issues check ✅ Passed 청크 분리 설정(vite.config.ts), 롤업 플러그인 의존성 추가(package.json), 채널 서비스 제거(index.tsx)로 MOA-420의 캐시 최적화 목표를 충족합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/#926-vite-cache-performance-setting-MOA-420

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/config/vite.config.ts (1)

19-71: manualChunks 분리 전략은 목표(캐시 효율)와 잘 맞습니다.
다만 지금처럼 조건문이 계속 늘어날 구조라, 규칙을 “매핑 테이블”로 빼서 추가/변경 비용을 낮추는 리팩터링을 고려해볼 만합니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3dcf13d and 73ba894.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • frontend/.cursorrules (0 hunks)
  • frontend/config/vite.config.ts (1 hunks)
  • frontend/package.json (1 hunks)
  • frontend/src/index.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • frontend/src/index.tsx
  • frontend/.cursorrules
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.{ts,tsx,js,jsx}: Replace magic numbers with named constants for clarity
Replace complex/nested ternaries with if/else or IIFEs for readability
Assign complex boolean conditions to named variables for explicit meaning
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle)
Use unique and descriptive names for custom wrappers/functions to avoid ambiguity
Define constants near related logic or ensure names link them clearly to avoid silent failures
Break down broad state management into smaller, focused hooks/contexts to reduce coupling

Files:

  • frontend/config/vite.config.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

Use consistent return types for similar functions/hooks

Files:

  • frontend/config/vite.config.ts
🧠 Learnings (1)
📚 Learning: 2025-11-15T08:13:58.854Z
Learnt from: lepitaaar
Repo: Moadong/moadong PR: 844
File: frontend/package.json:97-97
Timestamp: 2025-11-15T08:13:58.854Z
Learning: In frontend/package.json, the `tough-cookie` package is a dependency of `msw` (Mock Service Worker) used for cookie parsing and management. Both packages should be in devDependencies together.

Applied to files:

  • frontend/package.json
🔇 Additional comments (3)
.gitignore (1)

3-3: .cursor/ ignore 추가는 적절합니다.
팀 내 Cursor 사용 시 로컬 설정/캐시가 커밋되는 것을 방지합니다.

frontend/package.json (1)

95-95: rollup-plugin-visualizer 5.14.0은 Vite 7.2.2과 호환됩니다.

Rollup 4 및 표준 Vite 빌드 환경에서 완전히 지원되며, 모든 주요 옵션(filename, open, gzipSize, brotliSize)이 v5.14.0에서 정상 작동합니다. CI 환경에서 자동 열기 동작이 필요 없으면 open: false로 설정하여 관리하면 됩니다. (rolldown-vite를 사용하거나 Node ≥20인 경우 v6.x 업그레이드 검토)

frontend/config/vite.config.ts (1)

22-69: 수동 청크 구성을 공식 Vite/Rollup 권장사항에 맞춰 개선하세요.

현재 구현은 문자열 includes() 방식으로 경로를 매칭하고 있으나, 공식 Rollup 문서는 크로스플랫폼 호환성을 위해 /node_modules[\\/]/ 정규식 사용을 권장합니다. 또한 단순 경로 매칭보다 패키지명 추출 방식이 더 안정적입니다.

구체적 개선 사항:

  • 정규식 /node_modules[\\/]/으로 Windows/POSIX 경로 모두 대응
  • 전체 경로 대신 패키지명 기반 감지로 서브패스 변화에 대비
  • getModuleInfo() 활용으로 정적/동적 임포트 구분 및 순환 의존성 방지 (선택)
  • 모든 플랫폼(Windows/macOS/Linux)에서 빌드 테스트
⛔ Skipped due to learnings
Learnt from: oesnuj
Repo: Moadong/moadong PR: 529
File: frontend/config/webpack.common.ts:9-11
Timestamp: 2025-07-12T17:44:52.261Z
Learning: 사용자로부터 피드백: webpack filesystem cache 경로에 대해 추측하지 말고 정확한 공식 문서를 먼저 확인할 것. .gitignore 내용도 스크립트 결과만 믿지 말고 다시 한번 검증할 것. 정확성이 매우 중요함.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
frontend/config/vite.config.ts (1)

12-17: Visualizer 플러그인 open: true 설정은 CI 환경에서 문제를 일으킬 수 있습니다.

이전 리뷰에서 이미 지적된 내용입니다. CI/헤드리스 환경에서 브라우저 실행 시도로 인해 빌드 행(hang) 또는 실패가 발생할 수 있습니다. 조건부 활성화 또는 open: false 설정을 권장합니다.

🧹 Nitpick comments (1)
frontend/config/vite.config.ts (1)

22-61: 청크 분리 로직이 PR 목표에 맞게 잘 구현되었습니다.

라이브러리 의존성을 목적에 맞게 분류하여 캐시 효율성을 높이는 설정이 적절합니다. react-datepickerdate-fns가 동일한 dates 청크로 그룹화되는 것도 의도된 동작으로 보입니다.

선택적 개선 사항으로, 청크 이름들을 상수로 추출하면 오타 방지와 유지보수에 도움이 될 수 있습니다:

const CHUNKS = {
  ROUTER: 'router',
  DATES: 'dates',
  MARKDOWN: 'markdown',
  REACT_VENDOR: 'react-vendor',
  STATE: 'state',
  ANALYTICS: 'analytics',
  MOTION: 'motion',
  SWIPER: 'swiper',
  VENDOR: 'vendor',
} as const;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 73ba894 and c18fbf5.

📒 Files selected for processing (1)
  • frontend/config/vite.config.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.{ts,tsx,js,jsx}: Replace magic numbers with named constants for clarity
Replace complex/nested ternaries with if/else or IIFEs for readability
Assign complex boolean conditions to named variables for explicit meaning
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle)
Use unique and descriptive names for custom wrappers/functions to avoid ambiguity
Define constants near related logic or ensure names link them clearly to avoid silent failures
Break down broad state management into smaller, focused hooks/contexts to reduce coupling

Files:

  • frontend/config/vite.config.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

Use consistent return types for similar functions/hooks

Files:

  • frontend/config/vite.config.ts

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

Labels

🚗 Chore 빌드 관련 💻 FE Frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants