diff --git a/.changeset/healthy-walls-move.md b/.changeset/healthy-walls-move.md new file mode 100644 index 000000000000..a5ff8ab9bb54 --- /dev/null +++ b/.changeset/healthy-walls-move.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +add $app and $env to optimizeDeps.exclude so that libraries using these work correctly when prebundled diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 3c947f258e12..179104d8c19b 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -274,7 +274,13 @@ function kit() { external: ['@sveltejs/kit'] }, optimizeDeps: { - exclude: ['@sveltejs/kit'] + exclude: [ + '@sveltejs/kit', + // exclude kit features so that libraries using them work even when they are prebundled + // this does not affect app code, just handling of imported libraries that use $app or $env + '$app', + '$env' + ] } };