diff --git a/frontend/sharedUtils/vite.sharedUtils.config.js b/frontend/sharedUtils/vite.sharedUtils.config.js index 98410f737d..4787a60f69 100644 --- a/frontend/sharedUtils/vite.sharedUtils.config.js +++ b/frontend/sharedUtils/vite.sharedUtils.config.js @@ -1,11 +1,12 @@ import { defineConfig } from 'vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' import { resolve } from 'path' import { writeFileSync } from 'fs' import { exec } from 'child_process' import { promisify } from 'util' const execAsync = promisify(exec) -const VERSION = '1.0.12' +const VERSION = '1.0.13' export default defineConfig({ build: { @@ -24,6 +25,7 @@ export default defineConfig({ } }, plugins: [ + svelte(), { name: 'bundle-types', async closeBundle() { diff --git a/frontend/src/lib/svelte5Utils.svelte.ts b/frontend/src/lib/svelte5Utils.svelte.ts index d688ec1502..598fc85206 100644 --- a/frontend/src/lib/svelte5Utils.svelte.ts +++ b/frontend/src/lib/svelte5Utils.svelte.ts @@ -18,8 +18,12 @@ export function createState(initialValue: T): T { return s } -export function stateSnapshot(state: T) { - return $state.snapshot(state) +// Annotated: the inferred `Snapshot` is a deep conditional type TS refuses to +// serialize into a declaration file (TS7056), which breaks the shared-utils build. +// `Snapshot` is not exported from the `$state` namespace, and it only differs +// from `T` for Date/Map/Set, which no caller snapshots. +export function stateSnapshot(state: T): T { + return $state.snapshot(state) as T } export function refreshStateStore(store: StateStore): void { store.val = $state.snapshot(store.val) as any