Unexpected "export *" warning with Prisma 6.16 in monorepo setup

Hello 👋 I’m working in a monorepo with Prisma (v6.16.0) and since updating, my dev server is spammed with the following warning:
unexpected export *
export * used with module [project]/packages/database/generated/client.js [app-route] (ecmascript)
which is a CommonJS module with exports only available at runtime

List all export names manually (`export { a, b, c } from "..."`) or rewrite the module to ESM,
to avoid the additional runtime code.
unexpected export *
export * used with module [project]/packages/database/generated/client.js [app-route] (ecmascript)
which is a CommonJS module with exports only available at runtime

List all export names manually (`export { a, b, c } from "..."`) or rewrite the module to ESM,
to avoid the additional runtime code.
Repository setup - Monorepo with Turborepo - Structure :
.
├── apps
│ └── vdee
├── packages
│ ├── database
│ │ ├── prisma/schema.prisma
│ │ ├── index.ts
│ │ └── package.json
│ └── my-zod
├── turbo.json
├── package.json
└── yarn.lock
.
├── apps
│ └── vdee
├── packages
│ ├── database
│ │ ├── prisma/schema.prisma
│ │ ├── index.ts
│ │ └── package.json
│ └── my-zod
├── turbo.json
├── package.json
└── yarn.lock
- schema.prisma (packages/database/prisma/schema.prisma):
generator client {
provider = "prisma-client-js"
moduleFormat = "esm"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
moduleFormat = "esm"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
- packages/database/index.ts:
export { Client } from "@planetscale/database";
export { PrismaPlanetScale } from "@prisma/adapter-planetscale";

// Re-exports from Prisma
export * from "./generated";
export * from "./generated/client";
export * from "./generated/runtime/index-browser";
export { Client } from "@planetscale/database";
export { PrismaPlanetScale } from "@prisma/adapter-planetscale";

// Re-exports from Prisma
export * from "./generated";
export * from "./generated/client";
export * from "./generated/runtime/index-browser";
- Example usage:
import { Prisma, ApproachTypeEnum } from "database";
import { Prisma, ApproachTypeEnum } from "database";
8 Replies
Prisma AI Help
You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.
Marius Nowak
Marius NowakOP5d ago
Problem After running yarn dev inside apps/vdee, I get continuous warnings related to export * from generated/client.js being CommonJS. Even with moduleFormat = "esm", Prisma still generates generated/client.js as CommonJS. This makes export * from "./generated/client"; trigger the warning. What we already tried 1. Switching tsconfig options • Added verbatimModuleSyntax: false → no effect. 2. Using moduleFormat = "esm" in schema.prisma • Cleaned node_modules and regenerated client. • Still seeing client.js in CommonJS format. 3. Restructuring exports • Tried exporting from ./generated/index-browser, ./generated/library, etc. • Works partially but still noisy when including ./generated/client 4. Considering manual exports • Would prefer not to manually re-export >5000 models and enums from our schema 5. Tried both providers • provider = "prisma-client-js" (default we used so far) • provider = "prisma-client" (as recommended in release notes for 6.16) • In both cases, client.js appears CJS. Questions - Is generated/client.js expected to still be CommonJS even with moduleFormat = "esm" and provider = "prisma-client"? - What is the recommended way to re-export a large Prisma Client (with many models/enums) from a custom package in a monorepo without hitting the unexpected export * warnings? - Should we directly import PrismaClient from generated/client instead of re-exporting it? If so, how should we handle enums/types consistently across server and browser code? - Is this a known limitation/bug, or should we adjust our monorepo exports pattern? We’d love guidance on the proper and future-proof way to set up a monorepo with a shared database package, while staying aligned with Prisma 6.16+ (ESM-first direction).
Gregersen
Gregersen5d ago
Hey! I've set this up in our monorepo as well, and we're doing a few things differently what you have here. First, we are using the recommended settings from the recent Prisma blog on the topic: https://www.prisma.io/blog/rust-free-prisma-orm-is-ready-for-production More specifically, these options:
generator client {
provider = "prisma-client" // ESM-first
engineType = "client" // No rust engines
output = "../src/generated/prisma"
}
generator client {
provider = "prisma-client" // ESM-first
engineType = "client" // No rust engines
output = "../src/generated/prisma"
}
I notice you are missing an output so I don't think you are in fact using the rust-free implementation. From your writing and snippets it sounds like that is your intention. The generated folder does not show up unless you specify the output. moduleFormat is a deprecated setting as far as I know. We haven't used it since 6.0.0. The second part to this is we created a re-export file for each "namespace" in the generated folder. Something like: client.ts : export * from "../generated/client/client"; enums.ts: export * from "../generated/client/enums"; And so forth. Then we expose these 4 files in our package.json. This means Prisma is free to change their internals, but we've effectively created a facade layer, so we can redirect those exports if the Prisma internals change, without having to change our imports across the monorepo. So to answer your questions, I'll try to sum it up: 1) No its not supposed to be. I believe your configuration is wrong. Ours runs perfectly well in an ESM application. 2) Not sure what Prisma recommends, but I would personally recommend this facade layer, and re-export each namespace seperately. This will improve tree shaking and thus reduce bundle size and improve IDE performance. 3) Again, I'd recommend exporting the generated client from dedicated export files, from your package. The generated folder should only be visible to your db package. 4) Not as far as I know, I think your implementation is a little off. Hope this helps 🙏
Prisma
Rust-free Prisma ORM is Ready for Production, ORM v16.6.0 & More
The future of Prisma ORM is here: The Rust-free version of Prisma ORM and the ESM-first prisma-client generator are both Generally Available in v6.16.0.
Marius Nowak
Marius NowakOP4d ago
Hello, thank you very much for your answer. I setup like this inside packages/database/prisma/schema.prisma :
generator client {
provider = "prisma-client" // ESM-first
engineType = "client" // No rust engines
output = "../src/generated/prisma"
}
generator client {
provider = "prisma-client" // ESM-first
engineType = "client" // No rust engines
output = "../src/generated/prisma"
}
then, yarn db:generate then I created : - packages/database/client.ts -> export * from "./src/generated/prisma/client"; - packages/database/enums.ts -> export * from "./src/generated/prisma/enums"; - packages/database/browser.ts -> export * from "./src/generated/prisma/browser"; - packages/database/models.ts -> export * from "./src/generated/prisma/models"; - packages/database/commonInputTypes.ts -> export * from "./src/generated/prisma/commonInputTypes"; then inside package.json :
"exports": {
".": "./index.ts",
"./client": "./client.ts",
"./enums": "./enums.ts",
"./browser": "./browser.ts",
"./models": "./models.ts",
"./commonInputTypes": "./commonInputTypes.ts"
}
"exports": {
".": "./index.ts",
"./client": "./client.ts",
"./enums": "./enums.ts",
"./browser": "./browser.ts",
"./models": "./models.ts",
"./commonInputTypes": "./commonInputTypes.ts"
}
Then I ran yarn install Then I ran yarn dev and faced the warning
⚠ [externals]/@prisma/client
unexpected export *
export * used with module [externals]/@prisma/client [external] (@prisma/client, cjs) which is a CommonJS module with exports only available at runtime
List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.`

Import traces:
#1 [external]:
[externals]/@prisma/client [external]
./packages/my-zod/src/user/schema.ts [Server Component]
./apps/vdee/app/(loggedin)/layout.tsx [Server Component]
⚠ [externals]/@prisma/client
unexpected export *
export * used with module [externals]/@prisma/client [external] (@prisma/client, cjs) which is a CommonJS module with exports only available at runtime
List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.`

