Scheduling infrastructure for absolutely everyone.
chore: reduce atoms bundle size prisma types (#24001)
Morgan752cfa6bf98a
diff --git a/.changeset/ninety-colts-search.md b/.changeset/ninety-colts-search.mdnew file mode 100644index 00000000000..111894b687f--- /dev/null+++ b/.changeset/ninety-colts-search.md@@ -0,0 +1,5 @@+---+"@calcom/atoms": minor+---++Reduced bundle size by removing unnecessary typesdiff --git a/packages/platform/atoms/kysely-types/index.ts b/packages/platform/atoms/kysely-types/index.tsnew file mode 100644index 00000000000..9fe826d1156--- /dev/null+++ b/packages/platform/atoms/kysely-types/index.ts@@ -0,0 +1,2 @@+/* eslint-disable @typescript-eslint/no-unused-vars */+export type ColumnType<SelectType, InsertType = SelectType, UpdateType = SelectType> = SelectType;diff --git a/packages/platform/atoms/package.json b/packages/platform/atoms/package.jsonindex 6c05117534e..b186b9a7349 100644--- a/packages/platform/atoms/package.json+++ b/packages/platform/atoms/package.json@@ -7,7 +7,7 @@"version": "1.9.0","scripts": {"dev": "yarn vite build --watch & npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify --watch",- "build": "NODE_OPTIONS='--max_old_space_size=12288' rm -rf dist && yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify && mkdir ./dist/packages/prisma-client && cp -rf ../../prisma/client/*.d.ts ./dist/packages/prisma-client",+ "build": "NODE_OPTIONS='--max_old_space_size=12288' rm -rf dist && yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify","publish-npm": "yarn build && npm publish --access public","test": "jest","dev-on": "node scripts/dev-on.js",diff --git a/packages/platform/atoms/prisma-types/index.ts b/packages/platform/atoms/prisma-types/index.tsnew file mode 100644index 00000000000..b064ddbb851--- /dev/null+++ b/packages/platform/atoms/prisma-types/index.ts@@ -0,0 +1,9 @@+// src/prisma-types.ts++// These types are derived from Prisma's internal types+// to ensure type safety without importing the full client.+export type JsonValue = string | number | boolean | JsonObject | JsonArray | null;++export type JsonObject = { [key: string]: JsonValue };++export type JsonArray = Array<JsonValue>;diff --git a/packages/platform/atoms/tsconfig.json b/packages/platform/atoms/tsconfig.jsonindex 40d91f9f05f..f7cc9faa79d 100644--- a/packages/platform/atoms/tsconfig.json+++ b/packages/platform/atoms/tsconfig.json@@ -56,7 +56,11 @@"../../features/shell","../../features/components","../../features/form-builder",- "../../features/data-table"+ "../../features/data-table",+ "../../kysely/types.ts",+ "./prisma-types/index.ts",+ "./kysely-types/index.ts",+ "../../lib/intervalLimits/intervalLimitSchema.ts"],"exclude": ["dist",diff --git a/packages/platform/atoms/vite.config.ts b/packages/platform/atoms/vite.config.tsindex 975682e09da..4cbf2b5376e 100644--- a/packages/platform/atoms/vite.config.ts+++ b/packages/platform/atoms/vite.config.ts@@ -19,7 +19,23 @@ export default defineConfig(({ mode }) => {"@calcom/platform-utils",],},- plugins: [react(), dts({ insertTypesEntry: true })],+ plugins: [+ react(),+ dts({+ insertTypesEntry: true,+ beforeWriteFile: (filePath, content) => {+ // Check if the content includes the broken path from kysely+ if (content.includes(`kysely/types.ts').$Enums`)) {+ // Replace the broken path with the correct import+ return {+ filePath,+ content: content.replaceAll(`kysely/types.ts').$Enums`, `kysely/types.ts')`),+ };+ }+ return { filePath, content };+ },+ }),+ ],define: {"process.env.NEXT_PUBLIC_WEBAPP_URL": `"${webAppUrl}"`,},@@ -34,7 +50,16 @@ export default defineConfig(({ mode }) => {formats: ["es"],},rollupOptions: {- external: ["react", "fs", "path", "os", "react/jsx-runtime", "react-dom", "react-dom/client"],+ external: [+ "react",+ "fs",+ "path",+ "os",+ "react/jsx-runtime",+ "react-dom",+ "react-dom/client",+ "@prisma/client",+ ],output: {format: "esm",globals: {@@ -54,10 +79,9 @@ export default defineConfig(({ mode }) => {"@calcom/lib/hooks/useLocale": path.resolve(__dirname, "./lib/useLocale"),"@radix-ui/react-tooltip": path.resolve(__dirname, "./src/components/ui/tooltip.tsx"),"@radix-ui/react-dialog": path.resolve(__dirname, "./src/components/ui/dialog.tsx"),- ".prisma/client": path.resolve(__dirname, "../../prisma-client"),- "@prisma/client": path.resolve(__dirname, "../../prisma-client"),- "@calcom/prisma/client": path.resolve(__dirname, "../../prisma-client"),- "@calcom/prisma": path.resolve(__dirname, "../../prisma"),+ "@calcom/prisma/client/runtime/library": resolve("./prisma-types/index.ts"),+ "@calcom/prisma/client": path.resolve(__dirname, "../../kysely/types.ts"),+ kysely: path.resolve(__dirname, "./kysely-types/index.ts"),"@calcom/dayjs": path.resolve(__dirname, "../../dayjs"),"@calcom/platform-constants": path.resolve(__dirname, "../constants/index.ts"),"@calcom/platform-types": path.resolve(__dirname, "../types/index.ts"),