#Cloudflare D1 adapter explodes bundle size

2 messages · Page 1 of 1 (latest)

wet spindle
#

Hello! I setup a barebones app with Prisma on D1. I added prisma, @prisma/adapter-d1, and @prisma/client as dependencies. I'm importing and constructing following the instructions:

import { PrismaD1 } from "@prisma/adapter-d1";
import { PrismaClient } from "@prisma/client";

export async function addEmail(email: string, env: Env): Promise<number> {
  const adapter = new PrismaD1(env.DB);
  const prisma = new PrismaClient({ adapter });

However: My app now fails to deploy because the bundle is too big (beyond 1MB). Cloudflare helped me debug that the majority of this is coming from "query_engine_bg", which appears to be Prisma. My total deployment is now 4.2 MB, which is beyond the 1MB allowed on free plans.

Is it possible to use Prisma on a free plan with under 1 MB of JS, or is it just too big and I should go find something else?

#

My Prisma file if it matters:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

// This `datasource` file isn't used but Prisma ORM still requires the `datasource` definition.
// Your SQLite database file will be managed by D1:
// - A local version will exist in `.wrangler`.
// - The remote version is managed by Cloudflare in the Cloud.
datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model HotelWaitlist {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}