Skip to content

fix: cloudflare ssr deps optimization#16708

Merged
ematipico merged 5 commits into
withastro:mainfrom
fkatsuhiro:fix/cloudflare-ssr-deps-optimization
May 18, 2026
Merged

fix: cloudflare ssr deps optimization#16708
ematipico merged 5 commits into
withastro:mainfrom
fkatsuhiro:fix/cloudflare-ssr-deps-optimization

Conversation

@fkatsuhiro
Copy link
Copy Markdown
Contributor

@fkatsuhiro fkatsuhiro commented May 12, 2026

Changes

Close #16248

Root cause

Dependencies imported within .astro file frontmatter are not detected during Vite's initial Dependency Optimization phase. This leads to several issues.

Solution

I have added an onResolve handler to the astro-frontmatter-scan plugin to ensure proper dependency discovery

Testing

Before Implemented

スクリーンショット 2026-05-11 8 11 09

After Implemented

スクリーンショット 2026-05-12 21 44 31

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: e0be125

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

This PR includes changesets to release 37 packages
Name Type
@astrojs/cloudflare Patch
@test/astro-cloudflare-node-prerender-mdx Patch
@test/astro-cloudflare Patch
@test/astro-cloudflare-allowed-hosts Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-binding-image-service Patch
@test/astro-cloudflare-cache-provider-wait-until Patch
@test/astro-cloudflare-client-address Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-dev-image-endpoint Patch
@test/cloudflare-dev-ssr-optimization Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-external-redirects Patch
@test/astro-cloudflare-internal-redirects Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-prerender-queue-consumers Patch
@test/astro-cloudflare-prerender-styles Patch
@test/astro-cloudflare-prerenderer-errors Patch
@test/routing-priority-cloudflare Patch
@test/cf-server-entry Patch
@test/astro-cloudflare-server-island-prerender-framework Patch
@test/astro-cloudflare-sessions Patch
@test/astro-cloudflare-sql-import Patch
@test/cf-ssr-deps Patch
@test/astro-cloudflare-static Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-top-level-return Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-react Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch

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 github-actions Bot added the pkg: integration Related to any renderer integration (scope) label May 12, 2026
@fkatsuhiro fkatsuhiro force-pushed the fix/cloudflare-ssr-deps-optimization branch from 46a71bc to fdecfb1 Compare May 12, 2026 12:52
@fkatsuhiro fkatsuhiro changed the title Fix/cloudflare ssr deps optimization fix: cloudflare ssr deps optimization May 12, 2026
@fkatsuhiro fkatsuhiro marked this pull request as ready for review May 12, 2026 13:40
@ematipico
Copy link
Copy Markdown
Member

@fkatsuhiro fkatsuhiro force-pushed the fix/cloudflare-ssr-deps-optimization branch from 7396e43 to f46f938 Compare May 12, 2026 23:16
@fkatsuhiro
Copy link
Copy Markdown
Contributor Author

@fkatsuhiro when you submit a PR that closes an existing issue, please use github magic comments https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

Oh, I had no idea about it!
Thanks for letting me know. I've applied the changes!

Comment thread .changeset/modern-rooms-cry.md Outdated
Comment on lines +5 to +7
`vite:dep-scan` intercepted `.astro` files before `astroFrontmatterScanPlugin`, silently skipping frontmatter imports and triggering cascading re-optimization cycles that caused "The file does not exist" crashes in workerd on first request.

Fixed by adding `onResolve` to claim `.astro` files first, pre-including View Transitions modules in optimizeDeps.include, and enabling `ignoreOutdatedRequests` on server environments.
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.

Can you reword the changeset by following these guidelines? https://contribute.docs.astro.build/docs-for-code-changes/changesets/#tips-and-examples

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've update this.
Could you check this, if you are available? Thank you.

@ematipico ematipico self-assigned this May 15, 2026
@fkatsuhiro fkatsuhiro force-pushed the fix/cloudflare-ssr-deps-optimization branch 2 times, most recently from 1770753 to d886b3d Compare May 17, 2026 14:48
@fkatsuhiro fkatsuhiro force-pushed the fix/cloudflare-ssr-deps-optimization branch from d886b3d to e0be125 Compare May 18, 2026 11:44
@ematipico ematipico merged commit bb709ff into withastro:main May 18, 2026
23 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 18, 2026
pdlug added a commit to nicia-ai/typegraph that referenced this pull request May 20, 2026
Pins @astrojs/cloudflare at 13.5.1; 13.5.2 (PR withastro/astro#16708) broke `astro check`/`astro build` by making esbuild bundle expressive-code's `virtual:` modules. Bumps npm-run-all2 to v9 (now ESM-only, Node engine ^22.22.2 || ^24.15.0) — root is already ESM and CI runs 22/24.
pdlug added a commit to nicia-ai/typegraph that referenced this pull request May 20, 2026
Lifts the 13.5.1 pin from #146. Upstream fix for the expressive-code
virtual-module bundling issue shipped in 13.5.3 (withastro/astro#16708
follow-up). Verified `pnpm --filter @nicia-ai/typegraph-docs typecheck`
and `build` both succeed.

Other bumps (all dev-only): astro 6.3.5 → ^6.3.6, vitest 4.1.6 → ^4.1.7,
@vitest/coverage-v8 4.1.6 → ^4.1.7, eslint-plugin-functional 9.0.4 → ^9.0.5.
p-linnane added a commit to starhaven-io/pinprick that referenced this pull request May 26, 2026
@astrojs/cloudflare 13.5.2 shipped withastro/astro#16708, which added an
esbuild dep-scan plugin that incorrectly tried to bundle virtual: modules
imported from .astro frontmatter. astro-expressive-code (pulled in by
@astrojs/starlight) imports virtual:astro-expressive-code/{config,api},
so astro build fails with "Could not resolve" errors.

Reverted upstream in withastro/astro#16801, released in 13.5.3.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Patrick Linnane <patrick@linnane.io>
p-linnane added a commit to starhaven-io/pinprick that referenced this pull request May 26, 2026
…2 updates (#197)

* chore(deps): bump the npm-dependencies group across 1 directory with 2 updates

Bumps the npm-dependencies group with 2 updates in the /site directory: [@astrojs/cloudflare](https://github.com/withastro/astro/tree/HEAD/packages/integrations/cloudflare) and [astro](https://github.com/withastro/astro/tree/HEAD/packages/astro).


Updates `@astrojs/cloudflare` from 13.5.1 to 13.5.2
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/integrations/cloudflare/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/@astrojs/cloudflare@13.5.2/packages/integrations/cloudflare)

Updates `astro` from 6.3.3 to 6.3.5
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/astro@6.3.5/packages/astro)

---
updated-dependencies:
- dependency-name: "@astrojs/cloudflare"
  dependency-version: 13.5.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
- dependency-name: astro
  dependency-version: 6.3.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(site): bump @astrojs/cloudflare to 13.5.5 to unbreak build

@astrojs/cloudflare 13.5.2 shipped withastro/astro#16708, which added an
esbuild dep-scan plugin that incorrectly tried to bundle virtual: modules
imported from .astro frontmatter. astro-expressive-code (pulled in by
@astrojs/starlight) imports virtual:astro-expressive-code/{config,api},
so astro build fails with "Could not resolve" errors.

Reverted upstream in withastro/astro#16801, released in 13.5.3.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Patrick Linnane <patrick@linnane.io>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Patrick Linnane <patrick@linnane.io>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Cloudflare adapter SSR environment does not pre-compile dependencies — cascading "program reload" and chunk-not-found errors in dev

2 participants