-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor(client): bundle size optimization #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Walkthrough์ด PR์ ์ฝ๋ ์คํ๋ฆฌํ ๊ณผ ๋์ ์ํฌํธ๋ฅผ ํตํด ๋ฒ๋ค ์ต์ ํ๋ฅผ ๊ตฌํํฉ๋๋ค. React.lazy๋ฅผ ์ฌ์ฉํ์ฌ ํ์ด์ง ์ปดํฌ๋ํธ๋ฅผ ์ง์ฐ ๋ก๋ฉํ๊ณ , Suspense๋ก ๋ก๋ฉ ์ํ๋ฅผ ์ฒ๋ฆฌํ๋ฉฐ, Vite ์ค์ ์์ ๋ฒ๋ค ๋ถ์ ๋ฐ ์๋ ์ฒญํฌ ์์ฑ์ ์ถ๊ฐํฉ๋๋ค. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant MainBundle
participant LazyChunk as Lazy<br/>Chunk
participant SuspenseFallback
User->>Browser: ์ ํ๋ฆฌ์ผ์ด์
์ ์
Browser->>MainBundle: ๋ฉ์ธ ๋ฒ๋ค ๋ก๋
MainBundle->>Browser: ์ด๊ธฐ UI ๋ ๋๋ง (Layout + Outlet)
Note over Browser,Outlet: Outlet ์ปดํฌ๋ํธ ๋ง์ดํธ
User->>Browser: ํ์ด์ง ๋ค๋น๊ฒ์ด์
(e.g., MyBookmark)
Browser->>SuspenseFallback: Suspense ํด๋ฐฑ ํ์<br/>(Loading...)
par ๋ฐฑ๊ทธ๋ผ์ด๋ ์ฒญํฌ ๋ก๋
Browser->>LazyChunk: ์ง์ฐ ๋ก๋ฉ ์ฒญํฌ ์์ฒญ
LazyChunk->>Browser: ์ฒญํฌ ๋ก๋ ์๋ฃ
end
Browser->>Browser: ์ปดํฌ๋ํธ ๋ง์ดํธ
SuspenseFallback->>User: ์ค์ ํ์ด์ง ์ฝํ
์ธ ํ์
Estimated code review effort๐ฏ 2 (Simple) | โฑ๏ธ ~10 minutes
์ถ๊ฐ ๊ฒํ ํญ๋ชฉ:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touchesโ Failed checks (2 warnings)
โ Passed checks (3 passed)
โจ Finishing touches
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. Comment |
|
โ
Storybook chromatic ๋ฐฐํฌ ํ์ธ: |
There was a problem hiding this 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
๐งน Nitpick comments (3)
apps/client/vite.config.ts (2)
7-7: visualizer ์๋ ์ด๊ธฐ ๋์์ ํ๊ฒฝ์ ๋ฐ๋ผ ์กฐ๊ฑด๋ถ๋ก ์ค์ ํ๋ ๊ฒ์ ๊ณ ๋ คํ์ธ์.
open: true์ค์ ์ ๋งค ๋น๋๋ง๋ค ๋ธ๋ผ์ฐ์ ๋ฅผ ์๋์ผ๋ก ์ด์ด ๊ฐ๋ฐ ์ค์ ๋ฒ๊ฑฐ๋ก์ธ ์ ์์ต๋๋ค.๋ค์๊ณผ ๊ฐ์ด ํ๊ฒฝ ๋ณ์๋ฅผ ํตํด ์กฐ๊ฑด๋ถ๋ก ์ค์ ํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค:
- visualizer({ filename: 'dist/bundle-analysis.html', open: true }), + visualizer({ + filename: 'dist/bundle-analysis.html', + open: process.env.ANALYZE === 'true' + }),๊ทธ๋ฐ ๋ค์ package.json์ ๋ณ๋์ ์คํฌ๋ฆฝํธ๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค:
"scripts": { "build:analyze": "ANALYZE=true turbo run build" }Also applies to: 21-21
23-40: manualChunks์ ๊ฒฝ๋ก ๋งค์นญ ๋ก์ง์ ๋ ๊ฒฌ๊ณ ํ๊ฒ ๊ฐ์ ํ ์ ์์ต๋๋ค.ํ์ฌ ๊ตฌํ์ ์๋ํ์ง๋ง, ๋ฌธ์์ด ํฌํจ ๊ฒ์ฌ๋ ์คํ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
๋ ์ ํํ ํจํค์ง ๋งค์นญ์ ์ํด ๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํ ์ ์์ต๋๋ค:
manualChunks: (id: string) => { - if ( - id.includes('node_modules/react/') || - id.includes('node_modules/react-dom/') || - id.includes('node_modules/react-router-dom/') - ) { + if (id.includes('node_modules')) { + if (/[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/.test(id)) { - return '@react-vendor'; + return '@react-vendor'; + } + if (/[\\/]node_modules[\\/]framer-motion[\\/]/.test(id)) { + return '@framer-motion-vendor'; + } } - if (id.includes('node_modules/framer-motion/')) { - return '@framer-motion-vendor'; - } },์ด๋ ๊ฒ ํ๋ฉด ๊ฒฝ๋ก ๊ตฌ๋ถ์๋ฅผ ์ ํํ ๋งค์นญํ์ฌ ์คํ์ ๋ฐฉ์งํ ์ ์์ต๋๋ค.
apps/client/src/layout/Layout.tsx (1)
3-3: Suspense fallback UI๋ฅผ ๊ฐ์ ํ๋ ๊ฒ์ ๊ณ ๋ คํ์ธ์.Suspense ๋ํผ ๊ตฌํ์ ์ฌ๋ฐ๋ฅด๋ฉฐ lazy-loaded ๋ผ์ฐํธ์ ์ ํตํฉ๋ฉ๋๋ค. ๋ค๋ง ํ์ฌ fallback์ด ๋๋ฌด ๋จ์ํ์ฌ ํ๋ก๋์ ํ๊ฒฝ์์๋ UX ๊ฐ์ ์ด ํ์ํฉ๋๋ค.
๋ ๋์ ์ฌ์ฉ์ ๊ฒฝํ์ ์ํด ์ ์ ํ ๋ก๋ฉ ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค:
+import LoadingSpinner from '@components/LoadingSpinner'; // ๋๋ ์ ์ ํ ๋ก๋ฉ ์ปดํฌ๋ํธ const Layout = () => { const location = useLocation(); const isOnboarding = location.pathname.startsWith('/onboarding'); return ( <> <div className="flex h-screen"> {!isOnboarding && <Sidebar />} <main className="bg-gray-bg flex-1 overflow-y-auto"> - <Suspense fallback={<div>Loading...</div>}> + <Suspense fallback={ + <div className="flex h-full items-center justify-center"> + <LoadingSpinner /> + </div> + }> <Outlet /> </Suspense> </main> </div> </> ); };๋๋ ๋์์ธ ์์คํ ์ ์ด๋ฏธ ๋ก๋ฉ ์ปดํฌ๋ํธ๊ฐ ์๋ค๋ฉด ๊ทธ๊ฒ์ ํ์ฉํ ์ ์์ต๋๋ค.
Also applies to: 14-16
๐ Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
โ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
๐ Files selected for processing (4)
apps/client/src/layout/Layout.tsx(2 hunks)apps/client/src/routes/router.tsx(1 hunks)apps/client/vite.config.ts(2 hunks)package.json(1 hunks)
๐งฐ Additional context used
๐ง Learnings (1)
๐ Common learnings
Learnt from: constantly-dev
Repo: Pinback-Team/pinback-client PR: 2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.065Z
Learning: constantly-dev๋ docs ๋๋ ํฐ๋ฆฌ๋ฅผ ์ปจ๋ฒค์
๋ฌธ์ ์ถ๊ฐ์ฉ์ผ๋ก ์ฌ์ฉํ ์์ ์ด๋ผ๊ณ ๋ช
์ํ์ต๋๋ค.
Learnt from: constantly-dev
Repo: Pinback-Team/pinback-client PR: 5
File: apps/extension/src/index.css:1-1
Timestamp: 2025-08-19T17:18:57.678Z
Learning: constantly-dev๋ ๋์์ธ ์์คํ
์ค์ PR ๋จธ์ง ํ `import 'pinback/tailwind-config/shared-styles.css';`๋ฅผ `app.css`๋ `index.css`์์ ์ฌ์ฉํ์ฌ ๊ณต์ ์คํ์ผ์ ๊ด๋ฆฌํ ๊ณํ์
๋๋ค.
๐งฌ Code graph analysis (2)
apps/client/src/routes/router.tsx (1)
apps/client/src/pages/level/Level.tsx (1)
Level(12-73)
apps/client/src/layout/Layout.tsx (1)
apps/client/src/shared/components/sidebar/Sidebar.tsx (1)
Sidebar(24-236)
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: storybook
๐ Additional comments (3)
package.json (1)
29-29: LGTM!๋ฒ๋ค ๋ถ์์ ์ํ visualizer ํ๋ฌ๊ทธ์ธ ์ถ๊ฐ๊ฐ ์ ์ ํฉ๋๋ค. devDependencies์ ์ฌ๋ฐ๋ฅด๊ฒ ๋ฐฐ์น๋์์ต๋๋ค.
apps/client/src/routes/router.tsx (2)
5-10: LGTM!React.lazy๋ฅผ ์ฌ์ฉํ ์ฝ๋ ์คํ๋ฆฌํ ๊ตฌํ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋์ด ์์ต๋๋ค. ๋ฒ๋ค ์ต์ ํ์ ํจ๊ณผ์ ์ ๋๋ค.
1-1: Remind ์ปดํฌ๋ํธ์ eager ๋ก๋ฉ์ด ์๋์ ์ธ์ง ํ์ธํ์ธ์.๋ค๋ฅธ ํ์ด์ง๋ ๋ชจ๋ lazy ๋ก๋ฉ์ ์ฌ์ฉํ๋ ๋ฐ๋ฉด, Remind๋ eager ๋ก๋ฉ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ด๋ ๋๋ฉ ํ์ด์ง๋ก์ ์ฆ์ ๋ก๋๋์ด์ผ ํ๋ฏ๋ก ํฉ๋ฆฌ์ ์ผ ์ ์์ง๋ง, ๋ฒ๋ค ์ต์ ํ ๋ชฉํ์ ์ผ๊ด์ฑ์ ์ํด ์๋์ ์ธ ์ ํ์ธ์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
๋ง์ฝ Remind๋ lazy ๋ก๋ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์์ ํ ์ ์์ต๋๋ค:
-import Remind from '@pages/remind/Remind'; import { ROUTES_CONFIG } from '@routes/routesConfig'; import { createBrowserRouter } from 'react-router-dom'; import Layout from 'src/layout/Layout'; import { lazy } from 'react'; +const Remind = lazy(() => import('@pages/remind/Remind')); const MyBookmark = lazy(() => import('@pages/myBookmark/MyBookmark')); const Category = lazy(() => import('@pages/category/Category')); const Level = lazy(() => import('@pages/level/Level')); const OnBoarding = lazy(() => import('@pages/onBoarding/OnBoarding'));์ฐธ๊ณ :
index: true๋ก์ ๋ณ๊ฒฝ์ React Router v7์ ์ฌ๋ฐ๋ฅธ ํจํด์ ๋๋ค.Also applies to: 18-19
| if ( | ||
| id.includes('node_modules/react/') || | ||
| id.includes('node_modules/react-dom/') || | ||
| id.includes('node_modules/react-router-dom/') | ||
| ) { | ||
| return '@react-vendor'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์น ์ด๋ฐ์์ผ๋ก, ๋ฌด๊ฑฐ์ด ์ฒญํฌ๋ค์ ๋ถ๋ฆฌํ๊ณ ์ต์ ํํ๋๊ตฐ๋ ~! ๊ตฟ๊ตฟ
๐ Related Issues
๐ Tasks
๋ฒ๋ค ์ฌ์ด์ฆ ์ต์ ํ ์งํ
โญ PR Point (To Reviewer)
https://peppered-parade-9ba.notion.site/2a9081ae8cf980698826d0264b44eb32?source=copy_link
๋ ธ์ ์ผ๋ก ๋์ฒดํ๊ฒ ์ต๋๋ค!
Summary by CodeRabbit
๋ฆด๋ฆฌ์ค ๋ ธํธ
์๋ก์ด ๊ธฐ๋ฅ
์ต์ ํ
Chores