Ensure latest canary of Next.js is installed in repros #65197
Merged
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?
Always use latest canary in reproduction templates
Why?
Following up with the new PR #64967, it appears that CodeSandbox caches
package.json
and the changes made to it frompnpm update next
- which uses an outdated canary version of Next.jsEg. currently, the reproduction template URL uses
next@14.3.0-canary.26
is not the latest canaryhttps://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template
How?
Switch CodeSandbox "dev" task to update the pinned canary version of Next.js in the cached
package.json
to the latest Next.js canary:pnpm update next
pnpm update next@canary
This will:
A) upgrade the pinned version in the cached
package.json
fileB) perform this upgrade on forking of the sandbox (because of
restartOn.clone = true
)Caveats
Users restarting the
dev
task for any reason will get the (potentially unwanted) side effect of upgrading Next.js to the latest canary:1. User creates a reproduction on a certain canary version
2. New canary version is released
3. User restarts the
dev
task for any reason4. Next.js version updated, potentially leading to the bug disappearing from the reproduction (URL may be published somewhere publicly) 💥
This could be seen as unexpected behavior / a "paper cut".
However, it seems like the tradeoff is worth it, as having the latest canary on all new reproductions is higher value than allowing the potential (less common) action of restarting the
dev
task in a devbox.In future, I would however like to explore solutions with CodeSandbox that will allow for restarting the dev server without this unwanted side effect, eg. potentially with an environment variable or something similar.
cc @styfle