withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
43.84k stars 2.28k forks source link

Javascript API routes throw an error in hybrid rendering mode if set to render dynamically #11283

Open varialweb opened 1 week ago

varialweb commented 1 week ago

Astro Info

Astro                    v4.10.1
Node                     v20.9.0
System                   Windows (x64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind
                         @astrojs/svelte

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

If you have the project configured to hybrid rendering, and your API route uses javascript and you set export const prerender = false it will throw the error:

A prerender export has been detected, but its value cannot be statically analyzed.
Expected false value but got false .

It does not throw this error if you change the file to typescript.

What's the expected result?

I would expect the prerender const to work properly regardless of using typescript or javascript.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-7ycbzn?file=src%2Fcomponents%2FContactForm.svelte

Participation

varialweb commented 1 week ago

Also I tried to get this working in StackBlitz, but the API routes wont work at all for me in there, so in order to reproduce this, you may have to create it locally on your machine.

ematipico commented 1 week ago

Also I tried to get this working in StackBlitz, but the API routes wont work at all for me in there, so in order to reproduce this, you may have to create it locally on your machine.

So just downloading the stackblitz repository is enough?

matthewp commented 1 week ago

That is pretty odd, will take a look.