diff --git a/.changeset/flat-eggs-start.md b/.changeset/flat-eggs-start.md new file mode 100644 index 000000000000..8910073f66ae --- /dev/null +++ b/.changeset/flat-eggs-start.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: force `$app/*` modules to be bundled diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 4b332a6de07c..934a2beaa045 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -297,7 +297,12 @@ async function kit({ svelte_config }) { // that bundle later on from resolving the export conditions incorrectly // and for example include browser-only code in the server output // because they for example use esbuild.build with `platform: 'browser'` - 'esm-env' + 'esm-env', + // This forces `$app/*` modules to be bundled, since they depend on + // virtual modules like `__sveltekit/paths` (this isn't a valid bare + // import, but it works with vite-node's externalization logic, which + // uses basic concatenation) + '@sveltejs/kit/src/runtime' ] } };