-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐞]Building Prisma with Vercel-Edge generates compile errors #4075
Comments
Start a new pull request in StackBlitz Codeflow. |
Prisma is well known for not working well in edge, unfortunately, not the best choice to deploy in edge |
But going to look into the error |
thanks - I know about the cautions with Prisma and the edge and will likely abandon it - just thought you should know about this problem. BTW: the same problem occurs with the CloudFlare Pages adapter. I forgot to note this nuance. Build works with the dependency but as soon as you add a call (let prisma = new PrismaClient()) the compile error surfaces. |
I have the same problem with the Netlify adapter. Error: 7:18:32 PM: error during build: |
Same error on deno adapter as well |
Adding this to my vite.config.ts seems to fix it for me:
|
This configuration solves the build error, but prisma isn't working as expected at runtime. |
It does seem to work fine, although I haven't tested it thoroughly. However, I do get an error when deploying to Vercel, Netlify or Cloudflare Pages (looks like PrismaClient runs from the browser for some reason), see this comment. Not sure if it has to do with this fix |
@ruheni can you help us with this issue pls? |
This fixes only the app build, but when deploying the Vercel app it crashes again. |
Prisma has a well known issue with edge function. There is an issue in their repository |
I found a workaround and that is to deploy qwik with express on Vercel, without the Vercel-Edge adapter. |
@kokecar11 |
Could you try that and let us know if that works for you? See: I found out that this could be solved with 2 aliases, see my repro here: https://github.com/Jolg42/prisma-repro-21094 This is what worked for me: import { vercelEdgeAdapter } from "@builder.io/qwik-city/adapters/vercel-edge/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";
export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ["src/entry.vercel-edge.tsx", "@qwik-city-plan"],
},
outDir: ".vercel/output/functions/_qwik-city.func",
},
plugins: [vercelEdgeAdapter()],
resolve: {
alias: {
".prisma/client/default": "./node_modules/.prisma/client/default.js",
"./query_engine_bg.wasm?module": "./node_modules/.prisma/client/query_engine_bg.wasm?init",
},
},
};
}); I found out about this in Vite's docs here https://vitejs.dev/guide/features#webassembly
Originally posted by @Jolg42 in prisma/prisma#21094 (comment) |
@Jolg42 I personally get a new error when doing this workaround: ReferenceError: __dirname is not defined in ES module scope, Seems because __dirname is a CommonJS variable that is not available in ES module scope. |
@PerfectedApp Did you try the reproduction repo I shared in my previous comment? I guess that if you try that code it works? |
I found a solution for my end, but it seems it does need to be patched on Qwik City. the opts["qwikCityPlanModulePath'} import { fileURLToPath } from 'url'; And for resolve, as I'm using Turso sqlite: resolve: { |
me too both netlify and vercel |
Which component is affected?
Qwik Runtime
Describe the bug
I created the starter app and added two integrations: Prisma and Vercel-Edge. Here is the sequence:
.prisma/client/index-browser" is imported by ".prisma/client/index-browser?commonjs-external", but could not be resolved – treating it as an external dependency.
error during build:
TypeError [PLUGIN_ERROR]: Invalid module ".prisma/client/index-browser" is not a valid package name imported from /Users/noahshaffer/WebstormProjects/qwik-prisma-vercel-test/.vercel/output/functions/_qwik-city.func/@qwik-city-plan.js
at new NodeError (node:internal/errors:399:5)
at parsePackageName (node:internal/modules/esm/resolve:817:11)
at packageResolve (node:internal/modules/esm/resolve:840:5)
at moduleResolve (node:internal/modules/esm/resolve:938:20)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
I've had this same problem with using npm (in another sample) and pnpm.
Reproduction
https://stackblitz.com/edit/qwik-starter-eyehgf?file=package.json
Steps to reproduce
.prisma/client/index-browser" is imported by ".prisma/client/index-browser?commonjs-external", but could not be resolved – treating it as an external dependency.
error during build:
TypeError [PLUGIN_ERROR]: Invalid module ".prisma/client/index-browser" is not a valid package name imported from /Users/noahshaffer/WebstormProjects/qwik-prisma-vercel-test/.vercel/output/functions/_qwik-city.func/@qwik-city-plan.js
at new NodeError (node:internal/errors:399:5)
at parsePackageName (node:internal/modules/esm/resolve:817:11)
at packageResolve (node:internal/modules/esm/resolve:840:5)
at moduleResolve (node:internal/modules/esm/resolve:938:20)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
I've had this same problem with using npm (in another sample) and pnpm.
System Info
Additional Information
Note: this is not really Qwik runtime - but I could not figure out what category the issue falls in.
The text was updated successfully, but these errors were encountered: