Skip to content

Fix autoconfig for Astro 6+ projects to skip wrangler config generation#12856

Merged
edmundhung merged 4 commits intomainfrom
dario/autoconfig-astro-6
Mar 12, 2026
Merged

Fix autoconfig for Astro 6+ projects to skip wrangler config generation#12856
edmundhung merged 4 commits intomainfrom
dario/autoconfig-astro-6

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Mar 11, 2026

Astro 6+ generates its own wrangler configuration on build, so autoconfig now detects the Astro version and skips creating a wrangler.jsonc file for projects using Astro 6 or later. This prevents conflicts between the autoconfig-generated config and Astro's built-in config generation.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: already tested in the experimental C3 e2es
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: establishes expected behavior

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 3af5fdf

The changes in this PR will be included in the next version bump.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 11, 2026

✅ All changesets look good

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Mar 11, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR makes autoconfig skip wrangler config generation for Astro 6+ projects (which generate their own wrangler config on build), by checking the installed Astro version with semiver and returning wranglerConfig: null for v6+.

Issues found:

  1. Copy-paste JSDoc bug (low severity): The getAstroVersion function's JSDoc comment says Gets the installed version of the "@solidjs/start" package — it was copied from solid-start.ts without updating the description. Posted a suggestion comment to fix it.

The rest of the changes look correct — the null-handling for wranglerConfig is properly threaded through buildOperationsSummary, the dry-run path, and the actual config-writing path. The type changes in types.ts and index.ts are consistent.

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 11, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12856

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12856

miniflare

npm i https://pkg.pr.new/miniflare@12856

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12856

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12856

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12856

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12856

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12856

wrangler

npm i https://pkg.pr.new/wrangler@12856

commit: 6a2e604

Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 11, 2026 18:43
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 11, 2026 18:43
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 11, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Comment on lines +45 to 48
// From version 6 Astro doesn't need a wrangler config file but generates a redirected config on build
return {
wranglerConfig: null,
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: if there is no wrangler config, how does astro decide the worker name in the generated config? based on the directory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json name, then directory

Comment thread .changeset/real-plants-slide.md Outdated
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Mar 11, 2026
Copy link
Copy Markdown
Member

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dario-piotrowicz I think you need to remove quarantine: true from the test config too.

@ascorbic
Copy link
Copy Markdown
Contributor

astro add cloudflare should create a wrangler.jsonc in older versions of Astro too, so I'm not sure you need the version check

Co-authored-by: Edmund Hung <edmund@cloudflare.com>
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

dario-piotrowicz commented Mar 11, 2026

@dario-piotrowicz I think you need to remove quarantine: true from the test config too.

good call! 🫡

Done: 3af5fdf

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

astro add cloudflare should create a wrangler.jsonc in older versions of Astro too, so I'm not sure you need the version check

oof.... this is a problem! 😓

The astro add x logic is part of the astro package, that is why I added the version check

Unfortunately it seems like it tries to install latest versions of the packages (that's why I guess you were asking if the version check is needed). This doesn't actually work in older version of astro because of dependency incompatibilities... see:
dependency incompatibilities of running `astro add cloudflare` on an astro 5 project

Meaning that we can fix this for current versions of Astro but projects using older version of Astro won't be auto-configurable 😓 mh... I am not sure how we can deal with that... the only options that come to mind for me are either not supporting older Astro majors or re-implement the astro add cloudflare logic in autoconfig for older Astro versions ourselves... 😓

what do you think?

@ascorbic
Copy link
Copy Markdown
Contributor

Oh weird. I assumed it would be a bit smarter there. That's not great

@edmundhung edmundhung merged commit 6ee18e1 into main Mar 12, 2026
41 of 47 checks passed
@edmundhung edmundhung deleted the dario/autoconfig-astro-6 branch March 12, 2026 17:33
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants