Bundling prisma2 with the plugin
See original GitHub issueHi,
I’m having trouble initializing prisma when using the serverless-bundle plugin
Prisma needs to run a script “prisma generate” and uses a schema.prisma file (that i need to copy into the webpack bundle process) in order to make the client to access the database. I have added this part in the custom options of the plugin like so:
custom:
bundle:
copyFiles:
- from: "prisma/schema.prisma"
to: "./"
packagerOptions:
scripts:
- prisma generate
But then when I run serverless offline and i execute an api i get this error:
Failed to execute scheduled function: [hello] Error: Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again
It looks as though the script is not being run. Is there a way to see logs and see what is happening during the bundling process? Maybe the script is failing and it would be easier if i could see the output of the script.
Node Version : 14.0.0 NPM Version: 6.9.0 Serverless Bundle version: 3.2.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
I came back to this and tried this setup with these configs: Node version : 14.0.0 serverless: 2.33.1 serverless-bundle: 3.0.0
Looks like prisma has to be added in to the externals sections in order to work properly
I think adding prisma to the default list of externals would be a good idea in this case. This should probably be closed now since adding prisma to the externals options does do the trick, but i will leave it open in case it is used as a reference to add prisma to the default externals list or something.
We are currently relying on serverless-webpack for the custom scripts: https://github.com/serverless-heaven/serverless-webpack#custom-scripts
Does anybody want to take a look why it’s not being invoked?