codemod: cache-components-instant-false + next-cache-components-adoption skill#94941
Merged
aurorascharff merged 53 commits intoJun 22, 2026
Merged
Conversation
Contributor
Stats cancelledCommit: 5616f68 |
Contributor
Tests PassedCommit: 5616f68 |
… drop unstable_eager
|
PR Quality Score: A (81%) 🎉 I ran this PR through the PR Quality Analyzer — a free tool that checks description quality, labels, size, title, and more. Nice work on this codemod!
|
The previous version used raw text insertion with manual byte-offset math, which mishandled three fixtures on the Windows CI runners. Rewrite using the same shape as other codemods: build the export declaration as an AST node, attach the TODO + See: leading comments, splice it into program.body after the last import, and return root.toSource(). Recast handles the printing details (blank lines, comment placement, line endings) so we no longer need the CRLF normalization layer.
When the target file has no imports and body[0] carries a leading comment block (like `// @ts-nocheck` or a JSDoc banner), inserting the new export at index 0 would let recast steal those comments onto our node. Move the leading comments off body[0] onto the inserted export before its TODO/See: lines so they print in their original position. Also avoid an `alex` lint warning by replacing 'not just' with 'not only'.
icyJoseph
approved these changes
Jun 22, 2026
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.
Why?
Turning on
cacheComponentsmakes every blocking route a build error at once. On a large app that's a wall of failures with no clear order to fix them in, which is a rough first experience.What?
An opt-in adoption path so enabling Cache Components doesn't have to be all-or-nothing:
cache-components-instant-falsecodemod (@next/codemod) — blanket-insertsexport const instant = false(with a// TODO: Cache Components adoptioncomment) into everyapp/**/{page,layout}file, so the build goes green immediately. Idempotent: skips files that already exportinstant(including aliasedexport { x as instant }). Skips Client Components ("use client") and route handlers.next-cache-components-adoptionskill (skills/) — sequences the full migration in five steps across four milestones: green build (codemod or direct), remove the opt-outs top-down one group at a time, make navigations instant via the dev-overlay Insights, then adopt Partial Prefetching. It defers individual fixes to the dev overlay fix cards, stack traces, and the/docs/messages/blocking-prerender-*pages, and points at the migration / instant-navigation / Partial Prefetching guides rather than re-teaching them. Verifies each change at runtime vianext-dev-loop(with a manual dev-overlay fallback). Thenext-cache-components-optimizerskill is referenced only as optional shell-growing polish after adoption is complete.How?
TRANSFORMER_INQUIRER_CHOICESatversion: '16.3.0'.instantand on"use client"pages.pnpm jest cache-components-instant-falsepasses.cache-components-instant-falseentry in the codemods reference, and a pointer to the skill + codemod from the migration guide.