From 0545dc3bc4262ad53cd8d25969dce31fbe588556 Mon Sep 17 00:00:00 2001 From: Joel Brock Date: Thu, 21 May 2026 11:15:24 -0700 Subject: [PATCH] Pin Turbopack root to app dir to stop dev recompile loop Two package-lock.json files exist (parent civi-webform/ + this app); Next 16 silently picked the outer one, so Turbopack watched the parent node_modules/, .claude-flow/, .swarm/, ruvector.db. Background writes in those trees triggered a recompile loop that thrashed .next/dev and leaked memory until the dev server crashed. Setting turbopack.root keeps the watcher scoped to WebForm-mw/. --- next.config.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/next.config.ts b/next.config.ts index 03e59f8..a2e96ff 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import type { NextConfig } from "next"; /** @@ -49,6 +50,16 @@ const securityHeaders = [ const nextConfig: NextConfig = { poweredByHeader: false, reactStrictMode: true, + // Pin Turbopack's filesystem root to THIS app's directory. Without this, + // Next 16 walks up to the parent civi-webform/ workspace (it sees two + // package-lock.json files and silently picks the outer one), which causes + // Turbopack to watch the parent node_modules/, .claude-flow/, .swarm/, and + // ruvector.db. Background writes in those trees trigger a recompile loop: + // compile → write .next/dev → re-trigger → memory blows up. The build-time + // warning surfaces the same issue. + turbopack: { + root: path.resolve(__dirname), + }, async headers() { return [{ source: "/:path*", headers: securityHeaders }]; },