Description
Several heavy components — the rich-text editor, the Stellar SDK transaction builder, and charting libraries — are included in the initial JS bundle even for routes that do not use them, inflating the First Contentful Paint on all pages. Splitting these via next/dynamic ensures each route only loads code it actually needs.
Technical Context
next/dynamic with { ssr: false } applied in src/components/invoice/NotesEditor.tsx (wrapping the rich-text library), src/components/analytics/TrendChart.tsx (wrapping the chart library), and src/lib/stellar/transactionBuilder.ts (imported dynamically in src/app/invoice/[id]/sign/page.tsx). A next/bundle-analyzer configuration in next.config.js (behind the ANALYZE=true env var) is added to make bundle composition auditable in CI. Loading fallbacks for each dynamic import are defined using the loading option with accessible aria-busy spinner markup.
Acceptance Criteria
Description
Several heavy components — the rich-text editor, the Stellar SDK transaction builder, and charting libraries — are included in the initial JS bundle even for routes that do not use them, inflating the First Contentful Paint on all pages. Splitting these via
next/dynamicensures each route only loads code it actually needs.Technical Context
next/dynamicwith{ ssr: false }applied insrc/components/invoice/NotesEditor.tsx(wrapping the rich-text library),src/components/analytics/TrendChart.tsx(wrapping the chart library), andsrc/lib/stellar/transactionBuilder.ts(imported dynamically insrc/app/invoice/[id]/sign/page.tsx). Anext/bundle-analyzerconfiguration innext.config.js(behind theANALYZE=trueenv var) is added to make bundle composition auditable in CI. Loading fallbacks for each dynamic import are defined using theloadingoption with accessiblearia-busyspinner markup.Acceptance Criteria
ANALYZE=true npm run buildproduces an interactive bundle report; the rich-text and chart libraries do not appear in the initial route chunkloadingfallback that renders a spinner withrole="status"andaria-labelnext buildsize output