{"record":{"id":"bf34793510a85b77","repo":"oven-sh/bun","slug":"bun-svelte-plugin-forceside-must-be-either-clien","errorCode":null,"errorMessage":"bun-svelte-plugin: forceSide must be either 'client' or 'server', got ${opts.forceSide}","messagePattern":"bun-svelte-plugin: forceSide must be either 'client' or 'server', got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bun-plugin-svelte/src/options.ts","lineNumber":47,"sourceCode":"}\n\n/**\n * @internal\n */\nexport function validateOptions(options: unknown): asserts options is SvelteOptions {\n  assert(options && typeof options === \"object\", new TypeError(\"bun-svelte-plugin: options must be an object\"));\n  const opts = options as Record<keyof SvelteOptions, unknown>;\n\n  if (opts.forceSide != null) {\n    if (typeof opts.forceSide !== \"string\") {\n      throw new TypeError(\"bun-svelte-plugin: forceSide must be a string, got \" + typeof opts.forceSide);\n    }\n    switch (opts.forceSide) {\n      case \"client\":\n      case \"server\":\n        break;\n      default:\n        throw new TypeError(`bun-svelte-plugin: forceSide must be either 'client' or 'server', got ${opts.forceSide}`);\n    }\n  }\n\n  if (opts.compilerOptions) {\n    if (typeof opts.compilerOptions !== \"object\") {\n      throw new TypeError(\"bun-svelte-plugin: compilerOptions must be an object\");\n    }\n  }\n}\n\n/**\n * @internal\n */\nexport function getBaseCompileOptions(pluginOptions: SvelteOptions, config: Partial<BuildConfig>): CompileOptions {\n  let {\n    development = false,\n    compilerOptions: { customElement, runes, modernAst, namespace } = kEmptyObject as OverrideCompileOptions,\n  } = pluginOptions;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/packages/bun-plugin-svelte/src/options.ts#L29-L65","documentation":"validateOptions() accepts forceSide only as exactly 'client' or 'server'. A correctly-typed string with any other value — 'both', 'ssr', 'hybrid', trailing spaces, wrong casing like 'Client' — fails the switch and throws this TypeError naming the offending value.","triggerScenarios":"Bun.svelte({ forceSide: 'both' }), forceSide: 'SSR', forceSide: 'client ' (trailing whitespace), or values read from env vars/config files without normalization.","commonSituations":"Users expecting a 'both'/'universal' mode that does not exist; env-derived values with casing or whitespace differences; copy-pasted options from other Svelte tooling (e.g. vite-plugin-svelte semantics).","solutions":["Use exactly 'client' or 'server'","Trim/lowercase values sourced from env vars or config before passing","Omit forceSide to use the plugin's automatic side detection"],"exampleFix":"// before\nBun.svelte({ forceSide: 'both' });\n\n// after\nBun.svelte({ forceSide: 'client' }); // or 'server'","handlingStrategy":"type-guard","validationCode":"const FORCE_SIDES = ['client', 'server'] as const;\nfunction normalizeForceSide(v: unknown): 'client' | 'server' | undefined {\n  if (typeof v !== 'string') return undefined;\n  const s = v.trim().toLowerCase();\n  return (FORCE_SIDES as readonly string[]).includes(s) ? (s as 'client' | 'server') : undefined;\n}","typeGuard":"const isValidForceSide = (v: unknown): v is 'client' | 'server' =>\n  v === 'client' || v === 'server';","tryCatchPattern":null,"preventionTips":["Use exactly 'client' or 'server'; the option is not a boolean and has no 'both'","Normalize env-derived values (trim + lowercase) before passing them in"],"tags":["svelte","plugin","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}