Skip to content

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
mainfrom
fix/isolate-build-dist-dir
Open

fix: give next build its own dist dir so it cannot corrupt a running dev server#532
prabhatsharma wants to merge 1 commit into
mainfrom
fix/isolate-build-dist-dir

Conversation

@prabhatsharma

Copy link
Copy Markdown
Contributor

What

next build and next dev share .next by 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:

Page "/[[...slug]]/page" is missing param "/[[...slug]]" in "generateStaticParams()", which is required with "output: export" config.

until the server is restarted. This bit today while docs builds (#530, #531) ran repeatedly under a long-lived pnpm dev.

Fix

  • pnpm build sets NEXT_DIST_DIR=.next-build, routed through distDir in next.config.mjs (defaults to .next for everything else).
  • .next-build gitignored.

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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant