From 3721e9d8e3bac3bd6ed482f650c79c082fc3eb33 Mon Sep 17 00:00:00 2001 From: Will Sewell Date: Tue, 5 May 2026 16:10:32 +0100 Subject: [PATCH] fix(examples): exclude node_modules from example copy to prevent duplicate React MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generate-example script copies the source example directory into dist/, including node_modules with pnpm symlinks that still point back to the source location. When pnpm install runs in dist/ it finds the lockfile up-to-date and reuses the stale symlinks as-is. This causes packages like connectkit to resolve React from the source directory while the app uses React from the dist directory — two different React instances — leading to a "Cannot read properties of null (reading 'useRef')" error during Next.js prerendering. Filter out node_modules and .next during the copy so pnpm install creates a clean dependency tree in the dist directory. Co-Authored-By: Claude Opus 4.7 (1M context) --- examples/scripts/generate-example.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/scripts/generate-example.mjs b/examples/scripts/generate-example.mjs index b5a4c26..6ed7410 100644 --- a/examples/scripts/generate-example.mjs +++ b/examples/scripts/generate-example.mjs @@ -12,7 +12,10 @@ async function generate(app) { await rm(out, { recursive: true, force: true }); await mkdir(out, { recursive: true }); - await cp(src, out, { recursive: true }); + await cp(src, out, { + recursive: true, + filter: (source) => !source.includes("node_modules") && !source.includes(".next"), + }); // Seed .env from .env.example so Next.js prerendering has the required env vars. // push-example.sh uses `git add -A` which respects .gitignore, so .env won't be published.