Closed BeBoRE closed 11 months ago
I am now using tsx
and that seems to have fixed the issues. But I do still think that you should consider using tsup
to support ts-node when using CommonJS modules.
We don't intend to support CommonJS
@pilcrowOnPaper The Prisma adapter seems to not work for me because of this? I get ERR_REQUIRE_ESM
Those those utilizing lucia
with NestJS or commonJS, you can utilize dynamic imports to get around this issue.
const dynamicImport = async (packageName: string) =>
new Function(`return import('${packageName}')`)();
@Module({
providers: [
{
provide: AUTH,
async useFactory() {
return (await dynamicImport('./lucia')).lucia;
},
},
],
exports: [AUTH],
})
export class AuthModule {}
Those those utilizing
lucia
with NestJS or commonJS, you can utilize dynamic imports to get around this issue.const dynamicImport = async (packageName: string) => new Function(`return import('${packageName}')`)();
@Module({ providers: [ { provide: AUTH, async useFactory() { return (await dynamicImport('./lucia')).lucia; }, }, ], exports: [AUTH], }) export class AuthModule {}
you lose type safety though
Package
@lucia-auth/adapter-postgresql
Describe the bug
Because @lucia-auth/adapter-postgresql is of type "module" I am unable to use it in my project. Trying to import the adapter it will throw the error:
I have not been able to convert my packages to type "module" without running into other issues.
Can you consider using tsup to build both an ESM and CJS bundle and removing
type: "module"
?