Import traces:
#1 [external]:
[externals]/@prisma/client [external]
./packages/my-zod/src/user/schema.ts [Server Component]
./apps/vdee/app/(loggedin)/layout.tsx [Server Component]
There is still an old file that I didn't change, I don't know but maybe it is the one still causing the warning. It is this file packages/database/index.ts :
export { Client } from "@planetscale/database";
export { PrismaPlanetScale } from "@prisma/adapter-planetscale";
export * from "@prisma/client";
export { Client } from "@planetscale/database";
export { PrismaPlanetScale } from "@prisma/adapter-planetscale";
export * from "@prisma/client";
How should I rewrite it ? Should I delete it ?
Gregersen
Gregersen4d ago
Yeah I think you should not do the * export from Prisma client, but I am not a 100% sure either. It would likely conflict with the client export. I know we no longer do any exports from @prisma/client, and only use it to set it up the adapter Did you set up the adapter as recommended?
Marius Nowak
Marius NowakOP4d ago
About the adapter : We set it up inside apps/vdee/lib/db.ts , I think we do it the recommended way :
import { Client } from "@planetscale/database";
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
import { PrismaClient } from "@prisma/client";
import { fetch as undiciFetch } from "undici";

declare global {
var cachedPrisma: PrismaClient;
}

const client = new Client({
url: process.env.DATABASE_URL ?? "",
fetch: undiciFetch,
});
const adapter = new PrismaPlanetScale(client);
const prisma = global.cachedPrisma || new PrismaClient({ adapter });

if (process.env.NODE_ENV === "development") {
global.cachedPrisma = prisma;
}

export const db = prisma;
import { Client } from "@planetscale/database";
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
import { PrismaClient } from "@prisma/client";
import { fetch as undiciFetch } from "undici";

declare global {
var cachedPrisma: PrismaClient;
}

const client = new Client({
url: process.env.DATABASE_URL ?? "",
fetch: undiciFetch,
});
const adapter = new PrismaPlanetScale(client);
const prisma = global.cachedPrisma || new PrismaClient({ adapter });

if (process.env.NODE_ENV === "development") {
global.cachedPrisma = prisma;
}

export const db = prisma;
The only things I just changed are the import of Client, PrismaPlanetScale & PrismaClient which were previously imported from "database". My packages/database/index.ts file now looks like this :
export * from "@prisma/client";
export * from "@prisma/client";
I deleted the export of Client & PrismaPlanetScale. I think our Prisma setup now looks closer to what it should look like thanks to your help. But I struggle replacing the content of packages/database/index.ts file which contains the export * that is probably causing the warning. - if I delete it, "database" is not found anymore in the code - I tried to replace the content with
export * from "./src/generated/prisma/client";
export * from "./src/generated/prisma/client";
but now I'm getting the error Module not found: Can't resolve './enums.js inside packages/database/src/generated/prisma/client.ts If I look inside packages/database/src/generated/prisma/client.ts I can see import * as $Enums from "./enums.js" but it should be enums.ts (packages/database/src/generated/prisma/enums.ts) I post that for now, I will keep digging that later. I think there are options to generate .ts files.
Gregersen
Gregersen4d ago
It seems like you are close. I dont know if you tried, but have you updated to 6.16.2? A few major type issues were fixed in those minor versions, they may help you narrow in the issues too 🙂
Marius Nowak
Marius NowakOP3d ago
I am actually using Prisma version 6.16.2 👍 I said I was using v6.16.0, it was a mistake. I think I can't import everything from "database" right ? I have to change everywhere inside my code to from "database/client", from "database/enums", etc... It would take some time to modify that and change a lot of lines so I want to be sure, Is it how you do in your code ?

Did you find this page helpful?