Repository navigation
[autoconfig] Move the Wrangler migration from codemods into runAutoConfig - #16993
Closed
edmundhung wants to merge 29 commits into
Closed
edmundhung wants to merge 29 commits into
edmundhung wants to merge 29 commits into
Conversation
Contributor
|
LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/cli-shared-helpers
@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/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 17, 2026 22:30
8eeb174 to
38a98a5
Compare
🦋 Changeset detectedLatest commit: 53d65b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 17, 2026 22:41
38a98a5 to
fd664f2
Compare
edmundhung
changed the base branch from
main
to
edmundhung/autoconfig-config-edits-warn
November 17, 2026 22:42
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 17, 2026 23:52
fd664f2 to
637d3a4
Compare
2 of 5 tasks
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 18, 2026 11:24
637d3a4 to
03f4805
Compare
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 18, 2026 11:59
03f4805 to
5452247
Compare
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 18, 2026 12:03
5452247 to
a4022cd
Compare
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 18, 2026 12:21
a4022cd to
3e87ed1
Compare
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
2 times, most recently
from
November 18, 2026 16:10
0daffca to
701b126
Compare
2 of 5 tasks
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 19, 2026 13:15
701b126 to
15d55fd
Compare
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
2 times, most recently
from
November 19, 2026 14:29
478d982 to
caa1dbd
Compare
For the cf target, a root wrangler.jsonc, wrangler.toml or wrangler.json now makes the project one that setup migrates, and the Worker keeps the Wrangler config's name. Several configs are an error rather than a guess, and an existing cloudflare.config.ts takes precedence. The wrangler-to-cf codemod uses this instead of its own lookup.
edmundhung
force-pushed
the
autoconfig-project-setup-engine
branch
from
November 26, 2026 00:48
963e459 to
eb40651
Compare
…ework's A Wrangler project is already set up for its framework, so migrating it keeps its entrypoint, compatibility flags and bindings. The framework's settings only fill in what the Wrangler config doesn't set.
A Wrangler Astro project already has the settings its migrated config needs, and without a Wrangler config `astro add` still writes cloudflare.config.ts.
Drops the React Router changeset and the converter's import note, which are too detailed for the release notes.
…ts own Worker config runAutoConfig now always runs the detected framework's setup. Setup gets the project's existing Worker config, which for now is a Wrangler config that setup migrates, and decides what to do with it: - Static and Next.js set up nothing (vinext init refuses Wrangler projects). - React Router and TanStack Start keep the project's entrypoint. - SolidStart replaces Nitro's output entry, which the Vite plugin no longer builds. - Astro removes only the cloudflare.config.ts that `astro add` scaffolds. The framework's entrypoint replaces the one it was shown; its other settings only fill in what the Wrangler config doesn't set. The migration's bundler is the one the framework builds with, and otherwise the project's. A conflicting bundler option is an error. Frameworks that autoconfig can't set up leave a project with its own Worker config as it is. Pages projects are refused, including ones whose Wrangler config sets pages_build_output_dir. installDependencies: false makes setup install nothing: the migration lists the packages it needs, and frameworks that need packages do nothing. enableTargetCliInstallation goes back to covering only the target CLI. A given Wrangler config is migrated in its own project, which must be the config's directory. The Git check moves to the codemod, which words its own bypass hint. The converter no longer imports node:path. A framework that isn't installed reports that the project's dependencies need installing.
…their own Worker config The rework removed run.ts's output directory check along with the Wrangler special cases, so a project with neither an output directory nor a Wrangler config reached the setup prompt instead of failing as on main.
…as written Detection decides whether a project is a Pages one from its Wrangler config, which is the caller's parsed config or the one setup migrates, read as written.
Detection reads the Wrangler config that setup migrates and carries it on the details, so runAutoConfig and the migration use that copy instead of reading the file again. Detection types the config as RawConfig, which Wrangler's parsed config already satisfies.
…nfig Detection no longer looks for the project above a given Wrangler config. The caller's projectPath is the project, and a Wrangler config outside its folder isn't migrated yet, since the migration keeps the config's relative paths. The codemod migrates an exact --config in that config's folder, as before.
No caller passes one yet: the codemod uses the folder of an exact --config as the project. Supporting that case properly, by writing at the project root and rebasing the config's paths, follows separately.
It now says which bundler isn't supported and to use the framework's default instead.
Detection now reads the Wrangler config in one call, getting undefined when the project has none. Also restores a blank line in getDetailsForAutoConfig that an earlier change dropped.
Detection keeps its output directory check for the Wrangler target only. For cf, runAutoConfig reports it, and only for a project without a Worker config of its own: a project with no framework, Wrangler config or index.html now hears that nothing could be found to deploy, and how to fix that.
Detection keeps main's check, now for the Wrangler target only, and runAutoConfig keeps main's assert for Wrangler. For cf it reports a missing output directory itself, inline, for projects without a Worker config of their own.
outputDir is passed as string | undefined rather than being optional, and the new options don't get JSDoc that the existing ones don't have.
A framework's setup returns null when it does nothing for a project. The no-op framework refuses Pages and, for projects without a Worker config of their own, the frameworks autoconfig can't set up; the frameworks cf can't set up yet refuse through validateFrameworkTargetSupport, unchanged from main. runAutoConfig no longer checks support itself, and no framework version is checked for a framework the target can't set up.
…frameworks They passed hand-made framework objects to runAutoConfig, which no longer refuses by id: the no-op framework that detection creates refuses them now, and autoconfig's own tests cover both messages.
runAutoConfig only migrates projects without a cloudflare.config.ts, so any file the migration finds was written by this run's framework setup, as `astro add` does. The migration no longer refuses existing files, and Astro's setup no longer removes the config it scaffolds.
2 of 5 tasks
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.
Part of RM-31810.
Moves the Wrangler-to-cf migration from
@cloudflare/codemodsinto@cloudflare/autoconfigand makes it part of autoconfig's setup.getDetailsForAutoConfig()reports a project's Wrangler config, andrunAutoConfig()runs the framework's setup, which sees the Wrangler config and decides what to do, then migrates the Wrangler config as the project's Worker config, in one pass. Acloudflare.config.tsstays the signal that a project is set up. cf can call autoconfig instead of codemods, and the codemodswrangler-to-cfcommand runs the same pass.convertWranglerConfigmoves to@cloudflare/autoconfig/wrangler-to-cf.Setting up the framework of projects that already have a
cloudflare.config.tsfollows in #17177. The migration's files are moved as renames (36), most edited only for their new import paths.Examples
The codemod and
cf buildon two projects, using this branch's build:A plain Worker:
wrangler.jsoncwith a KV namespace, a var and a cronA React Router app from
npm create cloudflare -- --framework=react-routerpackage.jsongetscf,@cloudflare/vite-plugingoes from^1.70.2to^2.0.0-rc.0, and"deploy"becomes"cf deploy".migrateWranglerToCfexport, and the changeset describes the change