Vite + D1 + Cloudflare Workers + Prisma

I've used Prisma + D1 + Cloudflare workers before and it's been a great experience.

I'm not trying to use the same tack with Vite + Honox (https://github.com/honojs/honox/tree/main) in the mix.

My vite config uses two plugins:
import build from "@hono/vite-build/cloudflare-workers";
import honox from "honox/vite";


Using prisma modules causes errors:
e.g.
import { PrismaD1 } from "@prisma/adapter-d1";
const adapter = new PrismaD1(c.env.DB);


causes this error

module is not defined
    at eval (/home/ubuntu/projects/admin/node_modules/@prisma/debug/dist/index.js:30:1)
    at instantiateModule (file:///home/ubuntu/projects/admin/node_modules/vite/dist/node/chunks/dep-CHZK6zbr.js:52974:11


Are there any tricks to a vite config that will work with Prisma client libraries, but also allow the cloudflare worker build plugin to work (to rollup into a single output file with no external dependencies)
GitHub
HonoX - Hono based meta framework. Contribute to honojs/honox development by creating an account on GitHub.
Was this page helpful?