mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(build): resolve safety-contracts YAML path from cwd, not __dirname
Turbopack rewrites `__dirname` to a synthetic `/ROOT/...` token at build time, so `readFileSync(join(__dirname, 'safety-contracts.fr.yaml'))` crashed during page-data collection in the Docker build with an ENOENT. The chunk error fixed in the previous commit was hiding the issue. The path now resolves through `process.cwd() + 'src/lib/ai/prompts'`, which stays stable across `next build`, `next start`, and the test runner. `outputFileTracingIncludes` in `next.config.ts` pulls the YAML siblings into the standalone runtime image so the read succeeds at deploy time.
This commit is contained in:
1 parent
e51a4f53bb
commit
dd44a0df49
2 files changed
+17
-1
No files matched your search
@@ -35,7 +35,13 @@ import { z } from "zod";
|
||||
|
||||
import type { Locale } from "@/lib/i18n/config";
|
||||
|
||||
const SAFETY_CONTRACTS_DIR = __dirname;
|
||||
// Turbopack rewrites `__dirname` to a synthetic `/ROOT/...` token at
|
||||
// build time, which then fails at runtime when the YAML siblings are
|
||||
// looked up. Resolving from `process.cwd()` keeps the path stable
|
||||
// across `next build` + `next start` (and the test runner — vitest sets
|
||||
// cwd to the repo root). `outputFileTracingIncludes` in `next.config.ts`
|
||||
// pulls the YAML files into the standalone runtime image.
|
||||
const SAFETY_CONTRACTS_DIR = join(process.cwd(), "src/lib/ai/prompts");
|
||||
|
||||
const ContractEnumsSchema = z.object({
|
||||
severity: z.array(z.string()).min(1),
|
||||
|
||||
Reference in new issue
Block a user