High CPU usage when importing the library on a monorepo

As I am splitting my application into a monorepo solution using NX, I am facing performance issues with better-auth due to a recursive type in the automatic inference. The configuration it's pretty much straightforward:
import { prismaClient } from '@libs/shared';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';

export const auth = betterAuth({
baseUrl: process.env['APP_ADMIN_BETTER_AUTH_BASE_URL'],
secret: process.env['APP_ADMIN_BETTER_AUTH_SECRET'],
emailAndPassword: {
enabled: true,
autoSignIn: true,
minPasswordLength: 8,
maxPasswordLength: 100,
},
database: prismaAdapter(prismaClient, {
provider: 'postgresql',
}),
session: {
storeSessionInDatabase: true,
expiresIn: 60 * 60 * 24 * 30, // 30 days
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24 * 30, // 30 days
},
},
});

export const teste = await auth.api.createUser({
password: 'teste',
});
import { prismaClient } from '@libs/shared';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';

export const auth = betterAuth({
baseUrl: process.env['APP_ADMIN_BETTER_AUTH_BASE_URL'],
secret: process.env['APP_ADMIN_BETTER_AUTH_SECRET'],
emailAndPassword: {
enabled: true,
autoSignIn: true,
minPasswordLength: 8,
maxPasswordLength: 100,
},
database: prismaAdapter(prismaClient, {
provider: 'postgresql',
}),
session: {
storeSessionInDatabase: true,
expiresIn: 60 * 60 * 24 * 30, // 30 days
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24 * 30, // 30 days
},
},
});

export const teste = await auth.api.createUser({
password: 'teste',
});
`
Type instantiation is excessively deep and possibly infinite.ts(2589)
Type instantiation is excessively deep and possibly infinite.ts(2589)
No description
No description
2 Replies
Reis
ReisOP5mo ago
setting the strict: true and declaration: false in my tsconfig helped me to improve the performance]
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?