Skip to content

Commit e9b06c8

Browse files
teemingcbenmccannvercel[bot]
authored
fix: avoid unknown config option Vite warning (#15451)
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
1 parent 355e797 commit e9b06c8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/lazy-shirts-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: avoid Vite warning about unknown `codeSplitting` option

packages/kit/src/exports/vite/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,7 @@ async function kit({ svelte_config }) {
932932
assetFileNames: `${prefix}/assets/[name].[hash][extname]`,
933933
hoistTransitiveImports: false,
934934
sourcemapIgnoreList,
935-
inlineDynamicImports: is_rolldown ? undefined : !split,
936-
// @ts-ignore: only available in Vite 8
937-
codeSplitting: is_rolldown ? split : undefined
935+
inlineDynamicImports: is_rolldown ? undefined : !split
938936
},
939937
preserveEntrySignatures: 'strict',
940938
onwarn(warning, handler) {
@@ -967,6 +965,13 @@ async function kit({ svelte_config }) {
967965
}
968966
}
969967
};
968+
969+
// we must reference Vite 8 options conditionally. Otherwise, older Vite
970+
// versions throw an error about unknown config options
971+
if (is_rolldown && new_config?.build?.rollupOptions?.output) {
972+
// @ts-ignore only available in Vite 8
973+
new_config.build.rollupOptions.output.codeSplitting = split;
974+
}
970975
} else {
971976
new_config = {
972977
appType: 'custom',

0 commit comments

Comments
 (0)