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
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:
@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.
The deploy docs explicitly forbid vercel.jsonfunctions 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:
@vercel/redwood — copy api/db/generated/**/* into each function bundle after nodeFileTrace. Small, surgical, no NFT change needed.
@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.
Heads up on something I hit pushing a Cedar 4.2 ESM app to Vercel. Not asking for a template change —
.mtsis 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:
Patch around that (force NFT to trace
@prisma/clientvia a.tsside-effect import indb.ts) and the next error is:…and so on for every sibling generated
.mtsfile.Why
Vercel deploys Cedar via
@vercel/redwood, which callsnodeFileTracefrom@vercel/nftoverapi/dist/**/*.{js,ts}and bundles only what NFT returns:(
vercel/vercel/packages/redwood/src/index.ts)@vercel/nftparses withacorn(vanilla JS, no TS support). Thets: trueflag enables.js → .tsresolver 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.mtsitself ends up in the bundle because it's referenced from a parseable.jsfile (api/dist/lib/db.js), but the trace stops there.Why this isn't fixable in a Cedar project
.mtsis 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.vercel.jsonfunctionsconfig: "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/redwoodreadsexcludeFilesonly, noincludeFiles— confirmed in source. No env var, nocedar.tomlfield. 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:
@vercel/redwood— copyapi/db/generated/**/*into each function bundle afternodeFileTrace. Small, surgical, no NFT change needed.@vercel/nft— add TS-aware parsing for.ts/.mts/.cts(pre-strip types viatypescriptor@swc/corebefore acorn). Architecturally correct but a bigger change.Happy to file at
vercel/vercelagainst@vercel/redwoodlinking 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'sts: truethen 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
prisma-clientprovider,generatedFileExtension = "mts""type": "module"@vercel/redwood(auto-detected,@vercel/nft@1.5.0transitive)Related
.mtschoice was established.mtsrationale