Skip to content

Use typegraphql-prisma with ES Modules #370

Answered by valerii15298
valerii15298 asked this question in Q&A
Discussion options

You must be logged in to vote

Finally I found the way. The easiest solution for me was to create empty package.json with content {} like this:

prisma generate && echo {} > ./node_modules/@generated/type-graphql/package.json

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 creating package.json inside ./node_modules/@generated/type-graphql/ just solved everything.

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
8 replies
@MichalLytek
Comment options

@valerii15298
Comment options

@MichalLytek
Comment options

@valerii15298
Comment options

@valerii15298
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by valerii15298
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants