kit icon indicating copy to clipboard operation
kit copied to clipboard

Disabling SSR doesn't work

Open s1nistr4 opened this issue 2 years ago • 1 comments

Describe the bug

Putting export const ssr = false in src/+layout.js doesn't disable SSR, even though the docs say so. After running npm run build it still generates server code. There are many reasons to not use it such as using your own API written in something other than Node, you could roll 2 servers but it's a huge pain and there should be working support for writing single page apps

Reproduction

.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
    Memory: 3.53 GB / 10.95 GB
  Binaries:
    Node: 20.0.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.7.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.43)
    Internet Explorer: 11.0.22621.1

Severity

blocking all usage of SvelteKit

Additional Information

No response

s1nistr4 avatar Jun 16 '23 06:06 s1nistr4

Please provide a reproduction repository to clarify what you mean. export const ssr = false does turn off server side rendering. But it does not prevent you from writing code that needs a server - but you can also write it in such a way that you get a simple SPA with one index.html that loads all the JS. More info here: https://kit.svelte.dev/docs/single-page-apps

dummdidumm avatar Jun 16 '23 13:06 dummdidumm

Closing due to inactivity.

Conduitry avatar Jul 02 '23 14:07 Conduitry

I have to second the OP's problem. The reproduction is simple (i use TypeScript and Skeleton and all testing options):

bun create svelte@latest my-app
cd my-app
bun install
echo "export const ssr = false;" > src/routes/+layout.js
bun run build

As result, the whole doubled build-process for the Server runs and .svelte-kit/output/server gets populated.

Using pnpm instead of bun, doesn't change anything. Adding the adapter-static too, does not change anything apart from then pushing all into build/.

Originally i came from a skeleton.dev starter. Which does have a +layout.svelte. Which is then confusing in where to put the export const ssr = false; as stated here: https://kit.svelte.dev/docs/single-page-apps.

And that started a hunt through stackoverflow, issues and PR, with changing errors the build process presented ("ssr ignorend", "config option doesn't exits" ...)

guradia avatar Oct 30 '23 13:10 guradia

I'm facing the same issue as @guradia mentioned.

minhui-foxtel avatar Nov 24 '23 06:11 minhui-foxtel

Seeing the same thing here. I need my build process to be conditional (selectable between adapter-node and adapter-static) and was worried about the export const ssr = false requirement in +layout.js. But I guess it doesn't matter since it doesn't seem to change anything.

I also tried putting +layout.js at the actual root (one level above routes) since that's what the documentation says. Doesn't seem to matter.

justindthomas avatar Mar 10 '24 01:03 justindthomas