sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.49k stars 1.89k forks source link

Prerender when marked not to prerender #10515

Open LegendTomaszKwiatkowski opened 1 year ago

LegendTomaszKwiatkowski commented 1 year ago

Describe the bug

In my app, I build 2 apps, one is for development with all prerender false but with entries specified. That worked fine so far. And other app have some routes set to prerender and that also worked fine. I've added new server side more comples route like

forum/[...slug=noAssets] Inside which I have +server.ts, +page.server.ts, +page.svelte, +page.ts Which in each of this files I've specifically said export const prerender = false at all times. I still have kit.prerender.entries = ['/forum'], which to my understanding shouldn't matter, and it never did until now. But I get error when building node app, it tries to prerender /forum

How can I debug what triggers it to be marked for prerender ?

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-af8uvi?file=src%2Froutes%2Fforum%2F%5B...slug%5D%2F%2Bserver.js run npm run build

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 5.97 GB / 14.64 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
    pnpm: 7.13.4 - /mnt/c/Users/user/AppData/Roaming/npm/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.3 
    @sveltejs/adapter-node: ^1.1.0 => 1.3.1 
    @sveltejs/adapter-static: ^1.0.1 => 1.0.6 
    @sveltejs/kit: 1.22.0 => 1.22.0 
    @sveltejs/package: 1.0.0 => 1.0.0 
    @sveltejs/vite-plugin-svelte: ^2.0.2 => 2.4.3 
    svelte: 3.55.1 => 3.55.1 
    vite: ^4.0.1 => 4.4.7

Severity

serious, but I can work around it

Additional Information

No response

dummdidumm commented 1 year ago

please provide a ready-made reproduction. If every maintainer has to recreate every reproduction just from description that doesn't scale and costs a lot of time.

LegendTomaszKwiatkowski commented 1 year ago

please provide a ready-made reproduction. If every maintainer has to recreate every reproduction just from description that doesn't scale and costs a lot of time.

added reproduction link https://stackblitz.com/edit/sveltejs-kit-template-default-af8uvi?file=src%2Froutes%2Fforum%2F%5B...slug%5D%2F%2Bserver.js just run npm run build

dummdidumm commented 1 year ago

It seems it happens when there's both a +page(.server).ts and +server.ts present that somehow prerendering fails then when starting from a non-prerenderable entry point.

LegendTomaszKwiatkowski commented 1 year ago

do you think there is something I could do ? or it's a adapter-node bug ? for now I can remove entries when building for dev, but it does not seem right. Also I've marked all the files as prerender = false but that somehow is ignored ?

korcekj commented 1 year ago

Hi, having similar issue while pre-rendering. Got "Error: /api/+server.ts is not prerenderable" during the build (with adapter-vercel) although i have set prerender = false to that specific +server.ts file. Therefore i am curios to know if there is any update? Thank you.

eltigerchino commented 12 months ago

@korcekj can you provide a repository reproduction?

korcekj commented 11 months ago

@s3812497 I don't think it will be necessary because I found the root cause. The route i was trying to pre-render leads to an API route which is marked as not pre-renderable. In this case i have to either change it to pre-renderable or host the API separately. No need to investigate further, thank you.