Skip to content

fix(cloudflare): discover server-side dependencies in .astro frontmatter#15452

Merged
matthewp merged 4 commits intomainfrom
cf-ssr-deps-disc
Feb 11, 2026
Merged

fix(cloudflare): discover server-side dependencies in .astro frontmatter#15452
matthewp merged 4 commits intomainfrom
cf-ssr-deps-disc

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Feb 9, 2026

Changes

  • Adds an esbuild plugin that extracts frontmatter from .astro files during Vite's dependency optimization scan phase
  • This allows server-side imports in .astro frontmatter to be discovered ahead of time, avoiding the "new dependencies optimized" message and page reload during dev

Previously, Vite's scanner only looked for <script> tags in .astro files, missing the frontmatter section where server-side imports live. This caused npm dependencies like ms to be discovered lazily on first request.

This is only done in the Cloudflare adapter because dependency optimization is not needed in Node.js where these deps are external.

Testing

Added a new test fixture ssr-deps with a test that:

  1. Starts a dev server
  2. Clears the Vite cache
  3. Makes a request to a page that imports a third-party dependency (ms) in frontmatter
  4. Verifies no "new dependencies optimized" log message appears

Docs

N/A, bug fix

@changeset-bot
Copy link

changeset-bot bot commented Feb 9, 2026

🦋 Changeset detected

Latest commit: 18ade2d

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 github-actions bot added the pkg: integration Related to any renderer integration (scope) label Feb 9, 2026
@matthewp matthewp marked this pull request as ready for review February 9, 2026 18:58
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
@matthewp matthewp merged commit e1aa3f3 into main Feb 11, 2026
41 of 42 checks passed
@matthewp matthewp deleted the cf-ssr-deps-disc branch February 11, 2026 13:10
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.

2 participants