Skip to content

prisma-client: package developers cannot import runtime objects #27707

Open

Description

@mdesousa

Bug description

hi, we have an internal package that we reuse across different projects that run on node and aws-lambda.
those packages used to import some core objects from the prisma client (see list below), and things used to work well with the prisma-client-js generator. however after switching to prisma-client we've noticed that the imported references no longer work. for example, x instanceof Prisma.Decimal doesn't work, Prisma.DbNull and others cause reference errors. in aws lambda (esbuild bundler) client imports result in "ReferenceError: module is not defined in ES module scope".

wondering if it's possible to import these from non-generated libraries?
or alternatively, having a type that describes the Prisma namespace would be useful. import type { Prisma } doesn't work because Prisma is a namespace, not a type.

the objects causing challenges are:

  • Prisma.DbNull
  • Prisma.Decimal
  • PrismaClientKnownRequestError, PrismaClientKnownRequestError
  • Prisma.sql
  • Prisma.defineExtensions (we have shared extensions for things like tracing and authorization that don't use models)

being able to import Prisma as a type instead of a reference would be extremely helpful! it would allow developers to write the code in the package and pass the instance as a parameter or injection.

thanks!

Severity

Very challenging for package developers

Expected vs. Actual Behavior

package developers should be able to easily develop reusable code on top of prisma

  • import Prisma as a type instead of a namespace
  • reference singletons like DbNull, Decimal
  • access to Prisma from PrismaClient would be helpful (to have a single instance injected)

Frequency

Consistently reproducible

Does this occur in development or production?

In staging environments since bundling breaks things

Is this a regression?

yes, these things were possible with the prisma-client-js generator

Workaround

had to pass Prisma instance with dependency injection. getting the types was difficult, but a workaround like the one below works:

// my-package.ts

import { container, sid } from 'my-dependency-injection';
import type { Prisma as P } from '../generated/prisma/client.js';
type PrismaModule = { DbNull: typeof P.DbNull, Decimal: typeof P.Decimal };
const Prisma = container.get<PrismaModule>(sid.Prisma);

// now we can reference Prisma.DbNull, Prisma.Decimal

Environment & Setup

  • OS: macOS, Debian
  • Database: PostgreSQL
  • Node.js version: 20

Prisma Version

prisma                  : 6.11.1
@prisma/client          : 6.12.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v24.2.0
TypeScript              : 5.8.3
Query Engine (Node-API) : libquery-engine f40f79ec31188888a2e33acda0ecc8fd10a853a9 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
PSL                     : @prisma/prisma-schema-wasm 6.11.1-1.f40f79ec31188888a2e33acda0ecc8fd10a853a9
Schema Engine           : schema-engine-cli f40f79ec31188888a2e33acda0ecc8fd10a853a9 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Default Engines Hash    : f40f79ec31188888a2e33acda0ecc8fd10a853a9
Studio                  : 0.511.0

Activity

  1. added
    kind/bug
    on Jul 20, 2025
  2. added
    bug/1-unconfirmed
    on Jul 23, 2025
  3. added
    tracked
    on Aug 28, 2025
  4. FGoessler commented on Aug 28, 2025

    @FGoessler
    Contributor

    Hi @mdesousa,

    We are working on this issue and have this internally tracked as https://linear.app/prisma-company/issue/ORM-1074. 🙂

    Our current idea to solve this is to provide library authors with a dedicated entry point in the @prisma/client package that exports all relevant utilities. So you can develop a library without the need for an actually generated client.

    Do you think this would solve your use-case?

    It would be awesome if you could also provide a minimal reproduction example of your setup so we can directly test out our solution attempt. 😉

  5. assigned and unassigned on Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/1-unconfirmedkind/bugtopic: generator-tstopic: runtimetracked

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions