The components should be import just when user access them.
Problems & Solves:
- All components will be load when user access one of those pages.
Use react lazy for router components.
- router part does not in one file, the code logic maybe split-up.
Create router folder for manage router, move utils/route.ts to router/router.ts.
Export both components and path, use loop instead of manually add new route.
Now:
Static import all components on the entry file.
4.1Mb size will be transfer in the first access.
Router components and router path split on the different file.
Expect:
Use dynamic import replace static import for router components and the components that not be used immediately.
All router logic code in router folder.
1Mb size for necessary base library, other pages load when user access or pre-fetch on idle time.