fix(seed): use tsconfig.app.json instead of inline --compiler-options #235

Merged
julien merged 1 commits from fix/prisma-seed-tsconfig into main 2026-05-26 14:53:14 +02:00
Owner

Summary

Follow-up to #234. The db:seed script's inline --compiler-options '{"module":"CommonJS",…}' was getting its quotes stripped by the shell when pnpm run re-spawned ts-node:

> ts-node --compiler-options {module:CommonJS,esModuleInterop:true,target:ES2020} apps/portal-bff/prisma/seed.ts

SyntaxError: Expected property name or '}' in JSON at position 1

Cross-platform JSON-on-cmdline quoting through nested package.json → shell → npm-script → shell → ts-node is a notorious pain. apps/portal-bff/tsconfig.app.json already declares everything ts-node needs to transpile the seed (module=commonjs, esModuleInterop=true, target=es2021, moduleResolution=node, types=[node]). Point at it with -P and drop the inline JSON entirely.

What lands

File Change
package.json (root) db:seed script: --compiler-options '{...}'-P apps/portal-bff/tsconfig.app.json. One-line diff.

That's it.

Why tsconfig.app.json works for the seed even though seed.ts isn't under src/

ts-node --transpile-only reads compilerOptions from the -P tsconfig but ignores the include / exclude fields for the file passed explicitly on the command line. So the fact that tsconfig.app.json has "include": ["src/**/*.ts"] and the seed lives under prisma/ doesn't matter — ts-node happily transpiles whatever file you point it at.

Test plan

  • Locally: cd apps/portal-bff && pnpm exec prisma db seed — no more SyntaxError on the compiler-options, seed runs and reports [seed] test-tenant complete ….
  • Idempotency — re-run, expect created 0 / 0 / 0.
  • No application code changed — drift gate / lint / tests untouched.

Notes for the reviewer

  • Could have created a dedicated apps/portal-bff/prisma/tsconfig.json extending the app config. Less coupling but more files; pointing at the existing tsconfig.app.json is the minimum-surface fix.
  • The Prisma 7 deprecation warning about package.json#prisma is unchanged; migrating to prisma.config.ts is a separate future PR (would also let us inline the seed config without shell quoting at all).
## Summary Follow-up to [#234](https://git.unespace.com/julien/apf_portal/pulls/234). The `db:seed` script's inline `--compiler-options '{"module":"CommonJS",…}'` was getting its quotes stripped by the shell when `pnpm run` re-spawned `ts-node`: ``` > ts-node --compiler-options {module:CommonJS,esModuleInterop:true,target:ES2020} apps/portal-bff/prisma/seed.ts SyntaxError: Expected property name or '}' in JSON at position 1 ``` Cross-platform JSON-on-cmdline quoting through nested `package.json → shell → npm-script → shell → ts-node` is a notorious pain. `apps/portal-bff/tsconfig.app.json` already declares everything `ts-node` needs to transpile the seed (module=commonjs, esModuleInterop=true, target=es2021, moduleResolution=node, types=[node]). Point at it with `-P` and drop the inline JSON entirely. ## What lands | File | Change | | --- | --- | | `package.json` (root) | `db:seed` script: `--compiler-options '{...}'` → `-P apps/portal-bff/tsconfig.app.json`. One-line diff. | That's it. ## Why `tsconfig.app.json` works for the seed even though seed.ts isn't under `src/` `ts-node --transpile-only` reads `compilerOptions` from the `-P` tsconfig but **ignores the `include` / `exclude` fields** for the file passed explicitly on the command line. So the fact that `tsconfig.app.json` has `"include": ["src/**/*.ts"]` and the seed lives under `prisma/` doesn't matter — `ts-node` happily transpiles whatever file you point it at. ## Test plan - [ ] **Locally**: `cd apps/portal-bff && pnpm exec prisma db seed` — no more `SyntaxError` on the compiler-options, seed runs and reports `[seed] test-tenant complete …`. - [ ] **Idempotency** — re-run, expect `created 0 / 0 / 0`. - [x] No application code changed — drift gate / lint / tests untouched. ## Notes for the reviewer - Could have created a dedicated `apps/portal-bff/prisma/tsconfig.json` extending the app config. Less coupling but more files; pointing at the existing `tsconfig.app.json` is the minimum-surface fix. - The Prisma 7 deprecation warning about `package.json#prisma` is unchanged; migrating to `prisma.config.ts` is a separate future PR (would also let us inline the seed config without shell quoting at all).
julien added 1 commit 2026-05-26 14:52:32 +02:00
fix(seed): use tsconfig.app.json instead of inline --compiler-options
CI / check (pull_request) Successful in 1m46s
CI / scan (pull_request) Successful in 4m55s
CI / commits (pull_request) Successful in 6m28s
CI / a11y (pull_request) Successful in 7m36s
Docs site / build (pull_request) Successful in 6m36s
CI / perf (pull_request) Successful in 13m46s
9e92fdd820
The inline --compiler-options '{"module":"CommonJS",...}' was being
unquoted by the shell when pnpm run db:seed re-spawned ts-node:

  > ts-node --compiler-options {module:CommonJS,esModuleInterop:true,...}

  SyntaxError: Expected property name or '}' in JSON at position 1

Cross-platform quoting of JSON-on-cmdline is a notorious pain.
apps/portal-bff/tsconfig.app.json already declares all the options
we need (module=commonjs, esModuleInterop=true, target=es2021,
moduleResolution=node, types=[node]). Point ts-node at it with -P
and drop the inline JSON entirely.

ts-node --transpile-only ignores the tsconfig's `include`/`exclude`
fields for the file passed explicitly, so the fact that seed.ts is
under prisma/ (not src/) doesn't matter.
julien merged commit 55338b83c0 into main 2026-05-26 14:53:14 +02:00
julien deleted branch fix/prisma-seed-tsconfig 2026-05-26 14:53:22 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: julien/apf_portal#235