Skip to content

[AI-MADE] Optimize bundle size, modularize sync logic, and enhance UX snappiness#6

Open
DarshGupta16 wants to merge 1 commit intomasterfrom
feature/optimization-refactor
Open

[AI-MADE] Optimize bundle size, modularize sync logic, and enhance UX snappiness#6
DarshGupta16 wants to merge 1 commit intomasterfrom
feature/optimization-refactor

Conversation

@DarshGupta16
Copy link
Copy Markdown
Owner

Pull Request: Performance Optimization & Code Refactor

Description:
This PR implements a suite of performance optimizations and structural refactors to reduce initial bundle size and improve the overall "snappiness" of the application. All changes in this PR were generated and verified by AI.

Key Changes:

  1. Bundle Splitting & Lazy Loading:
    • Extracted heavy recharts logic into lazy-loaded components (DatasetGraphContent and PreviewChart).
    • This significantly reduces the initial main and index chunk sizes, as charting libraries are only downloaded when needed.
  2. Framer Motion Optimization:
    • Implemented LazyMotion with domAnimation globally in __root.tsx.
    • Converted all motion components to the lightweight m component to support strict tree-shaking and reduce the animation engine's footprint.
  3. Modular Subscription Engine:
    • Deconstructed the monolithic setupSubscriptions function into domain-specific handlers (datasets, measurements, units, preferences) located in src/utils/subscriptions/.
    • This improves maintainability, debugging, and future scalability of the PocketBase real-time sync logic.
  4. Enhanced UX Transitions:
    • Added preload="intent" to DatasetCard links, utilizing TanStack Router’s prefetching to load route data and lazy components when a user hovers over a card.
    • Updated DatasetCard with Suspense and pulse-animation fallbacks for a smoother loading experience.
  5. Build Compatibility:
    • Refined vite.config.ts to ensure compatibility between client environment chunking and SSR requirements.

Validation:

  • bun run build successfully generates smaller, optimized chunks.
  • bun run lint confirms no unused imports or sorting regressions.
  • Verified that recharts is now correctly split into its own chunk, preventing main thread bloat on initial load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant