-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
feature / enhancementNew feature or requestNew feature or request
Milestone
Description
Describe the bug
Even though I did everything the docs provide in order to disable any form of server side rendering or static site generation, the dev server tries to execute my code on the server.
Reproduction
npm create svelte@latest my-app
cd my-app
npm installEdit src/routes/+layout.ts according to https://kit.svelte.dev/docs/single-page-apps
export const ssr = false;
export const prerender = false;Edit svelte.config.js according to https://kit.svelte.dev/docs/single-page-apps#usage
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter({
fallback: 'index.html'
}),
}
};Create some code that will only work on client side
// +layout.ts
localStorage.setItem('test', 'lol');
Start the dev server
npm run devOpen the website in browser, and there will be an error complaining about localStorage not being definded.
Logs
No response
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (4) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 870.74 MB / 1.91 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.5.1 - /usr/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 9.8.0 - /usr/bin/npm
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.2.2
@sveltejs/adapter-static: ^3.0.2 => 3.0.2
@sveltejs/kit: ^2.0.0 => 2.5.20
@sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.1
svelte: ^4.2.7 => 4.2.18
vite: ^5.0.3 => 5.3.5Severity
serious, but I can work around it
Additional Information
No response
theodorejb
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or request