From c1b4f8179a6dec8b76a613f7a015ce5e4d5b27e0 Mon Sep 17 00:00:00 2001 From: Dominik G Date: Mon, 5 Dec 2022 10:44:48 +0100 Subject: [PATCH] [fix] add $app and $env to optimizeDeps.exclude to allow prebundling for libraries using them (#7933) --- .changeset/healthy-walls-move.md | 5 +++++ packages/kit/src/exports/vite/index.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/healthy-walls-move.md 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' + ] } };