chore: reduce atoms bundle size prisma types (#24001)

* chore: use kysely types instead of prisma types in atoms

* fixup! chore: use kysely types instead of prisma types in atoms

* fixup! Merge branch 'main' into reduce-atoms-bundle-size-prisma-types
This commit is contained in:
Morgan
2025-09-25 08:06:16 +05:30
committed by GitHub
parent f11c4dd7ec
commit 752cfa6bf9
6 changed files with 52 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@calcom/atoms": minor
---
Reduced bundle size by removing unnecessary types
@@ -0,0 +1,2 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
export type ColumnType<SelectType, InsertType = SelectType, UpdateType = SelectType> = SelectType;
+1 -1
View File
@@ -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",
@@ -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>;
+5 -1
View File
@@ -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",
+30 -6
View File
@@ -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"),