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/.
This commit is contained in:
Joel Brock
2026-05-21 11:15:24 -07:00
parent f0530ed337
commit 0545dc3bc4
+11
View File
@@ -1,3 +1,4 @@
import path from "node:path";
import type { NextConfig } from "next"; import type { NextConfig } from "next";
/** /**
@@ -49,6 +50,16 @@ const securityHeaders = [
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
poweredByHeader: false, poweredByHeader: false,
reactStrictMode: true, 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() { async headers() {
return [{ source: "/:path*", headers: securityHeaders }]; return [{ source: "/:path*", headers: securityHeaders }];
}, },