Prisma-client-js: Build for a different target

Created on 9 Jul 2019  路  3Comments  路  Source: prisma/prisma-client-js

For providers like AWS Lambda, GCP Cloud Functions, Netlify functions the bundling happens locally and the payload is deployed to the provider.

The binary workflow spec mentions a target parameter to mitigate this but in current state of our workflow, download step is at yarn or npm install which is never executed when deploying to these platforms.

We might need a way to build for a remote target or solve this by configuration.

kinquestion

Most helpful comment

Would it make sense for the binary download to happen lazily at the generation step?

That seems to solve this problem as the user would be able to simply run prisma2 generate after changing the target setting to get the correct binary.

All 3 comments

Would it make sense for the binary download to happen lazily at the generation step?

That seems to solve this problem as the user would be able to simply run prisma2 generate after changing the target setting to get the correct binary.

Just to summarize my understanding of this suggestion:

prisma2 generate downloads a binary for local machine's platform and a binary for target specified in Prisma project config file, then Photon can somehow dynamically resolve the correct binary, on deploy we upload both binaries?

This might work.

Follow up questions:

  • How do I target multiple platforms?
  • Is hidden dynamic binary resolution logic in photon good or should we expose it to use (via docs) and make it more deterministic and less magic?

This has been released in preview-3 https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md#specifying-the-right-platform-for-photon-js

Was this page helpful?
0 / 5 - 0 ratings