prisma-nestjs-graphql icon indicating copy to clipboard operation
prisma-nestjs-graphql copied to clipboard

Final JS file Too big using emitSingle (is including all generated classes)

Open AdsonCicilioti opened this issue 4 years ago • 2 comments

The application build results in a very large index.js file, containing all the classes generated from my models in schema.prisma.

I see a problem with this as I won't use all generated classes. In this scenario I don't know who is responsible for including all classes in the schema.graphql generation. I thought they would only be included as I was importing them into my providers.

I think the ideal scenario would be to generate the index.js file according to the use of classes (in DTOs, Entities, etc).

Would this already be possible in any way?

AdsonCicilioti avatar Oct 02 '21 11:10 AdsonCicilioti

It is not possible. Generator doesnt know which classes will be used. You can generate abstract classes and then inherit only required. But index js still stays large in size.

unlight avatar Oct 02 '21 13:10 unlight

It is not possible. Generator doesnt know which classes will be used. You can generate abstract classes and then inherit only required. But index js still stays large in size.

I understand. a "Shaking Tree" deal in the transpiled version after the build would be interesting.

Maybe the best choice for an project with great number of models, will be without emitSingle.

AdsonCicilioti avatar Oct 03 '21 00:10 AdsonCicilioti