fix: give next build its own dist dir so it cannot corrupt a running dev server - #532
Open
prabhatsharma wants to merge 1 commit into
Open
fix: give next build its own dist dir so it cannot corrupt a running dev server#532prabhatsharma wants to merge 1 commit into
prabhatsharma wants to merge 1 commit into
Conversation
…dev server next build and next dev share .next by default. Running a build while the dev server is up stomps the dev server's incremental state; the overlay then shows the version as (stale) and throws bogus errors such as 'missing param "/[[...slug]]" in generateStaticParams()' until the server is restarted. The build script now sets NEXT_DIST_DIR=.next-build, routed through distDir in next.config.mjs, so builds and the dev server never touch the same directory. Verified by running a full build under a live dev server: build output unchanged (470 pages, links clean), dev pages still 200 with no overlay errors afterward.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
next buildandnext devshare.nextby default. Running a build while the dev server is up corrupts the dev server's incremental state — the overlay then reports the Next.js version as (stale) and throws bogus runtime errors such as:until the server is restarted. This bit today while docs builds (#530, #531) ran repeatedly under a long-lived
pnpm dev.Fix
pnpm buildsetsNEXT_DIST_DIR=.next-build, routed throughdistDirinnext.config.mjs(defaults to.nextfor everything else)..next-buildgitignored.Verified
Started a fresh dev server, then ran a full
pnpm build(with pre/post scripts) underneath it: build output unchanged (470 pages, check-links clean), the two dist dirs coexist, and dev pages still return 200 with no overlay errors afterward — the exact sequence that previously required a restart.