Skip to content

Commit abf9f3a

Browse files
authored
[fix] ensure export conditions are resolve through Vite (sveltejs#8092)
Fixes sveltejs#8082
1 parent a5d1825 commit abf9f3a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/lucky-apples-breathe.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] ensure export conditions are resolve through Vite

packages/kit/src/exports/vite/build/utils.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,16 @@ export function get_build_setup_config({ config, ssr }) {
138138
exclude: ['@sveltejs/kit']
139139
},
140140
ssr: {
141-
noExternal: ['@sveltejs/kit']
141+
noExternal: [
142+
// TODO document why this is necessary
143+
'@sveltejs/kit',
144+
// This ensures that esm-env is inlined into the server output with the
145+
// export conditions resolved correctly through Vite. This prevents adapters
146+
// that bundle later on to resolve the export conditions incorrectly
147+
// and for example include browser-only code in the server output
148+
// because they for example use esbuild.build with `platform: 'browser'`
149+
'esm-env'
150+
]
142151
},
143152
worker: {
144153
rollupOptions: {

0 commit comments

Comments
 (0)