{"record":{"id":"69aa295dd8cc393d","repo":"oven-sh/bun","slug":"input-missing-default-export","errorCode":null,"errorMessage":"${input}: missing default export","messagePattern":"(.+?): missing default export","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/generate-string-map.ts","lineNumber":293,"sourceCode":"  // No `#![allow]` — this is `include!`d, and inner attributes aren't legal\n  // mid-module. Per-item allows are emitted where needed instead.\n  return [\n    `// Generated by src/codegen/generate-string-map.ts from ${rel} — do not edit.`,\n    ``,\n    ...arr.map(s => buildOne(s)),\n    ``,\n  ].join(\"\\n\\n\");\n}\n\n// ── CLI ─────────────────────────────────────────────────────────────────────\nif (import.meta.main) {\n  const [, , input, output] = process.argv;\n  if (!input || !output) {\n    throw new Error(\"usage: bun src/codegen/generate-string-map.ts <input.string-map.ts> <out.rs>\");\n  }\n  const mod = await import(path.resolve(input));\n  const specs = mod.default as StringMapSpec<unknown> | StringMapSpec<unknown>[];\n  if (!specs) throw new Error(`${input}: missing default export`);\n  writeIfNotChanged(output, generateStringMaps(specs, input));\n}\n","sourceCodeStart":275,"sourceCodeEnd":296,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/generate-string-map.ts#L275-L296","documentation":"After dynamically importing the input file, the generator reads `mod.default` and expects either a single StringMapSpec object or an array of them. A falsy default export (or none at all) cannot be generated from, so it aborts with the input path in the message.","triggerScenarios":"The input .string-map.ts exports its spec via a named export (`export const spec = ...`), exports `undefined` conditionally, or is an empty file.","commonSituations":"Converting an existing spec module to named exports; refactoring so the default export is behind a flag that evaluates falsy.","solutions":["Add `export default` to the spec object or array in the input file.","If the module intentionally has multiple named specs, default-export them as an array."],"exampleFix":"// before\nexport const spec = { name: \"Map\", entries: [] };\n\n// after\nconst spec = { name: \"Map\", entries: [] };\nexport default spec;","handlingStrategy":"type-guard","validationCode":"const mod = await import(path.resolve(input));\nif (!mod.default) throw new Error(`${input}: missing default export`);","typeGuard":"function isStringMapSpec(v: unknown): v is StringMapSpec<unknown> {\n  return (\n    typeof v === \"object\" && v !== null &&\n    typeof (v as any).name === \"string\" &&\n    Array.isArray((v as any).entries)\n  );\n}\nconst specs = Array.isArray(mod.default) ? mod.default : [mod.default];\nif (!specs.every(isStringMapSpec)) throw new Error(`${input}: bad default export shape`);","tryCatchPattern":null,"preventionTips":["Standardize every .string-map.ts on `export default { ... } satisfies StringMapSpec<T>`.","Type the spec file against the generator's exported interface so tsc catches shape mistakes before codegen runs."],"tags":["codegen","string-map","es-modules","default-export"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}