perf: optimize video adapter imports to avoid loading entire app store (#23435)
* perf: optimize video adapter imports to avoid loading entire app store - Creates VideoApiAdapterMap with lazy imports for 12 video services - Updates getVideoAdapters function to use VideoApiAdapterMap instead of dynamic app store imports - Preserves zoom app name parsing logic (zoom_video → zoomvideo) - Follows same optimization pattern as calendar, analytics, and payment services - Reduces bundle size by avoiding import of 100+ apps when only video functionality needed Affected files: - packages/app-store-cli/src/build.ts: Added video service generation logic - packages/lib/videoClient.ts: Updated to use VideoApiAdapterMap - packages/features/bookings/lib/handleCancelBooking.ts: Updated FAKE_DAILY_CREDENTIAL import - packages/lib/EventManager.ts: Updated FAKE_DAILY_CREDENTIAL import - packages/trpc/server/routers/viewer/calVideo/getMeetingInformation.handler.ts: Updated to use VideoApiAdapterMap - apps/web/lib/video/[uid]/getServerSideProps.ts: Updated daily video function imports - packages/app-store/video.services.generated.ts: Generated video adapter map with re-exports Co-Authored-By: [email protected] <[email protected]> * fix: add missing re-exports to video.services.generated.ts - Updates build.ts to include FAKE_DAILY_CREDENTIAL and other daily video function re-exports - Fixes type errors in EventManager.ts and other files importing from video.services.generated - Ensures video adapter refactoring maintains all existing functionality Co-Authored-By: [email protected] <[email protected]> * fix: update video adapter test mocks to work with VideoApiAdapterMap - Creates global mockVideoAdapterRegistry for dynamic video adapter mocks - Uses Proxy in vi.mock for VideoApiAdapterMap to return registered mocks - Updates mockVideoApp and mockErrorOnVideoMeetingCreation to register mocks - Fixes unit test failures in booking scenario tests - Ensures video meeting operations (createMeeting, updateMeeting, deleteMeeting) work correctly Co-Authored-By: [email protected] <[email protected]> * fix: remove re-exports from video.services.generated.ts and revert imports - Remove re-export block from video.services.generated.ts as requested - Revert imports back to pull directly from dailyvideo/lib/VideoApiAdapter - Update build.ts to not generate the re-exports - Maintains all existing functionality while addressing GitHub feedback Co-Authored-By: [email protected] <[email protected]> * fix: rename video.services.generated.ts to video.adapters.generated.ts - Updates build.ts to generate video.adapters.generated.ts instead of video.services.generated.ts - Updates all import statements to use new filename - Removes unnecessary mock exports from bookingScenario.ts (FAKE_DAILY_CREDENTIAL, etc.) - Addresses GitHub comments from @keithwillcode on PR #23435 The terminology change from 'services map' to 'adapters map' better reflects the actual content (video adapters, not services) and maintains consistency with the established refactoring pattern. Co-Authored-By: [email protected] <[email protected]> * refactor: rename videoServices to videoAdapters and simplify return statement - Rename variable from videoServices to videoAdapters for consistency - Remove unnecessary const variable and return directly in same line - Addresses GitHub comments from @keithwillcode on PR #23435 Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
bfacd8a780
commit
191db5104a
5 files changed
+159
-65
No files matched your search
@@ -433,6 +433,40 @@ function generateFiles() {
|
||||
|
||||
paymentOutput.push(...paymentServices);
|
||||
|
||||
const videoOutput = [];
|
||||
const videoAdapters = getExportedObject(
|
||||
"VideoApiAdapterMap",
|
||||
{
|
||||
importConfig: {
|
||||
fileToBeImported: "lib/VideoApiAdapter.ts",
|
||||
importName: "default",
|
||||
},
|
||||
lazyImport: true,
|
||||
},
|
||||
(app: App) => {
|
||||
return fs.existsSync(path.join(APP_STORE_PATH, app.path, "lib/VideoApiAdapter.ts"));
|
||||
}
|
||||
);
|
||||
|
||||
const videoExportLineIndex = videoAdapters.findIndex((line) =>
|
||||
line.startsWith("export const VideoApiAdapterMap")
|
||||
);
|
||||
if (videoExportLineIndex !== -1) {
|
||||
const exportLine = videoAdapters[videoExportLineIndex];
|
||||
const objectContent = videoAdapters.slice(videoExportLineIndex + 1, -1);
|
||||
|
||||
videoOutput.push(
|
||||
exportLine.replace(
|
||||
"export const VideoApiAdapterMap = {",
|
||||
"export const VideoApiAdapterMap = process.env.NEXT_PUBLIC_IS_E2E ? {} : {"
|
||||
),
|
||||
...objectContent,
|
||||
"};"
|
||||
);
|
||||
} else {
|
||||
videoOutput.push(...videoAdapters);
|
||||
}
|
||||
|
||||
const banner = `/**
|
||||
This file is autogenerated using the command \`yarn app-store:build --watch\`.
|
||||
Don't modify this file manually.
|
||||
@@ -449,6 +483,7 @@ function generateFiles() {
|
||||
["crm.apps.generated.ts", crmOutput],
|
||||
["calendar.services.generated.ts", calendarOutput],
|
||||
["payment.services.generated.ts", paymentOutput],
|
||||
["video.adapters.generated.ts", videoOutput],
|
||||
];
|
||||
filesToGenerate.forEach(([fileName, output]) => {
|
||||
fs.writeFileSync(`${APP_STORE_PATH}/${fileName}`, formatOutput(`${banner}${output.join("\n")}`));
|
||||
|
||||
Reference in new issue
Block a user