Closed alexanderniebuhr closed 1 month ago
This has a workaround, add the following to your astro config
vite: {
build: {
rollupOptions: {
external: ['qrcode'],
}
}
},
I think the issue is that when bundling for Cloudflare using ssr.target
webworker
, Vite will use the browser
variant of the packages where possible as it's assumed that the browser-bundle is more likely to run compared to the node-bundle.
However, there's another problem here where the endpoint is getting prerendered, so technically we will run the code within node instead of workerd. I suppose this is another reason we need a secondary build for prerendering to be more robust.
I think the workaround you showed here is fine (setting ssr.external: ['qrcode']
also works too). But for a workaround within @astrojs/cloudflare
, I'm not quite sure if it's possible at the moment.
I suppose this is another reason we need a secondary build for prerendering to be more robust.
@bluwy yeah, or at least to set different vite configurations for the different types. So that we can make sure on-demand rendered pages get the vite config which are needed for Cloudflare, while prerendered pages will keep the settings which work for node 🤔
This will be resolved, once upstream prerendering solution is more robust.
Describe the Bug
astro build
doesn't workWhat's the expected result?
astro build
to work successfullyLink to Minimal Reproducible Example
https://github.com/mrthiti/astro-cloudflare-root-cause
Participation