Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare adapter removing Sanity Integration embedded studio JS files #271

Closed
1 task
Joelkang opened this issue May 27, 2024 · 1 comment
Closed
1 task
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) pkg: cloudflare

Comments

@Joelkang
Copy link

Joelkang commented May 27, 2024

Astro Info

Astro                    v4.9.2
Node                     v18.20.3
System                   Linux (x64)
Package Manager          pnpm
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @sanity/astro
                         @astrojs/react

Describe the Bug

There are actually 2 bugs I've found:

  1. I can't even get the minimal repro to build:
Cannot access '_renderer0' before initialization
  Stack trace:
    at async BuildPipeline.retrieveManifest (file:///home/projects/github-emesfy/node_modules/astro/dist/core/build/pipeline.js:125:26)
    at async Module.staticBuild (file:///home/projects/github-emesfy/node_modules/astro/dist/core/build/static-build.js:130:7)

For whatever reason, I'm not seeing this in my actual repo (but I'm using pnpm whereas stackblitz uses npm so that could be it)


  1. The actual bug I wanted to report:

With the sanity plugin, I'm embedding the Sanity studio in my app (in the example at /studio), as per this guide. This actually works when you run astro dev, and the /studio route loads and the Sanity studio renders. However, when I run astro build and deploy on Cloudflare, my /studio route throws an exception that a prerender_{HASH} file is missing. Looking into the dist folder, indeed that file seems to be missing, which I believe is a similar issue to #211.

My hunch is that it's got something to do with these lines where the route added by the integration is using prerender to generate the route... but then not actually prerendering. All I can tell is that the cloudflare integrations is removing the prerender chunk, causing it to explode in production builds.

What's the expected result?

The studio route should work in production.

For now, I've done a dirty and added an actual pages/studio.astro with this content:

---
import StudioRoute from '@sanity/astro/studio/studio-route.astro'
export const prerender = false
---
<StudioRoute />

Which generates a chunk/studio_HASH.mjs page that correctly renders the studio.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-emesfy?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@Joelkang Joelkang changed the title Sanity Integration and Cloudflare adapter build issues Cloudflare adapter removing Sanity Integration studio JS files May 27, 2024
@Joelkang Joelkang changed the title Cloudflare adapter removing Sanity Integration studio JS files Cloudflare adapter removing Sanity Integration embedded studio JS files May 27, 2024
@alexanderniebuhr alexanderniebuhr added pkg: cloudflare - P4: important Violate documented behavior or significantly improves performance (priority) labels May 27, 2024
@alexanderniebuhr
Copy link
Member

This should be fixed in the v11 release, which will be published later today to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) pkg: cloudflare
Projects
None yet
Development

No branches or pull requests

2 participants