chore(prisma): isolate client into per-package output dir (monorepo prep) - #187
Conversation
…rep) Set the Prisma client generator `output` to a per-package `src/generated/prisma` directory and rewrite the bare `@prisma/client` import specifier to the relative generated path (20 sites). `@prisma/client` subpath imports (e.g. runtime/library) are left untouched. Monorepo prep: behavior-preserving upstream normalization ahead of the omni monorepo migration, where each package needs its own isolated generated Prisma client. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
1 blocker. Reply
|
Follow-up to the per-package Prisma output dir (src/generated/prisma). Dockerfile: the generated client (client JS + bundled runtime + query engine binary) lives in src/generated/prisma, which `nest build` does not emit into dist, and node_modules/.prisma is no longer produced in custom- output mode (the old COPY of it would fail). Copy the generated dir to the exact path the compiled code resolves at runtime (dist/src/generated/prisma). Verified locally: `node dist/src/main.js` boots, loads the engine from dist/src/generated/prisma/runtime/library.js, and only fails on DB auth. CI (pull-request.yml): add an explicit `npx prisma generate` step before type-check/tests so generation no longer relies on @prisma/client's implicit postinstall side effect. Addresses delegate review blockers and Bugbot finding on #187. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Both blockers + the Bugbot finding addressed in a5ba99c:
delegate review |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a5ba99c. Configure here.
main.yml runs `npm run test` after `npm ci` without generating the Prisma client (output to the gitignored src/generated/prisma). Add an explicit `npx prisma generate` step, mirroring pull-request.yml, so test runs don't rely on @prisma/client's implicit postinstall generation. Addresses delegate review blocker on #187. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed in 8d39bf6: added the same explicit delegate review |
Resolve package-lock.json conflict (siblings #187/#188/#190 merged to develop and moved package.json/package-lock.json). package.json auto-merged cleanly, preserving this PR's typescript ^5.9.3 + typescript-eslint ^8.60.0 alongside develop's changes. Lockfile regenerated via npm install (umbrella typescript-eslint -> 8.60.1) so it matches the merged package.json; strict npm ci resolves with no ERESOLVE, build + lint green. Co-authored-by: Cursor <cursoragent@cursor.com>
Monorepo prep
Behavior-preserving upstream normalization ahead of the omni monorepo migration. The monorepo sync is additive/deterministic, so we fix upstream here first where CI validates in the real environment.
What
prisma/schema/schema.prisma: addoutput = "../../src/generated/prisma"to thegenerator clientblock (existing provider/binaryTargets/previewFeatures unchanged) so each package owns an isolated generated Prisma client..gitignore: ignoresrc/generated/.@prisma/clientimport specifier to the relative generated path across 20 sites / 20 files (validated codemod).@prisma/client/...subpath imports are intentionally left alone — they still resolve to the real npm package the generated client depends on.Validation
npx prisma generate→ confirmed output tosrc/generated/prisma.npm run build✅ (zero Prisma-resolution errors).npm test→ 116 passed, 1 skipped; the only failing suite is a DB integration test (election_api_testdoes not exist on localhost) — environment-only, unrelated to this change. Notably it resolves the new client fromsrc/generated/prisma/runtime/library.js, confirming runtime resolution works.src/generated/confirmed git-ignored; not committed.Made with Cursor
Note
Medium Risk
Changes how the Prisma client is built and shipped (CI, Docker, and all DB type imports); a missed
prisma generateor wrong Docker copy would break builds or production DB access, though runtime behavior is intended to stay the same.Overview
Moves the Prisma client from the default
@prisma/clientpackage into a gitignored per-package output atsrc/generated/prisma, ahead of monorepo work so each package can own its own generated client.Schema & imports:
generator clientnow setsoutput = "../../src/generated/prisma". Application code that importedPrisma,PrismaClient, and model enums from@prisma/clientnow uses relative paths like../generated/prisma(many modules undersrc/).Tooling:
.gitignoreignoressrc/generated/. PR CI runsnpx prisma generateafternpm ciand beforetsc/ tests so type-checking sees the generated client. Docker stops copyingnode_modules/.prismaand instead copies the builtsrc/generated/prismatree intodist/src/generated/prismaso compiled Nest code can load the client and query engine at runtime.Reviewed by Cursor Bugbot for commit a5ba99c. Configure here.