Skip to content

Commit 51bce67

Browse files
keithwillcodedevin-ai-integration[bot]dhairyashiil
authored
refactor: split tRPC build into server and react phases (calcom#26082)
* refactor: import AppRouter from generated types instead of server source This change improves tRPC build performance by having the client-side code import AppRouter from pre-generated type declarations instead of traversing the entire server router tree. Changes: - Create type bridge file at packages/trpc/types/app-router.ts - Update packages/trpc/react/trpc.ts to import from the bridge - Update .gitignore to only ignore types/server (generated files) - Update eslint.config.mjs to only ignore types/server (generated files) The type bridge provides: 1. Faster typechecking - avoids parsing 458 server files 2. Stable import location that's easy to lint against 3. Single place to adjust if generated path changes Build order is already enforced in turbo.json (type-check depends on @calcom/trpc#build). Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: move bridge file to react/ to avoid TS5055 error Move the AppRouter type bridge file from types/app-router.ts to react/app-router.ts to avoid the TS5055 'Cannot write file because it would overwrite input file' error. The issue was that placing the bridge file in types/ caused TypeScript to treat the generated .d.ts files as input files during the tRPC build, then fail when trying to emit to the same location. By placing the bridge in react/ (which is excluded from the tRPC server build), the bridge file is only used by client code and doesn't interfere with the server type generation. Changes: - Move bridge file from types/app-router.ts to react/app-router.ts - Update import in react/trpc.ts to use ./app-router - Revert .gitignore to ignore all of types/ (generated files) - Revert eslint.config.mjs to ignore all of types/** Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: split tRPC build into server and react phases - Create tsconfig.server.json for server-only type generation - Create tsconfig.react.json for react/client type generation - Update build script to run server build first, then react build - Remove || true so build properly fails on errors - This allows react code to import from generated server types Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: split @calcom/trpc exports to separate server and react entrypoints - Remove react exports from @calcom/trpc root (index.ts) - Update 89 files to import from @calcom/trpc/react instead of @calcom/trpc - This fixes the boundary leak where server builds were pulling in react code - Server build no longer compiles react/app-router.ts, fixing the chicken-and-egg issue where react code needed generated server types that didn't exist yet This improves TypeScript build performance by preventing the server type generation from traversing the entire react/client type graph. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: import WorkflowType from lib/types instead of React component This fixes a boundary leak where the server build was pulling in React components through the WorkflowRepository import chain. By importing WorkflowListType from lib/types instead of WorkflowListPage.tsx, the server build no longer traverses React component files. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: extract server-safe types to prevent boundary leaks in tRPC build - Extract ChildrenEventType to lib/childrenEventType.ts (server-safe) - Extract Slots type to calendars/lib/slots.ts (server-safe) - Create types.server.ts files for eventtypes and bookings - Update server code to import from server-safe type files - Update DatePicker.tsx to use extracted Slots type - Update app-store utils to use BookerEventForAppData type This prevents the server build from pulling in React files through transitive imports from @calcom/features barrel exports. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: update Segment.test.tsx mock path to @calcom/trpc/react The test was mocking @calcom/trpc but importing from @calcom/trpc/react. After the entrypoint separation, the mock path needs to match the import path. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: temporarily restore || true to unblock PR merge The pre-existing Prisma type errors (~345 errors) will be addressed in a follow-up PR. This allows the two-phase build architecture changes to be merged first. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Run trpc build as part of API v2 build * Removed the bridge file * refactor: extract event type schemas to server-safe file - Create packages/features/eventtypes/lib/schemas.ts with createEventTypeInput and EventTypeDuplicateInput - Update types.ts to re-export schemas from the new server-safe location - Update tRPC schema files to import from schemas.ts instead of types.server.ts - Delete types.server.ts (was duplicating ~200 lines unnecessarily) This keeps the server build graph clean while avoiding code duplication. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Removed the optionality of the tRPC builds * Removed the extra command for API v2 * refactor: rename calendars/lib/slots.ts to types.ts Per Keith's feedback, renamed the file to types.ts since it contains type definitions. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Added back tRPC build:server for API v2 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com>
1 parent 0e3696f commit 51bce67

109 files changed

Lines changed: 283 additions & 202 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/api/v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"_dev:build:watch:enums": "yarn workspace @calcom/platform-enums build:watch",
1717
"_dev:build:watch:utils": "yarn workspace @calcom/platform-utils build:watch",
1818
"_dev:build:watch:types": "yarn workspace @calcom/platform-types build:watch",
19-
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-enums build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build && yarn workspace @calcom/platform-libraries build",
19+
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-enums build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build && yarn workspace @calcom/platform-libraries build && yarn workspace @calcom/trpc build:server",
2020
"dev": "yarn dev:build && ts-node scripts/docker-start.ts && yarn copy-swagger-module && yarn start --watch",
2121
"dev:no-docker": "yarn dev:build && yarn copy-swagger-module && yarn start --watch",
2222
"start:debug": "nest start --debug --watch",

apps/web/components/apps/alby/AlbyPaymentComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/paymen
1010
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
1111
import { useCopy } from "@calcom/lib/hooks/useCopy";
1212
import { useLocale } from "@calcom/lib/hooks/useLocale";
13-
import { trpc } from "@calcom/trpc";
13+
import { trpc } from "@calcom/trpc/react";
1414
import { Button } from "@calcom/ui/components/button";
1515
import { Spinner } from "@calcom/ui/components/icon";
1616
import { showToast } from "@calcom/ui/components/toast";

apps/web/components/apps/alby/Setup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { albyCredentialKeysSchema } from "@calcom/app-store/alby/lib/albyCredent
99
import type { IAlbySetupProps } from "@calcom/app-store/alby/pages/setup/_getServerSideProps";
1010
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
1111
import { useLocale } from "@calcom/lib/hooks/useLocale";
12-
import { trpc } from "@calcom/trpc";
12+
import { trpc } from "@calcom/trpc/react";
1313
import { Badge } from "@calcom/ui/components/badge";
1414
import { Button } from "@calcom/ui/components/button";
1515
import { Icon } from "@calcom/ui/components/icon";

apps/web/components/apps/btcpayserver/BtcpayPaymentComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/paymen
88
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
99
import { useCopy } from "@calcom/lib/hooks/useCopy";
1010
import { useLocale } from "@calcom/lib/hooks/useLocale";
11-
import { trpc } from "@calcom/trpc";
11+
import { trpc } from "@calcom/trpc/react";
1212
import { Button } from "@calcom/ui/components/button";
1313
import { Spinner } from "@calcom/ui/components/icon";
1414
import { showToast } from "@calcom/ui/components/toast";

apps/web/components/apps/btcpayserver/Setup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { IBTCPaySetupProps } from "@calcom/app-store/btcpayserver/pages/set
1414
import { WEBAPP_URL } from "@calcom/lib/constants";
1515
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
1616
import { useLocale } from "@calcom/lib/hooks/useLocale";
17-
import { trpc } from "@calcom/trpc";
17+
import { trpc } from "@calcom/trpc/react";
1818
import { Button } from "@calcom/ui/components/button";
1919
import { Icon } from "@calcom/ui/components/icon";
2020
import { showToast } from "@calcom/ui/components/toast";

apps/web/components/apps/hitpay/Setup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { hitpayCredentialKeysSchema } from "@calcom/app-store/hitpay/lib/hitpayC
1313
import type { IHitPaySetupProps } from "@calcom/app-store/hitpay/pages/setup/_getServerSideProps";
1414
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
1515
import { useLocale } from "@calcom/lib/hooks/useLocale";
16-
import { trpc } from "@calcom/trpc";
16+
import { trpc } from "@calcom/trpc/react";
1717
import { Button } from "@calcom/ui/components/button";
1818
import { Switch } from "@calcom/ui/components/form";
1919
import { Icon } from "@calcom/ui/components/icon";

apps/web/components/apps/paypal/Setup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Toaster } from "sonner";
44

55
import AppNotInstalledMessage from "@calcom/app-store/_components/AppNotInstalledMessage";
66
import { useLocale } from "@calcom/lib/hooks/useLocale";
7-
import { trpc } from "@calcom/trpc";
7+
import { trpc } from "@calcom/trpc/react";
88
import { Button } from "@calcom/ui/components/button";
99
import { TextField } from "@calcom/ui/components/form";
1010
import { Icon } from "@calcom/ui/components/icon";
@@ -101,7 +101,7 @@ export default function PayPalSetup() {
101101
<a
102102
className="text-orange-600 underline"
103103
target="_blank"
104-
href="https://developer.paypal.com/api/rest/#link-getclientidandclientsecret">
104+
href="https://developer.paypal.com/api/rest/#link-getclientidandclientsecret" rel="noreferrer">
105105
Link to Paypal developer API REST Setup Guide:
106106
https://developer.paypal.com/api/rest/#link-getclientidandclientsecret
107107
</a>
@@ -120,7 +120,7 @@ export default function PayPalSetup() {
120120
<a
121121
target="_blank"
122122
href="https://developer.paypal.com/dashboard/applications/live"
123-
className="text-orange-600 underline">
123+
className="text-orange-600 underline" rel="noreferrer">
124124
{t("here")}
125125
</a>
126126
.

apps/web/components/apps/routing-forms/TestForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useOrgBranding } from "@calcom/features/ee/organizations/context/provid
1515
import { WEBSITE_URL } from "@calcom/lib/constants";
1616
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
1717
import { useLocale } from "@calcom/lib/hooks/useLocale";
18-
import { trpc } from "@calcom/trpc";
18+
import { trpc } from "@calcom/trpc/react";
1919
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
2020
import type { Brand } from "@calcom/types/utils";
2121
import { Button } from "@calcom/ui/components/button";

apps/web/modules/auth/verify-email-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useEffect } from "react";
88
import { useFlagMap } from "@calcom/features/flags/context/provider";
99
import { APP_NAME } from "@calcom/lib/constants";
1010
import { useLocale } from "@calcom/lib/hooks/useLocale";
11-
import { trpc } from "@calcom/trpc";
11+
import { trpc } from "@calcom/trpc/react";
1212
import useEmailVerifyCheck from "@calcom/trpc/react/hooks/useEmailVerifyCheck";
1313
import { Button } from "@calcom/ui/components/button";
1414
import { EmptyScreen } from "@calcom/ui/components/empty-screen";

apps/web/modules/connect-and-join/connect-and-join-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-para
99
import ServerTrans from "@calcom/lib/components/ServerTrans";
1010
import { WEBAPP_URL } from "@calcom/lib/constants";
1111
import { useLocale } from "@calcom/lib/hooks/useLocale";
12-
import { trpc } from "@calcom/trpc";
12+
import { trpc } from "@calcom/trpc/react";
1313
import { Alert } from "@calcom/ui/components/alert";
1414
import { Button } from "@calcom/ui/components/button";
1515
import { EmptyScreen } from "@calcom/ui/components/empty-screen";

0 commit comments

Comments
 (0)