-
Notifications
You must be signed in to change notification settings - Fork 10.7k
feat: implement dynamic import caching for app store services #24303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ices - Add service loader caching for calendar, payment, and video services - Eliminate repeated dynamic import() calls after first resolution - Maintain code splitting benefits while improving runtime performance - Fix ESLint warnings and type safety issues - Backward compatible with existing service implementations
@krishvsoni is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis change introduces caching and mixed static/dynamic import resolution across calendar services, video adapters, and payment services. build.ts adjusts import generation (regex tweak, ESLint rule update, defaulting non-lazy imports to "default") and preserves preceding import statements when emitting CalendarServiceMap and VideoApiAdapterMap. getCalendar.ts adds memoization and supports direct class or Promise-based module resolution. videoClient.ts adds adapter factory caching, supports static/dynamic adapters, and simplifies catch blocks. handlePayment.ts adds service caching, refines type guards, and supports static/dynamic imports. setupVitest.ts switches to direct mocks, adds calendar and video adapter mock maps, and updates payment map typings. Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
🧰 Additional context used📓 Path-based instructions (3)**/*.ts📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx,js,jsx}⚙️ CodeRabbit configuration file
Files:
🧬 Code graph analysis (3)packages/app-store/_utils/getCalendar.ts (1)
packages/app-store/videoClient.ts (1)
packages/features/bookings/lib/handlePayment.ts (1)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
feat: implement dynamic import caching for app store services
What does this PR do?
This PR optimizes Cal.com's development server performance by implementing intelligent caching for dynamic imports in app store service loaders. The optimization targets 28 services across 3 critical categories (calendar, payment, video) that were causing repeated import() calls during development.
Performance Impact:
Technical Changes:
Map<string, ServiceType>
caching pattern for all service loadersRoot Cause Addressed:
The app store was performing repeated
import()
calls for the same services during development, causing unnecessary overhead. This change caches the resolved service classes after first import, maintaining the benefits of code splitting while eliminating redundant operations.Files Modified:
packages/app-store/_utils/getCalendar.ts
- Calendar service cachingpackages/features/bookings/lib/handlePayment.ts
- Payment service cachingpackages/app-store/videoClient.ts
- Video adapter cachingpackages/app-store-cli/src/build.ts
- ESLint compliance fixessetupVitest.ts
- Updated test mocks for compatibilityVisual Demo (For contributors especially)
A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).
Image Demo (if applicable):
Performance Results
Core Server Performance:
Key Point: The optimization successfully reduces service import overhead.
The 10s timing includes first-time route compilation which is separate from
the core server startup that your caching optimization targets.
Before vs After Performance Comparison:
Technical Implementation Overview:
Key Technical Benefits:
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Performance Testing
1. Development Server Startup:
2. Service Functionality Testing:
3. ESLint and Type Checking:
yarn lint:fix yarn type-check # Should pass with 0 warnings (17 ESLint warnings were fixed)
4. Service Integration Verification:
Environment Setup
yarn install
- no additional dependencies addedTest Data Requirements
.env
configuration.next
directory recommended for accurate startup measurementExpected Results (Happy Path)
Input:
Expected Output:
Service Usage Example:
Important Testing Information
.next
directory before testing for accurate startup timingChecklist