All questions

One croct.json5 for the whole pnpm workspace or one per Next.js app?

Asked by Tobias Lindgren on

TLTobias Lindgren

We run two Next.js applications in a single pnpm workspace. Both belong to the same Croct workspace, but they use entirely different slots. I am setting up the repository structure now and want to get this right from the start.

Where should croct.json5 and the generated slots.d.ts live? One shared config at the repository root, or one per app? And does the CLI have any awareness of pnpm workspaces, or does it just operate on the current directory?

Was this helpful?

2 answers

Aaleksp

One croct.json5 per app. The file pins the organization, workspace, applications per environment, and the slot and component version specifiers for that app alone. Since your two apps use different slots, a shared root config would force both apps to carry version pins for slots they never fetch, and a version bump for one app would touch the other's config for no reason.

The CLI operates on the directory it runs in, so run it from each app folder:

apps/  storefront/    croct.json5    slots.d.ts  dashboard/    croct.json5    slots.d.ts

Each app gets its own generated slots.d.ts scoped to the slots it actually uses, which also keeps the types honest: referencing a dashboard slot from the storefront becomes a compile error instead of a runtime surprise.

Was this helpful?
GLGrace Liu

Agree with per-app configs. One thing I would add from running a similar setup: commit both croct.json5 and slots.d.ts to the repository. The types are generated from the API, and if they are not committed your CI build depends on a network fetch to produce them. Committed files make builds reproducible and let you review slot schema changes in pull requests like any other diff.

Was this helpful?
Still have questions?