Skip to content

Fix HMR crash when editing content collection files in Cloudflare adapter projects using zod v4#16109

Merged
matthewp merged 1 commit intomainfrom
fix-ssr-import-meta-collision
Mar 27, 2026
Merged

Fix HMR crash when editing content collection files in Cloudflare adapter projects using zod v4#16109
matthewp merged 1 commit intomainfrom
fix-ssr-import-meta-collision

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

@matthewp matthewp commented Mar 26, 2026

Changes

  • Fixes a crash (Cannot split a chunk that has already been edited) that occurs when editing content collection files during dev in Cloudflare adapter
  • Adds banner: { js: '' } to esbuildOptions in the configEnvironment hook for server environments. This suppresses the createRequire(import.meta.url) banner that Vite prepends to pre-bundled SSR chunks, which is the trigger for the collision.
  • The root cause is a Vite bug (vitejs/vite#22004): Vite's SSR transform replaces import.meta at positions 69–80, then tries to also replace the meta identifier (positions 76–80) from zod v4's meta export — but those positions are already inside the edited range. The fix is merged on Vite main (vitejs/vite#22019) but not yet backported to v7.

Testing

  • Manually verified

Docs

N/A, bug fix

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 9208a53

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 Mar 26, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label Mar 26, 2026
@github-actions github-actions bot removed the pr preview Apply this label to a PR to generate a preview release label Mar 26, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 26, 2026

npm i https://pkg.pr.new/astro@16109
npm i https://pkg.pr.new/@astrojs/cloudflare@16109

commit: 9208a53

@matthewp matthewp marked this pull request as ready for review March 26, 2026 19:59
@matthewp matthewp merged commit c887b4a into main Mar 27, 2026
23 checks passed
@matthewp matthewp deleted the fix-ssr-import-meta-collision branch March 27, 2026 18:42
@astrobot-houston astrobot-houston mentioned this pull request Mar 27, 2026
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