Use typegraphql-prisma with ES Modules #370
-
Is it possible to use typegraphql-prisma with ES Modules? Or are there any workarounds to make it work in nestjs + prisma + typegraphql-prisma project? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Have you tried and have some issues or just asking ahead of time? |
Beta Was this translation helpful? Give feedback.
-
Finally I found the way. The easiest solution for me was to create empty
After that my project that uses ESM was able successfully import everything from generated types. |
Beta Was this translation helpful? Give feedback.
-
I have stumbled upon the same use case and wasn't able to resolve it using the provided solutions. |
Beta Was this translation helpful? Give feedback.
Finally I found the way. The easiest solution for me was to create empty
package.json
with content{}
like this:After that my project that uses ESM was able successfully import everything from generated types.
As I understood generated files here
./node_modules/@generated/type-graphql/
use CommonJS but in order for ESM project to import cjs project it needs to know that it is a separate package. So creatingpackage.json
inside./node_modules/@generated/type-graphql/
just solved everything.