feat: add route-level code splitting with React.lazy and Suspense (Closes #469) - #597
Open
waterWang wants to merge 1 commit into
Open
feat: add route-level code splitting with React.lazy and Suspense (Closes #469)#597waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
- Convert all 20 page imports to React.lazy() dynamic imports - Add Suspense wrapper with loading spinner (Loader2 from lucide-react) - Keep layout/utility components (EmployerLayout, ErrorBoundary, ErrorFallback) as regular imports since they are not route pages - Each page chunk loads on demand, reducing initial bundle size Closes Protocol-Guild#469
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts all 20 page components in
App.tsxfrom eager imports toReact.lazy()dynamic imports, enabling route-level code splitting. Each page chunk loads on demand, reducing the initial bundle size.Changes
Code Splitting
React.lazy(() => import('./pages/...'))EmployerLayout,ErrorBoundary,ErrorFallback) remain as regular imports since they are not route pagesSuspensewraps the entire<Routes>block with a centered loading spinner (Loader2from lucide-react)Loading Fallback
PageLoadercomponent shows a centered spinner with "Loading…" textLoader2withanimate-spinfrom the existing lucide-react dependencyError Handling
ErrorBoundarywrapper — chunk load failures are caught by the existing error boundary hierarchySuspensefallback only shows during initial chunk loading; runtime errors are handled by the per-routeErrorBoundaryBundle Impact
tsc --noEmit— zero type errorsVerification
tsc --noEmitpasses cleanlylucide-reactis already a project dependency (Loader2used inCrossAssetPayment.tsx)Closes #469