Repository navigation
Keep Turbopack compile cache across production builds - #3725
marcklingen wants to merge 2 commits into
Conversation
Stop deleting .next/cache after every build (a leftover Nextra workaround) and enable Next 16's turbopackFileSystemCacheForBuild so incremental Vercel/CI builds can reuse compile work. Co-authored-by: marc.klingen <marc.klingen@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Claude Code Review
No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 718d6c23b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Beyond the reported candidate issue, I checked that the next dependency is pinned to ^16.2.6 (matches the PR's claim that turbopackFileSystemCacheForBuild requires 16.2+) and that both edited files remain consistently formatted with their surroundings.
Extended reasoning...
This is a two-line-equivalent, self-contained config change (one experimental flag added in next.config.mjs, one script removed in package.json) with no bugs reported by the bug hunter. I independently verified the next version pin (^16.2.6) matches the PR's stated requirement for the flag, and that formatting is consistent. The one substantive risk — unbounded .next/cache growth without built-in eviction on Next 16.2 (eviction becomes default only in 16.3) — was already surfaced as a candidate issue and investigated this run, so I'm not re-raising it, just noting it was checked.
STATIC_EXPORT sets distDir to out, so turbopackFileSystemCacheForBuild would write the compile cache under out/cache and ship it with the Cloudflare Pages artifact. Keep the flag on for normal next build. Co-authored-by: marc.klingen <marc.klingen@clickhouse.com>
|
The Vercel preview failure is unrelated to this PR. No code change on this branch. Deployment The same window failed previews for unrelated PRs (#3722, #3569, #3724, #3723, #3717, #3715, #3726). Last successful preview was #3705 at 12:32. Production deploys just before that succeeded. Vercel status is green — this looks like a project-level concurrent-build / rate-limit squeeze. I could not pull inspector logs from here (no Vercel token). Redeploy this commit from the dashboard once the queue clears. |
Enable Next 16.2's Turbopack filesystem cache for production builds and stop deleting
.next/cacheafternext build.This is the only change from a local experiment pass that had a measured compile saving and no SSG/SEO risk.
Why
Vercel Enhanced (8 cores / 16 GB) spends most of
pnpm run buildhere:llms-txt.next, not the script)postbuild:cleanup(rm -rf .next/cache) was a Nov 2024 Nextra workaround. Next already keeps.next/cachewhen it cleans the dist dir. Withoutexperimental.turbopackFileSystemCacheForBuild, that directory is only ~1.6 MB of fetch-cache, so deleting it does nothing for the 61s compile. With the flag, it becomes a real compile cache (623–850+ MB locally).The flag is opt-in on Next 16.2 and becomes the default in 16.3.
Expected Vercel impact
What this PR changes
experimental.turbopackFileSystemCacheForBuildinnext.config.mjs(on for Vercel /next build)postbuild:cleanupso the cache can survive into Vercel's build cacheSTATIC_EXPORT=truesopnpm build:staticdoes not write the compile cache underout/cache(Cloudflare Pages artifact)What we measured and would not ship
ignoreBuildErrors)tscjob.next buildis the only typecheck.experimental.cpus: 8cpus - 1(7 workers). ~1s SSG locally.next build --webpackfailed (fumadocs-mdx:collections/server)..nextis 975 HTML + 7805 RSC pages.optimizePackageImports/outputFileTracingExcludes.nextis ~8 KB. The upload gap is prerendered HTML/RSC.How to verify on Vercel
.next/cacherestored. If cache restore fails or approaches 1 GB, turn the flag off or upgrade to Next 16.3 (default FS cache + eviction).Greptile Summary
This PR enables Next.js 16.2's persistent Turbopack compilation cache and preserves it after production builds.
experimental.turbopackFileSystemCacheForBuildto the Next.js configuration..next/cache.llms.txt, and static-export postbuild processing intact.Confidence Score: 5/5
The PR appears safe to merge, with the cache-retention behavior consistently wired into the existing production and static build flows.
No concrete correctness, security, packaging, or workflow regression remains; environments that do not persist the cache simply receive no warm-build performance benefit.
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR Build[next build] --> Compile[Turbopack compilation] Compile --> Cache[.next/cache] Cache --> Vercel[Vercel build-cache persistence] Vercel --> Restore[Subsequent build restores cache] Restore --> Compile Build --> Postbuild[Postbuild sitemap and llms.txt] Postbuild -. no longer deletes cache .-> CacheReviews (1): Last reviewed commit: "perf(build): keep Turbopack compile cach..." | Re-trigger Greptile