Skip to content

fix(prisma): Explain schema.prisma config settings#1761

Merged
Tobbe merged 2 commits into
mainfrom
tobbe-fix-schema-prisma-config-comment
May 12, 2026
Merged

fix(prisma): Explain schema.prisma config settings#1761
Tobbe merged 2 commits into
mainfrom
tobbe-fix-schema-prisma-config-comment

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented May 12, 2026

Had this comment first, but it felt like it was too long

// For CJS Cedar apps:
// It might feel a little out of place to have .mts files in the codebase, and
// especially importing them like we do in `src/lib/db`.
// For ESM Cedar apps:
// It might feel a little weird to ask Prisma to generate CJS compatible format.
//
// Setting `moduleFormat = "cjs"` and using `.mts` extensions is however the
// only combination that makes Prisma 7, which is ESM-only, work in CJS Cedar
// apps while also having the same configuration work for ESM Cedar apps.
//
// The only reason this works is thanks to Node 24's support for require(esm).
// https://www.prisma.io/docs/orm/prisma-schema/overview/generators

So I shortened it to what we have now, and then pointing here for more info.

This all came out of the discussion on PR #1752

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit f93b597
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6a035f1b24a7af0008238908

@github-actions github-actions Bot added this to the next-release-patch milestone May 12, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 12, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit f93b597

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 7s View ↗
nx run-many -t build ✅ Succeeded 4m 22s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-12 20:47:13 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 12, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit da5553f

Command Status Duration Result
nx run-many -t build ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-12 17:09:42 UTC

1 similar comment
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 12, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit da5553f

Command Status Duration Result
nx run-many -t build ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-12 17:09:42 UTC

@Tobbe Tobbe marked this pull request as ready for review May 12, 2026 17:10
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 12, 2026

Greptile Summary

Adds a 3-line explanatory comment above the generator client block in all 9 schema.prisma files, explaining that the moduleFormat = "cjs" / .mts extension combination is required to make Prisma 7 work across both CJS and ESM Cedar apps, with a link to PR #1761 for deeper context. The project overview doc (docs/implementation-docs/2026-03-26-cedarjs-project-overview.md) remains factually consistent — it already lists Prisma 7 and Node.js 24 in the runtime section, which aligns with the Node 24 require(esm) dependency described in the PR.

  • All 9 schema.prisma files (four create-cedar-app templates, three test fixtures, two local-testing projects) receive the identical comment block.
  • No schema, generator settings, or runtime behavior is changed — this is a documentation-only update.

Confidence Score: 5/5

Documentation-only change with no impact on runtime behavior; safe to merge.

Every changed file receives the same identical 3-line comment block. No generator settings, migrations, or code paths are modified. The comment text is accurate and consistent with the Prisma 7 / Node 24 setup already reflected in the codebase and project overview doc.

No files require special attention.

Important Files Changed

Filename Overview
packages/create-cedar-app/templates/ts/api/db/schema.prisma Adds a 3-line explanatory comment before the generator block linking to PR #1761 for context on the CJS/ESM settings combination
packages/create-cedar-app/templates/js/api/db/schema.prisma Same explanatory comment addition as other templates
packages/create-cedar-app/templates/esm-ts/api/db/schema.prisma Same explanatory comment addition as other templates
packages/create-cedar-app/templates/esm-js/api/db/schema.prisma Same explanatory comment addition as other templates
fixtures/test-project/api/db/schema.prisma Same explanatory comment addition as other fixtures
fixtures/test-project-esm/api/db/schema.prisma Same explanatory comment addition as other fixtures
fixtures/test-project-live/api/db/schema.prisma Same explanatory comment addition as other fixtures
local-testing-project/api/db/schema.prisma Same explanatory comment addition as other local testing projects
local-testing-project-live/api/db/schema.prisma Same explanatory comment addition as other local testing projects

Reviews (1): Last reviewed commit: "Update comment" | Re-trigger Greptile

@Tobbe Tobbe merged commit d432721 into main May 12, 2026
99 of 105 checks passed
@Tobbe Tobbe deleted the tobbe-fix-schema-prisma-config-comment branch May 12, 2026 21:09
@github-actions
Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 5.0.0-canary.2326

Or try it in a new app with yarn dlx create-cedar-app@5.0.0-canary.2326

Tobbe added a commit that referenced this pull request May 13, 2026
Had this comment first, but it felt like it was too long

```js
// For CJS Cedar apps:
// It might feel a little out of place to have .mts files in the codebase, and
// especially importing them like we do in `src/lib/db`.
// For ESM Cedar apps:
// It might feel a little weird to ask Prisma to generate CJS compatible format.
//
// Setting `moduleFormat = "cjs"` and using `.mts` extensions is however the
// only combination that makes Prisma 7, which is ESM-only, work in CJS Cedar
// apps while also having the same configuration work for ESM Cedar apps.
//
// The only reason this works is thanks to Node 24's support for require(esm).
// https://www.prisma.io/docs/orm/prisma-schema/overview/generators
```
So I shortened it to what we have now, and then pointing here for more
info.

This all came out of the discussion on PR
#1752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant