From ec31cf35b2619562c7a3b19b0dbf661ed8238ed1 Mon Sep 17 00:00:00 2001 From: Steve Martocci Date: Wed, 25 Mar 2026 13:43:48 -0700 Subject: [PATCH] fix: avoid bundling svelte compiler in client apps Use the runtime svelte VERSION export for analytics techVersion instead of importing from svelte/compiler, which prevents pulling compiler code into consumer bundles. Made-with: Cursor --- packages/svelte-cloudinary/src/config.ts | 5 +++-- packages/svelte-cloudinary/tests/config.test.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/svelte-cloudinary/src/config.ts b/packages/svelte-cloudinary/src/config.ts index 924957c0..e2ab128a 100644 --- a/packages/svelte-cloudinary/src/config.ts +++ b/packages/svelte-cloudinary/src/config.ts @@ -1,5 +1,5 @@ import { VERSION as SVELTE_CLOUDINARY_VERSION } from './version'; -import { VERSION as SVELTE_VERSION } from 'svelte/compiler'; +import { VERSION as SVELTE_VERSION } from 'svelte'; import { setContext, getContext } from 'svelte'; import { klona } from './internal/klona'; import { defu } from 'defu'; @@ -10,7 +10,8 @@ import type { const STORE_KEY = 'svelte-cloudinary-v2-config'; -function normaliseVersion(version: string) { +function normaliseVersion(version?: string) { + if (!version) return '0.0.0'; return version.includes('-') ? version.split('-')[0] : version; } diff --git a/packages/svelte-cloudinary/tests/config.test.ts b/packages/svelte-cloudinary/tests/config.test.ts index 4fb5202a..ee0554a0 100644 --- a/packages/svelte-cloudinary/tests/config.test.ts +++ b/packages/svelte-cloudinary/tests/config.test.ts @@ -13,6 +13,7 @@ vi.mock('svelte', () => { const context = new Map(); return { + VERSION: '5.0.0-next.1', getContext(key: string) { return context.get(key); },