QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.83k stars 1.31k forks source link

[🐞] Build with Prisma and Netlify adapter FAILS #3784

Open y471n opened 1 year ago

y471n commented 1 year ago

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

I added Prisma in endpoints and tried fetching data with it. The build fails with Netlify with the following error:

Packaging Edge Functions from .netlify/edge-functions directory:
 - entry.netlify-edge
error: Uncaught (in promise) Error: Relative import path ".prisma/client/index-browser" not prefixed with / or ./ or ../ and not in import map from "file:///root/.netlify/edge-functions/entry.netlify-edge/assets/@qwik-city-plan-50bb4998.js"

Reproduction

NA

Steps to reproduce

No response

System Info

NA

Additional Information

No response

y471n commented 1 year ago

With Vercel I end up the following error during build:


Error: The Edge Function "_qwik-city" is referencing unsupported modules:
--
06:35:02.062 | - assets/@qwik-city-plan-e244df1e.js: .prisma/client/index-browser
06:35:02.156 | Deployment completed
06:35:02.107 | NOW_SANDBOX_WORKER_EDGE_FUNCTION_UNSUPPORTED_MODULES: The Edge Function "_qwik-city" is referencing unsupported modules: - assets/@qwik-city-plan-e244df1e.js: .prisma/client/index-browser
manucorporat commented 1 year ago

You need to provide a repo case, we can't help without a way to reproduce it!

y471n commented 1 year ago

Here's a demo Github Repo with the same issue: https://github.com/y471n/qwik-demo-app-with-prisma

Error: The Edge Function "_qwik-city" is referencing unsupported modules:
--
14:36:34.299 | - @qwik-city-plan.js: .prisma/client/index-browser
14:36:34.369 | Deployment completed
14:36:34.331 | NOW_SANDBOX_WORKER_EDGE_FUNCTION_UNSUPPORTED_MODULES: The Edge Function "_qwik-city" is referencing unsupported modules: - @qwik-city-plan.js: .prisma/client/index-browser

Just deploy to Vercel to validate this issue. Let me know if I can help in some way. Thanks @manucorporat

DennisVanIngen commented 1 year ago

In my project, I also did run into this error on Vercel:

Error: The Edge Function "_qwik-city" is referencing unsupported modules:
--
21:05:07.798 | - @qwik-city-plan.js: .prisma/client/edge
21:05:08.302 | Deployment completed
21:05:07.907 | NOW_SANDBOX_WORKER_EDGE_FUNCTION_UNSUPPORTED_MODULES: The Edge Function "_qwik-city" is referencing unsupported modules: - @qwik-city-plan.js: .prisma/client/edge
y471n commented 1 year ago

Guys, till this is resolved either from Prisma or QwikJS. Any other recommendations of an ORM that plays nice with Qwik?

igalklebanov commented 1 year ago

@y471n

Guys, till this is resolved either from Prisma or QwikJS. Any other recommendations of an ORM that plays nice with Qwik?

https://dev.to/nexxeln/typesafe-database-queries-on-the-edge-5bbn

People have opted for prisma for migrations/schemas and https://github.com/kysely-org/kysely for data access. There's https://github.com/valtyr/prisma-kysely to help bridge the gap.

DaleWebb commented 1 year ago

@y471n - You can't use @prisma/client on the edge. You can only use Prisma's Data Proxy on the edge via the @prisma/client/edge package.

manucorporat commented 1 year ago

This also got me by surprise to be honest!

this week added integration with Prisma and I was not aware of the limitations with the edge

gustavocadev commented 1 year ago

I got this error on vercel too:

TypeError [PLUGIN_ERROR]: Invalid module ".prisma/client/index-browser"
is not a valid package name imported from /vercel/path0/.vercel/output/functions/_qwik-city.func/@qwik-city-plan.js
GrandSchtroumpf commented 1 year ago

I've run into a similar issue with another library (ethers) The problem is that Edge Functions are using a specific environment (not node), so a lot of lib are not working. One issue though is when you use the lib only on the front, but it ends up in the output for vercel. I would be nice to strip out all frontend specific code (everything inside event$ or useVisibleTask$) from the server output

gioboa commented 1 year ago

@ruheni do you have any insights? Thanks in advance