build: Fix build cache of page content - #1982
Open
marcleblanc2 wants to merge 4 commits into
Open
marcleblanc2 wants to merge 4 commits into
marcleblanc2 wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
marcleblanc2
force-pushed
the
marc/build/turbopack-and-contentlayer-cache
branch
from
September 17, 2026 04:28
0818b2f to
b844daf
Compare
Contributor
This comment has been minimized.
This comment has been minimized.
marcleblanc2
added a commit
that referenced
this pull request
Sep 17, 2026
The redirects check on #1982 posted a comment containing only its hidden marker, then failed. The PR changed src/data/redirects.ts from module.exports to export {}, and its copy of dev/check-redirects.mjs could no longer read the base branch's file. The workflow could not tell that crash (Node exits 1) from findings (also exit 1), so it treated an empty report as a finding. - check-redirects.mjs accepts both export styles, since CI runs the PR's script against the base branch too - Both check workflows classify by output: the scripts write their result in one go at the end, so a crash leaves it empty. A crash is a workflow warning; the comment, review and fail steps only run on a real result - The comment step never posts a report it does not have Amp-Thread-ID: https://ampcode.com/threads/T-01a0adcb-1b03-716a-852a-cc3746148488 Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/build/turbopack-and-contentlayer-cache
branch
from
September 17, 2026 06:01
153e463 to
d7ce16a
Compare
marcleblanc2
added a commit
that referenced
this pull request
Sep 17, 2026
The redirects check on #1982 posted a comment containing only its hidden marker, then failed. The PR changed src/data/redirects.ts from module.exports to export {}, and its copy of dev/check-redirects.mjs could no longer read the base branch's file. The workflow could not tell that crash (Node exits 1) from findings (also exit 1), so it treated an empty report as a finding. - check-redirects.mjs accepts both export styles, since CI runs the PR's script against the base branch too - Both check workflows classify by output: the scripts write their result in one go at the end, so a crash leaves it empty. A crash is a workflow warning; the comment, review and fail steps only run on a real result - The comment step never posts a report it does not have Amp-Thread-ID: https://ampcode.com/threads/T-01a0adcb-1b03-716a-852a-cc3746148488 Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
marked this pull request as ready for review
September 17, 2026 06:24
marcleblanc2
added a commit
that referenced
this pull request
Sep 17, 2026
The redirects check on #1982 posted a comment containing only its hidden marker, then failed. The PR changed src/data/redirects.ts from module.exports to export {}, and its copy of dev/check-redirects.mjs could no longer read the base branch's file. The workflow could not tell that crash (Node exits 1) from findings (also exit 1), so it treated an empty report as a finding. - check-redirects.mjs accepts both export styles, since CI runs the PR's script against the base branch too - Both check workflows classify by output: the scripts write their result in one go at the end, so a crash leaves it empty. A crash is a workflow warning; the comment, review and fail steps only run on a real result - The comment step never posts a report it does not have Amp-Thread-ID: https://ampcode.com/threads/T-01a0adcb-1b03-716a-852a-cc3746148488 Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
added a commit
that referenced
this pull request
Sep 17, 2026
When a PR check script crashes, the workflow now comments that the check could not run instead of failing the PR Unblocks #1982 ## Testing - Tested the `run:` steps locally for the crash, clean and findings paths - `actionlint` passes --------- Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/build/turbopack-and-contentlayer-cache
branch
from
September 17, 2026 10:07
245a391 to
d530440
Compare
…Vercel deploys Vercel builds spend ~25-30s regenerating all 506 MDX documents on every deploy, because contentlayer only writes its cache to .contentlayer/.cache and Vercel only keeps .next/cache. dev/build-content.mjs symlinks the one into the other and runs contentlayer2 build, so only changed pages are re-rendered. With contentlayer run as its own step, next build no longer needs the next-contentlayer2 webpack hook, so it can use Turbopack (the Next 16 default): no --webpack, no webpack persistent cache to restore and upload, no 'Collecting build traces' step. next dev --webpack keeps the plugin through the PHASE_DEVELOPMENT_SERVER branch in next.config.js. Two things webpack tolerated that Turbopack does not: - src/proxy.ts loaded src/data/redirects.ts with require() of a file that mixes import and module.exports; it is now import/export on both sides, and dev/check-redirects.mjs strips the new export line - contentlayer.config.ts read the code theme with a path relative to where contentlayer compiles the config; it is now a JSON import esbuild bundles Amp-Thread-ID: https://ampcode.com/threads/T-01a0acbf-1cb1-7317-92d6-cd9399e6112a Co-authored-by: Amp <amp@ampcode.com>
…ercel contentlayer2 keys its document cache on the source file's mtime, and a fresh clone sets every mtime to the clone time, so on Vercel every entry missed. The second preview deploy of this branch restored the cache and still spent 23s re-rendering all 506 documents. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad75-46cf-77ed-889b-438e2521bc89 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad75-46cf-77ed-889b-438e2521bc89 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad75-46cf-77ed-889b-438e2521bc89 Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/build/turbopack-and-contentlayer-cache
branch
from
September 17, 2026 10:10
d530440 to
0ab4acd
Compare
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.
Every Vercel build spent 25-40s of its ~2 minutes re-rendering all 506 MDX documents, even when they didn't change, because contentlayer2's cache lived in
.contentlayer/.cacheand Vercel only keeps.next/cachebetween buildsChanges
pnpm run buildnow runs contentlayer2 as its own step (dev/build-content.mjs) with its cache under.next/cache, so a deploy re-renders only the documents that changedUpstream Contentlayer2 decides "changed" by comparing each file's
mtime, but Vercel builds use fresh clone, which sets everymtimeto the clone time, so the restored cache never hitdev/build-content.mjsnow sets each.mdxfile'smtimefrom a hash of its content firstThis removes the only reason
next buildwas still holding onto webpack, so we switched it to using Vercel's Turbopack for faster builds and better cachingThis upgrade to Turbopack required 2 fixes in our code:
src/data/redirects.tsis imported instead ofrequire()contentlayer.config.tsimports the Shiki theme as JSON instead of by a relative pathVercel build times
mainThe first build after any change to this script is still cold (its restored cache holds the old hashes)
Also checked locally:
.mdxwithout changing content still hits the cache (8.5s → 2.8s)next startserves docs pages,/api/og,.mdrewrites, redirects, sitemap,/api/releases, 404tsc, lint andcheck-redirectsunchanged frommain