-
- Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Describe the bug
kit/packages/kit/src/runtime/components/svelte-5/error.svelte
Lines 1 to 6 in e0f8e85
| <script> | |
| import { page } from '$app/state'; | |
| </script> | |
| <h1>{page.status}</h1> | |
| <p>{page.error?.message}</p> |
While this does import $app/state, it doesn't actually use any runes, so compiler will treat it as a legacy component due to lack of <svelte:options runes={true} />.
This produces three small side effects during compilation:
import 'svelte/internal/disclose-version'; + import 'svelte/internal/flags/legacy'; import 'svelte/internal/flags/async'; import * as $ from 'svelte/internal/client'; import { page } from '$app/state'; var root = $.from_html(`<h1> </h1> <p> </p>`, 1); export default function Page($$anchor, $$props) { - $.push($$props, true); + $.push($$props, false); + $.init(); var fragment = root();- SvelteKit unintentionally enables the legacy flag even if the rest of the project is entirely in Runes mode, so the bundle always includes it
- Sets the component context as legacy mode
- Calls the legacy
init
Reproduction
pnpm dlx sv create test # typescript, no other addonsSlightly alter svelte.config.js
const config = { compilerOptions: { // defaults to rune mode for the project, execept for `node_modules`. Can be removed in svelte 6. runes: ({ filename }) => { + if (filename.endsWith('@sveltejs/kit/src/runtime/components/svelte-5/error.svelte')) return true; const relativePath = relative(import.meta.dirname, filename); const pathSegments = relativePath.toLowerCase().split(sep); const isExternalLibrary = pathSegments.includes('node_modules'); return isExternalLibrary ? undefined : true; } }, kit: { // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://svelte.dev/docs/kit/adapters for more information about adapters. adapter: adapter(), + output: { bundleStrategy: 'single' } } };(comment out the svelte-5/error.svelte line to toggle behavior between current and suggested)
Vite 7, the difference:
(current) vite v7.3.1 building ssr environment for production... ✓ 153 modules transformed. vite v7.3.1 building client environment for production... ✓ 153 modules transformed. .svelte-kit/output/client/_app/version.json 0.03 kB │ gzip: 0.05 kB .svelte-kit/output/client/.vite/manifest.json 0.51 kB │ gzip: 0.24 kB .svelte-kit/output/client/_app/immutable/bundle.BTnJH-Mj.js 67.12 kB │ gzip: 25.57 kB (runes enabled error.svelte) ✓ 153 modules transformed. vite v7.3.1 building client environment for production... ✓ 152 modules transformed. .svelte-kit/output/client/_app/version.json 0.03 kB │ gzip: 0.05 kB .svelte-kit/output/client/.vite/manifest.json 0.51 kB │ gzip: 0.24 kB .svelte-kit/output/client/_app/immutable/bundle.aLI-mkLv.js 65.70 kB │ gzip: 25.01 kB 1.42 kB | gzip: 0.56 kB savings
Vite 8, the difference:
(current) vite v8.0.3 building ssr environment for production... ✓ 151 modules transformed. vite v8.0.3 building client environment for production... ✓ 154 modules transformed. computing gzip size... .svelte-kit/output/client/_app/version.json 0.02 kB │ gzip: 0.04 kB .svelte-kit/output/client/.vite/manifest.json 0.74 kB │ gzip: 0.26 kB .svelte-kit/output/client/_app/immutable/bundle.meV4uIi_.js 75.87 kB │ gzip: 28.85 kB (runes enabled error.svelte) vite v8.0.3 building ssr environment for production... ✓ 151 modules transformed. vite v8.0.3 building client environment for production... ✓ 153 modules transformed. computing gzip size... .svelte-kit/output/client/_app/version.json 0.02 kB │ gzip: 0.04 kB .svelte-kit/output/client/.vite/manifest.json 0.74 kB │ gzip: 0.26 kB .svelte-kit/output/client/_app/immutable/bundle.DRRUWnzY.js 74.84 kB │ gzip: 28.46 kB 1.03 kB | gzip: 0.39 kB savings
Logs
System Info
Vite 7 + VPS 6 System: OS: macOS 15.7.5 CPU: (8) arm64 Apple M1 Memory: 117.78 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.14.1 - ~/.local/share/mise/installs/node/24.14.1/bin/node npm: 11.11.0 - ~/.local/share/mise/installs/node/24.14.1/bin/npm pnpm: 10.33.0 - ~/.local/share/mise/installs/pnpm/10.33.0/pnpm bun: 1.3.11 - ~/.local/share/mise/installs/bun/1.3.11/bin/bun Deno: 2.7.8 - ~/.local/share/mise/installs/deno/2.7.8/bin/deno Browsers: Chrome: 146.0.7680.165 Edge: 146.0.3856.72 Firefox: 149.0 Safari: 26.4 Safari Technology Preview: 26.0 npmPackages: @sveltejs/adapter-auto: ^7.0.0 => 7.0.1 @sveltejs/kit: ^2.50.2 => 2.55.0 @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4 svelte: ^5.54.0 => 5.55.0 vite: ^7.3.1 => 7.3.1 Vite 8 + VPS 7 System: OS: macOS 15.7.5 CPU: (8) arm64 Apple M1 Memory: 117.78 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.14.1 - ~/.local/share/mise/installs/node/24.14.1/bin/node npm: 11.11.0 - ~/.local/share/mise/installs/node/24.14.1/bin/npm pnpm: 10.33.0 - ~/.local/share/mise/installs/pnpm/10.33.0/pnpm bun: 1.3.11 - ~/.local/share/mise/installs/bun/1.3.11/bin/bun Deno: 2.7.8 - ~/.local/share/mise/installs/deno/2.7.8/bin/deno Browsers: Chrome: 146.0.7680.165 Edge: 146.0.3856.72 Firefox: 149.0 Safari: 26.4 Safari Technology Preview: 26.0 npmPackages: @sveltejs/adapter-auto: ^7.0.0 => 7.0.1 @sveltejs/kit: ^2.50.2 => 2.55.0 @sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0 svelte: ^5.54.0 => 5.55.0 vite: ^8.0.3 => 8.0.3Severity
annoyance
Additional Information
tl;dr add <svelte:options runes /> to svelte-5/error.svelte so we don't unnecessarily always ship legacy mode code path
Reactions are currently unavailable