Closed donnguyen closed 10 months ago
It sounds NestJS is running in commonjs but this extension currently only supports ESM at the moment. I'm not too familiar with how NestJS apps are built but it seems like there is a compilation step anyway so would it be possible to switch to ESM for your application?
I've created a quick demo app in stackblitz with the latest version of NestJS and it seems to be running fine.
Thanks, @adamjkb. Can you save me the demo app on stackblitz please?
Actually, never mind. It works with "moduleResolution": "node16",
added to typescript config. Cheers
Just share what we did here in case anyone needs it:
import { PrismaClient } from '@prisma/client';
import { type withBark } from 'prisma-extension-bark';
async function getWithBark(): Promise<typeof withBark> {
const module = await (eval(`import('prisma-extension-bark')`) as Promise<any>);
return module.withBark;
}
export const getPrismaClient = async () => {
const withBark = await getWithBark();
return new PrismaClient({
log: ['query', 'info', 'warn'],
}).$extends(withBark({ modelNames: ['folder'] }));
};
export type ExtendedPrismaClient = Awaited<ReturnType<typeof getPrismaClient>>;
Hi there,
We are looking forward to trying this out but couldn't import it in our NestJS app. Can you please declare
main
in package.json file and publish a new release?Thank you