Minimal repro for a build crash with @astrojs/cloudflare when
experimental.advancedRouting uses a custom fetchFile.
pnpm install
pnpm build(0 , __vite_ssr_import_0__.createGetEnv) is not a function
at runInRunnerObject (workers/runner-worker/index.js:107:3)
src/worker.tsis thefetchFile. It importscffrom@astrojs/cloudflare/fetch.- Set
experimental.advancedRoutingtotrueand the build passes, becausevirtual:astro:fetchablefalls back toDefaultFetchHandlerand never imports@astrojs/cloudflare/fetch. - It's a circular import:
fetch.jsrunssetGetEnv(createGetEnv(globalEnv))andcreateApp()at module top level.createAppcomes fromastro/app/entrypoint, which importsvirtual:astro:fetchable, which re-exportsworker.ts, which imports@astrojs/cloudflare/fetchagain. - Importing
cflazily inside the handler (const { cf } = await import('@astrojs/cloudflare/fetch')) breaks the static back-edge and the build passes.