Repository navigation
Conversation
OpenNext builds into .open-next/ rather than the Build Output under .cloudflare/output/v0/ that cf deploys. vinext builds with the Cloudflare Vite plugin and writes cloudflare.config.ts itself, so use it for the cf target on the Next.js versions it supports. Earlier Next.js versions and the Wrangler target keep using OpenNext.
🦋 Changeset detectedLatest commit: 72ccac1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
|
I'm Bonk, and I've done a quick review of your PR. Configures Next.js 16
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
heads up @james-elicx |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
| if (!dryRun) { | ||
| await runCommand( | ||
| [ | ||
| ...dlx, | ||
| "vinext", | ||
| "init", | ||
| // `vinext init` prompts for these choices and fails in agent environments | ||
| // when they are missing, so we pass the defaults it uses when non-interactive | ||
| "--platform=cloudflare", | ||
| "--cdn-cache=none", | ||
| "--image-optimization=cloudflare-images", | ||
| // Cloudflare only serves pre-rendered routes when using the Static Assets cache | ||
| "--no-prerender", | ||
| ], | ||
| { | ||
| cwd: projectPath, | ||
| } | ||
| ); |
There was a problem hiding this comment.
🔴 Selected Worker name is ignored
When a user selects a different Worker name, vinext init receives no workerName. The generated configuration bypasses runAutoConfig, so deployment uses vinext's name instead.
Learn more
Autoconfig lets users choose a Worker name in confirmAutoConfigDetails. runAutoConfig normally writes it as the default Worker name, but workerConfig: null makes it preserve vinext's generated configuration instead. The command does not pass the chosen name to vinext.
Example: A project named storefront chooses storefront-production in the Worker-name prompt. Vinext receives no selected name, so deployment uses its generated name instead.
Recommended fix: Pass workerName to vinext if supported, or update the generated cloudflare.config.ts to use the selected name without discarding vinext's settings.
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes N/A.
When targeting
cf, autoconfig configures Next.js projects with@opennextjs/cloudflare migrate. OpenNext builds into.open-next/, whilecfbuilds and deploys from the Build Output under.cloudflare/output/v0/. vinext builds Next.js apps with the Cloudflare Vite plugin and itsinitcommand already targetscf, so this uses it for thecftarget instead.cftarget on Next.js 16 or later,NextJs.configure()runsvinext init --platform=cloudflare --cdn-cache=none --image-optimization=cloudflare-images --no-prerender. These flags match vinext's non-interactive defaults; without themvinext initprompts, and fails in agent environments.--no-prerenderis passed because Cloudflare serves pre-rendered routes only with the Static Assets cache.workerConfig: nullbecausevinext initwritescloudflare.config.ts, and returns avite buildbuild command.Validation: the autoconfig suite passes, as do the package typecheck and scoped lint and format checks. I also ran the built package against a fresh
create-next-appproject (Next.js 16.4.0) withtarget: "cf"from an agent environment:vinext initcompleted without prompting, the generatedcloudflare.config.tswas preserved, andvite buildproduced.cloudflare/output/v0/workers/default.Merge order
This is one of three related changes:
@cloudflare/autoconfig, but it must be incfbefore step 4, otherwise the firstcf devafter setup runsnext devrather thanvite dev.--nametovinext init) merges and is released.cftarget) is updated to pass the Worker name chosen during setup tovinext init --nameand to require the vinext release from step 2. It then merges and@cloudflare/autoconfigis released. (this PR)cfbumps@cloudflare/autoconfigto the release from step 3, after fix: analyse the project again after framework setup cf#260 has merged.cftarget.