Your project is well-optimized and currently well under Vercel's 250MB serverless function limit:
- Total Server Bundle: 24.97 MB (well under 250MB limit)
- API Routes:
/api/price: 5.34 KB/api/snapshot: 3.19 MB
- Static Assets: 2.54 MB
- Externalized heavy blockchain SDKs (
@saros-finance/dlmm-sdk,@solana/spl-token) - Excluded development tools and large utility libraries
- Properly configured for both server and client bundles
- API routes use dynamic imports to avoid bundling heavy dependencies
- Supabase client now uses lazy loading to reduce initial bundle size
- Added
outputFileTracingIncludesandoutputFileTracingExcludesinnext.config.ts - Excludes unnecessary files from serverless functions (components, hooks, types, etc.)
- Created
vercel.jsonto exclude unnecessary files from serverless functions - Configured proper file exclusions for API routes
- Added
npm run build:size-checkscript for continuous monitoring - Automated bundle size checking with 200MB safety margin
- Warns when approaching size limits
- Comprehensive chunk splitting with 200KB per chunk limit
- Separate chunks for different libraries (Solana, Supabase, React, etc.)
- Optimized for tree-shaking
- Minimal dependencies (only essential packages)
- Proper externalization of heavy libraries
- No duplicate dependencies
- Static files served via CDN (not bundled in functions)
- Proper image optimization configuration
- Compressed assets
- Modular API routes with single responsibilities
- Dynamic imports for heavy dependencies
- Lazy loading of database clients
- Tree-shaking enabled
- Dead code elimination
- Optimized package imports
# Check bundle sizes
npm run build:size-check
# Analyze bundle composition
npm run build:analyze- Current: 24.97 MB (10% of limit)
- Warning Threshold: 150 MB (60% of limit)
- Hard Limit: 250 MB (100% of limit)
- New Dependencies: Check size impact before adding
- Bundle Growth: Monitor size increases over time
- API Route Changes: Ensure new routes stay optimized
- Split Large Functions: Break down complex API routes
- External Services: Move heavy processing to separate services
- Further Optimization: Remove unused code and dependencies
- Caching: Implement aggressive caching strategies
- Regular Audits: Monthly dependency reviews
- Bundle Analysis: Quarterly bundle composition analysis
- Performance Monitoring: Track function cold start times
- Code Reviews: Include bundle size impact in PR reviews
next.config.ts- Webpack externals and file tracingvercel.json- Vercel-specific optimizationspackage.json- Added size monitoring scriptscripts/check-bundle-size.js- Bundle size monitoring toolsrc/lib/data/supabaseClient.ts- Lazy loading implementation
Status: ✅ OPTIMIZED - Your project is well within Vercel's limits and follows best practices for serverless function optimization.