-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bundle 사이즈 최적화 #716
Bundle 사이즈 최적화 #716
Changes from all commits
c3282c7
ab981be
b35abf0
b79e3dc
469dae9
349d51a
dd8835e
3aa7495
e6e19ad
3d0238b
5456e6c
fa2e4d9
bae39af
dfa2cf0
8908aa1
a9e8408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
import { ErrorBoundary } from '@sentry/react'; | ||
import { Suspense } from 'react'; | ||
import { lazy, Suspense } from 'react'; | ||
import { createBrowserRouter } from 'react-router-dom'; | ||
|
||
import { Layout, LoadingFallback } from '@/components'; | ||
import { | ||
TemplatePage, | ||
TemplateUploadPage, | ||
SignupPage, | ||
LoginPage, | ||
LandingPage, | ||
NotFoundPage, | ||
TemplateExplorePage, | ||
MyTemplatePage, | ||
} from '@/pages'; | ||
|
||
import RouteGuard from './RouteGuard'; | ||
import { END_POINTS } from './endPoints'; | ||
|
||
const LandingPage = lazy(() => import('@/pages/LandingPage/LandingPage')); | ||
const TemplatePage = lazy(() => import('@/pages/TemplatePage/TemplatePage')); | ||
const TemplateUploadPage = lazy(() => import('@/pages/TemplateUploadPage/TemplateUploadPage')); | ||
const SignupPage = lazy(() => import('@/pages/SignupPage/SignupPage')); | ||
const LoginPage = lazy(() => import('@/pages/LoginPage/LoginPage')); | ||
const NotFoundPage = lazy(() => import('@/pages/NotFoundPage/NotFoundPage')); | ||
const TemplateExplorePage = lazy(() => import('@/pages/TemplateExplorePage/TemplateExplorePage')); | ||
const MyTemplatePage = lazy(() => import('@/pages/MyTemplatesPage/MyTemplatePage')); | ||
|
||
const CustomSuspense = ({ children }: { children: JSX.Element }) => ( | ||
<Suspense fallback={<div>Loading...</div>}>{children}</Suspense> | ||
); | ||
Comment on lines
+19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분에서 혹시 LayoutShift가 생기진 않나요?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout의 모든 요소가 한 번에 렌더링 되기 때문에 Layout Shift가 생기진 않지만, (캐시가 없을 때) 로딩 후 뒤늦게 렌더링 됩니다. 헤인이 Footer이 미리 렌더링 되지 않도록 하여 Layout Shift를 해결했던 것과 동일한 이유로 Layout Shift가 발생하지 않는다고 할 수 있을 것 같습니다. |
||
|
||
const router = createBrowserRouter([ | ||
{ | ||
errorElement: <NotFoundPage />, | ||
element: <Layout />, | ||
errorElement: ( | ||
<CustomSuspense> | ||
<NotFoundPage /> | ||
</CustomSuspense> | ||
), | ||
Comment on lines
+26
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CustomSuspense를 Layout 내부 같은 곳에서 한번에 걸어도 괜찮을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 지금 생각했을 땐 방법이 떠오르지는 않네용 |
||
element: ( | ||
<CustomSuspense> | ||
<Layout /> | ||
</CustomSuspense> | ||
), | ||
children: [ | ||
{ | ||
path: END_POINTS.HOME, | ||
element: <LandingPage />, | ||
element: ( | ||
<CustomSuspense> | ||
<LandingPage /> | ||
</CustomSuspense> | ||
), | ||
}, | ||
{ | ||
path: END_POINTS.MY_TEMPLATES, | ||
|
@@ -40,39 +55,57 @@ const router = createBrowserRouter([ | |
}, | ||
{ | ||
path: END_POINTS.TEMPLATES_EXPLORE, | ||
element: <TemplateExplorePage />, | ||
element: ( | ||
<CustomSuspense> | ||
<TemplateExplorePage /> | ||
</CustomSuspense> | ||
), | ||
}, | ||
{ | ||
path: END_POINTS.TEMPLATE, | ||
element: <TemplatePage />, | ||
element: ( | ||
<CustomSuspense> | ||
<TemplatePage /> | ||
</CustomSuspense> | ||
), | ||
}, | ||
{ | ||
path: END_POINTS.TEMPLATES_UPLOAD, | ||
element: ( | ||
<RouteGuard isLoginRequired redirectTo={END_POINTS.LOGIN}> | ||
<TemplateUploadPage /> | ||
<CustomSuspense> | ||
<TemplateUploadPage /> | ||
</CustomSuspense> | ||
</RouteGuard> | ||
), | ||
}, | ||
{ | ||
path: END_POINTS.SIGNUP, | ||
element: ( | ||
<RouteGuard isLoginRequired={false} redirectTo={END_POINTS.HOME}> | ||
<SignupPage /> | ||
<CustomSuspense> | ||
<SignupPage /> | ||
</CustomSuspense> | ||
</RouteGuard> | ||
), | ||
}, | ||
{ | ||
path: END_POINTS.LOGIN, | ||
element: ( | ||
<RouteGuard isLoginRequired={false} redirectTo={END_POINTS.HOME}> | ||
<LoginPage /> | ||
<CustomSuspense> | ||
<LoginPage /> | ||
</CustomSuspense> | ||
</RouteGuard> | ||
), | ||
}, | ||
{ | ||
path: '*', | ||
element: <NotFoundPage />, | ||
element: ( | ||
<CustomSuspense> | ||
<NotFoundPage /> | ||
</CustomSuspense> | ||
), | ||
}, | ||
], | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,5 +84,4 @@ module.exports = { | |
}, | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
devtool: 'source-map', | ||
}; |
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.
혹시 lint 에러가 나지 않았나요?!
Fast refresh only works when a file only exports components. Move your component(s) to a separate file.eslint(react-refresh/only-export-components)
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.
이 부분에 ESLint 에러가 발생하고 있습니다.
이 에러는 DX 향상 목적의 에러인데요.
소스코드 변경 시, 브라우저에서 해당 부분만 빠르게 업데이트하여 개발생산성을 높힐 수 있다는 경고입니다.
이 ESLint 에러 같은 경우에는 컴포넌트의 Default export 또는 컴포넌트를 리턴하고 있지 않아서 발생한다고 하는데, lazy 로딩을 사용할 수 없게 됩니다.
따라서 ESLint에서 이 에러를 경고처리만 하여서 개발자가 파악할 수 있도록 하여 사용하는 케이스도 있다고 합니다.