Skip to content

Add backward-compatible autoconfig support for Astro v5 and v4 projects#12938

Merged
dario-piotrowicz merged 9 commits intomainfrom
dario/older_astro_config
Mar 19, 2026
Merged

Add backward-compatible autoconfig support for Astro v5 and v4 projects#12938
dario-piotrowicz merged 9 commits intomainfrom
dario/older_astro_config

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

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

This PR updates autoconfig to support applications using Astro v5 and v4 while erroring on older versions of astro


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
      • created an astro v5 project and astro v4 project
      • run npx <path-to-wrangler-built> setup
      • validated the output
      • run npm run preview and checked that the application is served correctly
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: UX improvement

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


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: c4ba137

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-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Mar 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

⚠️ Issues found

.changeset/sour-lions-march.md

Version type mismatch: The changeset is marked as patch, but the change adds new functionality — backward-compatible autoconfig support for Astro v4 and v5 projects. Per the changeset guidelines, new features and new configuration options should be minor, not patch. A patch is appropriate for bug fixes and small improvements; introducing new autoconfig logic for multiple Astro version ranges is a new feature.

Recommendation: Change "wrangler": patch to "wrangler": minor.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 17, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: c4ba137

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

This comment was marked as outdated.

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 17, 2026 16:01
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 17, 2026 16:01
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 17, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/older_astro_config branch from a896799 to 55ec991 Compare March 19, 2026 00:37
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

dario-piotrowicz and others added 7 commits March 19, 2026 17:41
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
When tsconfig.json has no explicit 'include' field (common for Astro
projects using "extends": "astro/tsconfigs/base"), adding an 'include'
array with only worker-configuration.d.ts would override the parent
config's includes, breaking type-checking.

Instead, warn the user to manually add the entry when no existing
'include' field is found.
When an Astro config already has an import from @astrojs/cloudflare with
a different local name (e.g. 'import adapter from "@astrojs/cloudflare"'),
the autoconfig now correctly uses that identifier instead of hardcoding
'cloudflare'. This prevents generating broken config with undefined
identifiers.
@dario-piotrowicz dario-piotrowicz force-pushed the dario/older_astro_config branch from 12435b0 to 46da614 Compare March 19, 2026 17:44
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM - I tested it with an Astro 4 project, which worked, but I haven't tried out all the different permutations.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 19, 2026
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

LGTM - I tested it with an Astro 4 project, which worked, but I haven't tried out all the different permutations.

Thanks! 🫶

I manually tested it with Astro 4, 5 and 6. I didn't test all the different permutations either as there are a few however the code should be correct and if something were not to work as expected we can always fix that later 🙂🙏

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@dario-piotrowicz dario-piotrowicz merged commit 71ab981 into main Mar 19, 2026
36 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/older_astro_config branch March 19, 2026 19:02
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 19, 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