@@ -6,18 +6,17 @@ import * as Sentry from '@sentry/react'
6
6
import { BrowserTracing } from '@sentry/tracing'
7
7
8
8
import 'normalize.css'
9
- import React from 'react'
9
+ import React , { lazy } from 'react'
10
10
import ReactDOM from 'react-dom/client'
11
11
import { Route , Routes } from 'react-router-dom'
12
12
13
- import { AboutPage } from 'pages/about '
13
+ import { withSuspensable } from 'components/Suspensable '
14
14
import { ViewPage } from 'pages/view'
15
15
import { clearOutdatedSwrCache } from 'utils/swr'
16
16
17
17
import { App } from './App'
18
18
import { AppLayout } from './layouts/AppLayout'
19
19
import { NotFoundPage } from './pages/404'
20
- import { CreatePage } from './pages/create'
21
20
import { IndexPage } from './pages/index'
22
21
import './styles/blueprint.less'
23
22
@@ -49,15 +48,22 @@ if (navigator.userAgent.includes('Win')) {
49
48
50
49
clearOutdatedSwrCache ( )
51
50
51
+ const CreatePageLazy = withSuspensable (
52
+ lazy ( ( ) => import ( './pages/create' ) . then ( ( m ) => ( { default : m . CreatePage } ) ) ) ,
53
+ )
54
+ const AboutPageLazy = withSuspensable (
55
+ lazy ( ( ) => import ( './pages/about' ) . then ( ( m ) => ( { default : m . AboutPage } ) ) ) ,
56
+ )
57
+
52
58
ReactDOM . createRoot ( document . getElementById ( 'root' ) ! ) . render (
53
59
< React . StrictMode >
54
60
< App >
55
61
< AppLayout >
56
62
< Routes >
57
63
< Route path = "/" element = { < IndexPage /> } />
58
- < Route path = "/create/:id" element = { < CreatePage /> } />
59
- < Route path = "/create" element = { < CreatePage /> } />
60
- < Route path = "/about" element = { < AboutPage /> } />
64
+ < Route path = "/create/:id" element = { < CreatePageLazy /> } />
65
+ < Route path = "/create" element = { < CreatePageLazy /> } />
66
+ < Route path = "/about" element = { < AboutPageLazy /> } />
61
67
< Route path = "/operation/:id" element = { < ViewPage /> } />
62
68
< Route path = "*" element = { < NotFoundPage /> } />
63
69
</ Routes >
0 commit comments