Skip to content

Commit a1ae9c0

Browse files
authored
fix: no longer read kit.browser.hydrate to initialize compilerOptions.hydratable (#496)
1 parent be3d46d commit a1ae9c0

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

.changeset/flat-shrimps-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
simplify init of compilerOptions.hydratable for kit (kit.browser.hydrate is no longer in use)

packages/vite-plugin-svelte/src/utils/options.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,9 @@ function removeIgnoredOptions(options: ResolvedOptions) {
286286
// some SvelteKit options need compilerOptions to work, so set them here.
287287
function addSvelteKitOptions(options: ResolvedOptions) {
288288
// @ts-expect-error kit is not typed to avoid dependency on sveltekit
289-
if (options?.kit != null) {
290-
// @ts-expect-error kit is not typed to avoid dependency on sveltekit
291-
const kit_browser_hydrate = options.kit.browser?.hydrate;
292-
const hydratable = kit_browser_hydrate !== false;
293-
if (
294-
options.compilerOptions.hydratable != null &&
295-
options.compilerOptions.hydratable !== hydratable
296-
) {
297-
log.warn(
298-
`Conflicting values "compilerOptions.hydratable: ${options.compilerOptions.hydratable}" and "kit.browser.hydrate: ${kit_browser_hydrate}" in your svelte config. You should remove "compilerOptions.hydratable".`
299-
);
300-
}
301-
log.debug(`Setting compilerOptions.hydratable: ${hydratable} for SvelteKit`);
302-
options.compilerOptions.hydratable = hydratable;
289+
if (options?.kit != null && options.compilerOptions.hydratable == null) {
290+
log.debug(`Setting compilerOptions.hydratable = true for SvelteKit`);
291+
options.compilerOptions.hydratable = true;
303292
}
304293
}
305294

0 commit comments

Comments
 (0)