Skip to content

Prisma 7 .mts generated client breaks Vercel deploy via @vercel/redwood (NFT can't parse .mts) #1781

@bellcoTech

Description

@bellcoTech

Heads up on something I hit pushing a Cedar 4.2 ESM app to Vercel. Not asking for a template change — .mts is the right default per #1752 / #1761 — just flagging it because the documented path is incompatible with Vercel's default builder and there's no in-project workaround that doesn't diverge from your docs.

What I see

Vercel build succeeds. At runtime, the lambda throws:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@prisma/client' imported from /var/task/api/db/generated/prisma/client.mts

Patch around that (force NFT to trace @prisma/client via a .ts side-effect import in db.ts) and the next error is:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/api/db/generated/prisma/enums.mts' imported from /var/task/api/db/generated/prisma/client.mts

…and so on for every sibling generated .mts file.

Why

Vercel deploys Cedar via @vercel/redwood, which calls nodeFileTrace from @vercel/nft over api/dist/**/*.{js,ts} and bundles only what NFT returns:

nodeFileTrace([absEntrypoint], {
  base: workPath, processCwd: workPath,
  ts: true, mixedModules: true,
  ignore: config.excludeFiles,
})

(vercel/vercel/packages/redwood/src/index.ts)

@vercel/nft parses with acorn (vanilla JS, no TS support). The ts: true flag enables .js → .ts resolver fallback but neither the resolver nor the parser handles .mts (vercel/nft/src/analyze.ts, node-file-trace.ts).

When NFT parses client.mts — which contains TS syntax (generics, type aliases, interfaces) — acorn fails. NFT catches the error and returns { deps: [], imports: [] }. Silent. Every transitive import inside the generated client is dropped. client.mts itself ends up in the bundle because it's referenced from a parseable .js file (api/dist/lib/db.js), but the trace stops there.

Why this isn't fixable in a Cedar project

  • .mts is the documented default and necessary for CJS-mode Cedar projects per fix(internal): fall back to schema parsing for Prisma 7 ModelName #1752 / fix(prisma): Explain schema.prisma config settings #1761 — can't drop it.
  • The deploy docs explicitly forbid vercel.json functions config: "Since Cedar has its own handling of the api directory, the Vercel flavored api directory is disabled. Therefore you don't use the 'functions' config in vercel.json with Cedar."
  • @vercel/redwood reads excludeFiles only, no includeFiles — confirmed in source. No env var, no cedar.toml field. There's no surface for a Cedar user to inject files into the bundle while staying on the documented path.

Where the fix could live (probably not Cedar)

Two candidates, both Vercel-side:

  1. @vercel/redwood — copy api/db/generated/**/* into each function bundle after nodeFileTrace. Small, surgical, no NFT change needed.
  2. @vercel/nft — add TS-aware parsing for .ts/.mts/.cts (pre-strip types via typescript or @swc/core before acorn). Architecturally correct but a bigger change.

Happy to file at vercel/vercel against @vercel/redwood linking back here if that's useful. Filing here first since Cedar users are who hit it.

Conditional workaround (not for the template)

For ESM-only projects (api workspace is type: module), generatedFileExtension = "ts" is functionally equivalent at runtime — Node 24 strips types from both, NFT's ts: true then parses the generated client correctly. Not safe as a template default, but a viable local divergence for ESM-only apps until upstream fixes land.

Environment

  • Cedar 4.2.0
  • Prisma 7.8.0, prisma-client provider, generatedFileExtension = "mts"
  • api workspace "type": "module"
  • Node 24.x
  • Vercel @vercel/redwood (auto-detected, @vercel/nft@1.5.0 transitive)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions