{"record":{"id":"6cebfd8a3a322545","repo":"oven-sh/bun","slug":"bun-svelte-plugin-compileroptions-must-be-an-obje","errorCode":null,"errorMessage":"bun-svelte-plugin: compilerOptions must be an object","messagePattern":"bun-svelte-plugin: compilerOptions must be an object","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bun-plugin-svelte/src/options.ts","lineNumber":53,"sourceCode":"  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;\n  const { minify = false } = config;\n\n  const shouldMinify = Boolean(minify);\n  const {\n    whitespace: minifyWhitespace,\n    syntax: _minifySyntax,","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/packages/bun-plugin-svelte/src/options.ts#L35-L71","documentation":"validateOptions() requires compilerOptions, when provided, to be an object — the Svelte compiler options bag (customElement, runes, modernAst, namespace, ...). Passing a string, array, number, or other non-object type throws this TypeError at plugin configuration time.","triggerScenarios":"Bun.svelte({ compilerOptions: 'svelte' }), compilerOptions: ['runes'], or options spread from a flat config where compilerOptions was never nested (e.g. putting runes: true at the top level and misassigning the result).","commonSituations":"Confusing the plugin's own options with the Svelte compiler options; passing a JSON-parsed value that is a string; migrating configs from vite-plugin-svelte with different nesting.","solutions":["Pass compilerOptions as an object: Bun.svelte({ compilerOptions: { runes: true } })","Leave it out to use the defaults derived by getBaseCompileOptions()","Keep values that are compiler flags (runes, customElement, ...) nested inside compilerOptions, not at the top level"],"exampleFix":"// before\nBun.svelte({ compilerOptions: 'svelte' });\n\n// after\nBun.svelte({ compilerOptions: { runes: true } });","handlingStrategy":"type-guard","validationCode":"if (opts.compilerOptions != null && typeof opts.compilerOptions !== 'object') {\n  throw new TypeError('compilerOptions must be an object');\n}","typeGuard":"const isCompilerOptions = (v: unknown): v is BunSveltePlugin.OverrideCompileOptions =>\n  !!v && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["Nest compiler flags inside compilerOptions, never at the top level","Keep the config object typed as SvelteOptions end-to-end","Reject arrays/strings early when reading options from untyped sources"],"tags":["svelte","plugin","typescript","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}