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

adapter-static still runs ssr in npm run dev #9410

Closed
ianengelbrecht opened this issue Mar 11, 2023 · 3 comments
Closed

adapter-static still runs ssr in npm run dev #9410

ianengelbrecht opened this issue Mar 11, 2023 · 3 comments

Comments

@ianengelbrecht
Copy link

Describe the bug

Using adapter-static to create an SPA, as per instructions at https://kit.svelte.dev/docs/single-page-apps and https://kit.svelte.dev/docs/single-page-apps#usage gives a message saying ssr compile in progress ...

I would have expected no SSR at all. In this case I'm using indexedDB (via Dexie via RXDB), which throws an error as there is no indexedDB on the server.

Repo created from skeleton template. No server side code at all.

Seems related to issue #9161

Reproduction

https://github.com/ianengelbrecht/svelte-pwa-ktt

Just clone, npm install, npm run dev and you'll see the resulting error in the console.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 16.36 GB / 31.89 GB
  Binaries:
    Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 96.0.4664.45
    Edge: Spartan (44.18362.1593.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.0.0
    @sveltejs/adapter-static: ^2.0.1 => 2.0.1
    @sveltejs/kit: ^1.5.0 => 1.11.0
    svelte: ^3.54.0 => 3.56.0
    vite: ^4.0.0 => 4.1.4

Severity

annoyance

Additional Information

Annoyance as I'm just playing around here to see how things work, but could be more serious if this was a real project.

@eltigerchino
Copy link
Member

You'll need to add a src/routes/+layout.js file with the line export const ssr = false;.

You can turn any SvelteKit app, using any adapter, into a fully client-rendered single-page app (SPA) by disabling SSR at the root layout:

https://kit.svelte.dev/docs/single-page-apps

Below is a link to a working example.

https://stackblitz.com/edit/github-csyvke?file=src/routes/+layout.js

@lukebrdn
Copy link

lukebrdn commented Mar 15, 2023

I've followed the steps above and added src/routes/+layout.js as recommended by @s3812497 and I still see the [vite-plugin-svelte] ssr compile done. log after running npm run dev -- --open.

@eltigerchino eltigerchino reopened this Mar 15, 2023
@dummdidumm
Copy link
Member

This is just an info that vite-plugin-svelte did compile something for SSR (but there's nothing that runs this). I don't think there's a sensible way to disable this during dev without degrading the DX when switching between rendering modes.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants