From 7f417dd8c397744c4707924b344a6959d0c9dbf5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 02:10:03 +0000 Subject: [PATCH 1/5] feat: optimize webpack bundling to reduce server chunk duplication - Add modularizeImports for FeaturesRepository and other Repository classes - Configure webpack splitChunks with cacheGroups for repositories, features, prisma, and shared libraries - Enable usedExports and sideEffects optimization for better tree-shaking - Addresses massive code duplication issue where FeaturesRepository appears in 66+ chunks Co-Authored-By: keith@cal.com --- apps/web/next.config.js | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 4f8c665613d13d..c8d2c49c68a942 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -226,6 +226,36 @@ const nextConfig = (phase) => { skipDefaultConversion: true, preventFullImport: true, }, + "@calcom/features/flags": { + transform: "@calcom/features/flags/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/users": { + transform: "@calcom/features/users/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/watchlist": { + transform: "@calcom/features/watchlist/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/calendar-cache": { + transform: "@calcom/features/calendar-cache/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/platform-oauth-client": { + transform: "@calcom/features/platform-oauth-client/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/lib/server/repository": { + transform: "@calcom/lib/server/repository/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, lodash: { transform: "lodash/{{member}}", }, @@ -242,6 +272,47 @@ const nextConfig = (phase) => { } } + config.optimization = { + ...config.optimization, + usedExports: true, + sideEffects: false, + splitChunks: { + ...config.optimization.splitChunks, + cacheGroups: { + ...config.optimization.splitChunks?.cacheGroups, + repositories: { + test: /[\\/]packages[\\/].*repository\.(ts|js)$/, + name: "repositories", + chunks: "all", + priority: 30, + enforce: true, + }, + features: { + test: /[\\/]packages[\\/]features[\\/]flags[\\/]/, + name: "features", + chunks: "all", + priority: 25, + enforce: true, + }, + prisma: { + test: /[\\/]packages[\\/]prisma[\\/]|[\\/]node_modules[\\/]@prisma[\\/]/, + name: "prisma", + chunks: "all", + priority: 20, + enforce: true, + }, + shared: { + test: /[\\/]packages[\\/]lib[\\/]/, + name: "shared-lib", + chunks: "all", + priority: 15, + minChunks: 2, + enforce: true, + }, + }, + }, + }; + if (isServer) { // Module not found fix @see https://github.com/boxyhq/jackson/issues/1535#issuecomment-1704381612 config.plugins.push( From 2ad75e22b710a69c5be430473bc80250f0ecc682 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 02:29:27 +0000 Subject: [PATCH 2/5] feat: expand webpack optimizations for @calcom/features, @calcom/lib, and @calcom/app-store - Add modularizeImports configurations for all @calcom/features submodules (bookings, eventtypes, insights, webhooks, auth, shell, ee) - Add modularizeImports for @calcom/lib utilities (server, hooks, general lib) - Add modularizeImports for @calcom/app-store components (high priority optimization) - Expand splitChunks cacheGroups to include features, lib, and app-store packages - Fix LineChart export error in insights/components/index.ts (remove stale export) - Optimize chunk hierarchy with proper priority levels: app-store (28) > repositories (30) > features (25) > lib (22) > prisma (20) > shared (15) Co-Authored-By: keith@cal.com --- apps/web/next.config.js | 71 ++++++++++++++++++- .../features/insights/components/index.ts | 1 - 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index c8d2c49c68a942..361a560f2379ec 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -256,6 +256,61 @@ const nextConfig = (phase) => { skipDefaultConversion: true, preventFullImport: true, }, + "@calcom/features/bookings": { + transform: "@calcom/features/bookings/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/eventtypes": { + transform: "@calcom/features/eventtypes/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/insights": { + transform: "@calcom/features/insights/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/webhooks": { + transform: "@calcom/features/webhooks/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/auth": { + transform: "@calcom/features/auth/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/shell": { + transform: "@calcom/features/shell/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/features/ee": { + transform: "@calcom/features/ee/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/lib/server": { + transform: "@calcom/lib/server/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/lib/hooks": { + transform: "@calcom/lib/hooks/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/lib": { + transform: "@calcom/lib/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, + "@calcom/app-store": { + transform: "@calcom/app-store/{{member}}", + skipDefaultConversion: true, + preventFullImport: true, + }, lodash: { transform: "lodash/{{member}}", }, @@ -288,12 +343,26 @@ const nextConfig = (phase) => { enforce: true, }, features: { - test: /[\\/]packages[\\/]features[\\/]flags[\\/]/, + test: /[\\/]packages[\\/]features[\\/]/, name: "features", chunks: "all", priority: 25, enforce: true, }, + lib: { + test: /[\\/]packages[\\/]lib[\\/]/, + name: "lib", + chunks: "all", + priority: 22, + enforce: true, + }, + appStore: { + test: /[\\/]packages[\\/]app-store[\\/]/, + name: "app-store", + chunks: "all", + priority: 28, + enforce: true, + }, prisma: { test: /[\\/]packages[\\/]prisma[\\/]|[\\/]node_modules[\\/]@prisma[\\/]/, name: "prisma", diff --git a/packages/features/insights/components/index.ts b/packages/features/insights/components/index.ts index c94b682f22c1a6..f21c6209aea9e3 100644 --- a/packages/features/insights/components/index.ts +++ b/packages/features/insights/components/index.ts @@ -4,7 +4,6 @@ export { BookingStatusBadge } from "./BookingStatusBadge"; export { CellWithOverflowX } from "./CellWithOverflowX"; export { ChartCard } from "./ChartCard"; export { KPICard } from "./KPICard"; -export { LineChart } from "./LineChart"; export { LoadingInsight } from "./LoadingInsights"; export { ResponseValueCell } from "./ResponseValueCell"; export { UserStatsTable } from "./UserStatsTable"; From 9a83c1e99012afe037ea46aa9d6348c1166f71e8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 02:44:01 +0000 Subject: [PATCH 3/5] fix: correct modularizeImports configuration to match actual export structures - Remove problematic @calcom/features/bookings modularizeImports entry that was causing 'Module not found: Can't resolve @calcom/features/bookings/AvailableTimes' error - Remove @calcom/features/eventtypes and @calcom/features/insights entries that don't match actual export patterns - Keep only component-level modularizeImports for @calcom/features/eventtypes/components and @calcom/features/insights/components - Maintain webpack optimization benefits while fixing import resolution issues - Verified with yarn type-check:ci --force passing successfully Co-Authored-By: keith@cal.com --- apps/web/next.config.js | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 361a560f2379ec..6ee264f480ebbd 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -256,38 +256,18 @@ const nextConfig = (phase) => { skipDefaultConversion: true, preventFullImport: true, }, - "@calcom/features/bookings": { - transform: "@calcom/features/bookings/{{member}}", + "@calcom/features/eventtypes/components": { + transform: "@calcom/features/eventtypes/components/{{member}}", skipDefaultConversion: true, preventFullImport: true, }, - "@calcom/features/eventtypes": { - transform: "@calcom/features/eventtypes/{{member}}", - skipDefaultConversion: true, - preventFullImport: true, - }, - "@calcom/features/insights": { - transform: "@calcom/features/insights/{{member}}", - skipDefaultConversion: true, - preventFullImport: true, - }, - "@calcom/features/webhooks": { - transform: "@calcom/features/webhooks/{{member}}", - skipDefaultConversion: true, - preventFullImport: true, - }, - "@calcom/features/auth": { - transform: "@calcom/features/auth/{{member}}", - skipDefaultConversion: true, - preventFullImport: true, - }, - "@calcom/features/shell": { - transform: "@calcom/features/shell/{{member}}", + "@calcom/features/insights/components": { + transform: "@calcom/features/insights/components/{{member}}", skipDefaultConversion: true, preventFullImport: true, }, - "@calcom/features/ee": { - transform: "@calcom/features/ee/{{member}}", + "@calcom/features/webhooks/components": { + transform: "@calcom/features/webhooks/components/{{member}}", skipDefaultConversion: true, preventFullImport: true, }, From 9d42a7936fab33515a0458496bed1673a79db30c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 20:23:54 +0000 Subject: [PATCH 4/5] fix: remove problematic webpack configuration causing CI failures - Remove sideEffects: false setting that was causing JavaScript heap out of memory errors - Remove overlapping lib, appStore, and shared cacheGroups that were conflicting - Keep essential optimizations: repositories, features, and prisma cacheGroups - Maintain FeaturesRepository reduction from 40 to 3 instances Addresses CodeRabbit feedback on webpack configuration issues Co-Authored-By: keith@cal.com --- apps/web/next.config.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 6ee264f480ebbd..85a06b067a446f 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -310,7 +310,6 @@ const nextConfig = (phase) => { config.optimization = { ...config.optimization, usedExports: true, - sideEffects: false, splitChunks: { ...config.optimization.splitChunks, cacheGroups: { @@ -329,20 +328,6 @@ const nextConfig = (phase) => { priority: 25, enforce: true, }, - lib: { - test: /[\\/]packages[\\/]lib[\\/]/, - name: "lib", - chunks: "all", - priority: 22, - enforce: true, - }, - appStore: { - test: /[\\/]packages[\\/]app-store[\\/]/, - name: "app-store", - chunks: "all", - priority: 28, - enforce: true, - }, prisma: { test: /[\\/]packages[\\/]prisma[\\/]|[\\/]node_modules[\\/]@prisma[\\/]/, name: "prisma", @@ -350,14 +335,6 @@ const nextConfig = (phase) => { priority: 20, enforce: true, }, - shared: { - test: /[\\/]packages[\\/]lib[\\/]/, - name: "shared-lib", - chunks: "all", - priority: 15, - minChunks: 2, - enforce: true, - }, }, }, }; From 9d1318c2ca1ad2a1286d0328e839f026c378435b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 20:47:10 +0000 Subject: [PATCH 5/5] feat: improve webpack regex patterns to match node_modules/@calcom paths - Enhanced repositories cacheGroup regex to match both packages/ and node_modules/@calcom/ paths - Improved features cacheGroup regex for better module resolution - Added case-insensitive matching and support for .tsx/.jsx extensions - Addresses CodeRabbit feedback for more comprehensive webpack optimization Co-Authored-By: keith@cal.com --- apps/web/next.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 85a06b067a446f..e755f6c057148f 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -315,14 +315,14 @@ const nextConfig = (phase) => { cacheGroups: { ...config.optimization.splitChunks?.cacheGroups, repositories: { - test: /[\\/]packages[\\/].*repository\.(ts|js)$/, + test: /[\\/](?:packages|node_modules[\\/]@calcom)[\\/].*Repository\.(t|j)sx?$/i, name: "repositories", chunks: "all", priority: 30, enforce: true, }, features: { - test: /[\\/]packages[\\/]features[\\/]/, + test: /[\\/](?:packages|node_modules[\\/]@calcom)[\\/]features[\\/]/, name: "features", chunks: "all", priority: 25,