diff --git a/.changeset/thin-suns-fail.md b/.changeset/thin-suns-fail.md new file mode 100644 index 000000000000..c497dd93546c --- /dev/null +++ b/.changeset/thin-suns-fail.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: correctly resolve `$app/state` on the server with Vite 5 diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 2c76a71f0026..0addaadc7fa3 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -306,7 +306,13 @@ async function kit({ svelte_config }) { // See https://github.com/sveltejs/kit/pull/9172 // and https://vitest.dev/config/#deps-registernodeloader '@sveltejs/kit' - ] + ], + resolve: { + // We need this so that importing $app/state correctly + // resolves to the default conditional export instead of + // the browser condition on the server. + conditions: ['module', 'node'] + } } };