You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v4.9.3
Node v22.0.0
System Linux (x64)
Package Manager pnpm
Output server
Adapter @astrojs/node
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Prisma allows multiple schemas to be bundled into separate Prisma clients.
When using the default way to create a Prisma client and importing it (@prisma/client) into Astro, it works fine.
When importing one of those custom-output Prisma clients (which are accessed using relative path, see Repro Repo), the bundling fails because Prisma is CommonJS, but Astro is ESM:
17:58:01 [ERROR] [vite] x Build failed in 318ms
src/pages/index.astro (2:9): "PrismaClient" is not exported by "prisma/prismaclient/index-browser.js", imported by "src/pages/index.astro".
I don't think it's a bug inside Astro, it's probably either (1) a rollup configuration issue, and I'm too stupid for configuring rollup, or (2) a Rollup bug. However, dev (which uses esbuild), also doesn't work, so I think it's a configuration issue for both esbuild and rollup. But it is an issue with Astro I have unfortunately stumbled across. Maybe some Rollup magician knows a solution. In the end the issue is Prisma still does not output ESM...
In general I find it awkward that in Astro SSR I need to manually set Vite settings like:
to bundle dependencies, so my production build is node_modules independent. It feels very hidden and not well documented. IMO it should even be the default to create a standalone build artifact. But that is another discussion entirely.
Closing as this is a non-Astro issue. We do special-case popular packages but since this is submodules specifically I don't think there's anything we can special-case here. I would just suggest using noExternal config as you are doing now, that's what the config is for.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Prisma allows multiple schemas to be bundled into separate Prisma clients.
When using the default way to create a Prisma client and importing it (@prisma/client) into Astro, it works fine.
When importing one of those custom-output Prisma clients (which are accessed using relative path, see Repro Repo), the bundling fails because Prisma is CommonJS, but Astro is ESM:
I don't think it's a bug inside Astro, it's probably either (1) a rollup configuration issue, and I'm too stupid for configuring rollup, or (2) a Rollup bug. However, dev (which uses esbuild), also doesn't work, so I think it's a configuration issue for both esbuild and rollup. But it is an issue with Astro I have unfortunately stumbled across. Maybe some Rollup magician knows a solution. In the end the issue is Prisma still does not output ESM...
In general I find it awkward that in Astro SSR I need to manually set Vite settings like:
to bundle dependencies, so my production build is node_modules independent. It feels very hidden and not well documented. IMO it should even be the default to create a standalone build artifact. But that is another discussion entirely.
What's the expected result?
It's possible to use multiple prisma schemas.
Link to Minimal Reproducible Example
https://github.com/marvin-j97/astro-prisma-bundle-issue
Participation
The text was updated successfully, but these errors were encountered: