Repository navigation
Support Cloudflare Vite plugin v2 - #18119
Conversation
🦋 Changeset detectedLatest commit: 79b5018 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 |
3f1e57c to
c6357ef
Compare
| --- | ||
| 'astro': minor | ||
| --- | ||
|
|
||
| Astro now treats Vite's resolved `outDir` values as the source of truth for build output. Generated assets, build hook `dir` values, and SSR manifest paths use the resolved client, server, and prerender directories. Custom prerenderer factories also receive these directories through a new context argument. |
There was a problem hiding this comment.
I would rewrite this changeset from the user point of view.
| if (cloudflareOptions.configPath) { | ||
| addWatchFile(new URL(cloudflareOptions.configPath, config.root)); | ||
| } | ||
|
|
||
| addWatchFile(new URL('./wrangler.toml', config.root)); | ||
| addWatchFile(new URL('./wrangler.json', config.root)); | ||
| addWatchFile(new URL('./wrangler.jsonc', config.root)); |
There was a problem hiding this comment.
Don't we need to watch the new configuration file?
There was a problem hiding this comment.
Hmm, that depends on how Astro restarts interact with Vite restarts. We restart the Vite dev server when the config file or any of its dependencies change. Watching it here would be tricky because you don't know its dependencies.
There was a problem hiding this comment.
I would check to make sure restarting the dev server in Astro works that same as in vite dev, it might not.
There was a problem hiding this comment.
I got an agent to investigate this. Here is its reply:
The Cloudflare plugin already watches cloudflare.config.ts and its dependencies, so watching only the top-level file here would be incomplete and would cause both Astro and Cloudflare to initiate restarts. However, Matthew’s concern uncovered an Astro lifecycle issue: Vite replaces its watcher during a native restart, and Astro’s externally registered restart/content listeners are not reattached after a plugin-initiated restart. We should fix that listener lifecycle and add an astro dev regression test rather than restore addWatchFile() here.
| "peerDependencies": { | ||
| "astro": "^7.2.0", | ||
| "wrangler": "^4.125.0" | ||
| "astro": "^7.4.0" |
There was a problem hiding this comment.
Was this change intentional? We usually don't bump it unless we need a specific API from astro
There was a problem hiding this comment.
This PR relies on #18112, which makes changes to Astro core, so I assumed that would require the bump?
There was a problem hiding this comment.
Oh I see. Makes sense then. So I suggest #18112 to main
There was a problem hiding this comment.
I will change this to 7.4.0-beta.0
Depends on #18112.
Until that PR lands, the focused diff is:
jamesopstad/astro@resolved-vite-output-dirs...support-cloudflare-vite-plugin-v2
Changes
Updates the adapter to use v2 of
@cloudflare/vite-pluginand support deployment withcf.Projects should replace Wrangler configuration with
cloudflare.config.ts, importing configuration utilities fromcf/config.cfshould also be used in place of Wrangler for deployment.The adapter’s
configPathoption has been removed. Configuration is always loaded from acloudflare.config.tsfile in the project root.wrangleris no longer a peer dependency of@astrojs/cloudflare.Testing
Tests updated as appropriate.
Docs
withastro/docs#14614