{"record":{"id":"9928d4614dbc9e69","repo":"oven-sh/bun","slug":"slicesourcecode-truncated-modulelist-i-likel","errorCode":null,"errorMessage":"sliceSourceCode truncated ${moduleList[i]} — likely a regex literal in a position builtin-parser.ts doesn't recognise. Leftover starts: ${processed.rest.slice(0, 80)}","messagePattern":"sliceSourceCode truncated (.+?) — likely a regex literal in a position builtin-parser\\.ts doesn't recognise\\. Leftover starts: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bundle-modules.ts","lineNumber":148,"sourceCode":"    }\n    let importStatements: string[] = [];\n\n    const processed = sliceSourceCode(\n      \"{\" +\n        input\n          .replace(\n            /\\bimport(\\s*type)?\\s*(\\{[^}]*\\}|(\\*\\s*as)?\\s[a-zA-Z0-9_$]+)\\s*from\\s*['\"][^'\"]+['\"]/g,\n            stmt => (importStatements.push(stmt), \"\"),\n          )\n          .replace(/export\\s*{\\s*}\\s*;/g, \"\"),\n      true,\n      x => requireTransformer(x, moduleList[i]),\n    );\n    // Guard rail: builtin-parser.ts's regex-position heuristic only recognises\n    // `/` as regex-start after `[(,=;:{]|return|=>`; a regex whose body has `)`\n    // or `}` in any other position silently truncates. Fail loudly here.\n    if (processed.rest.trim() !== \"\") {\n      throw new Error(\n        `sliceSourceCode truncated ${moduleList[i]} — likely a regex literal in a position builtin-parser.ts doesn't recognise. ` +\n          `Leftover starts: ${processed.rest.slice(0, 80)}`,\n      );\n    }\n    let fileToTranspile = `// GENERATED TEMP FILE - DO NOT EDIT\n// Sourced from src/js/${moduleList[i]}\n${importStatements.join(\"\\n\")}\n\n${processed.result.slice(1).trim()}\n;$$EXPORT$$(__intrinsic__exports).$$EXPORT_END$$;\n`;\n\n    // Attempt to optimize \"$exports = ...\" to a variableless return\n    // otherwise, declare $exports so it works.\n    let exportOptimization = false;\n    fileToTranspile = fileToTranspile.replace(\n      /__intrinsic__exports\\s*=\\s*(.*|.*\\{[^\\}]*}|.*\\([^\\)]*\\))\\n+\\s*\\$\\$EXPORT\\$\\$\\(__intrinsic__exports\\).\\$\\$EXPORT_END\\$\\$;/,\n      (_, a) => {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bundle-modules.ts#L130-L166","documentation":"Error \"sliceSourceCode truncated ${moduleList[i]} — likely a regex literal in a position builtin-parser.ts doesn't recognise. Leftover starts: ${processed.rest.slice(0, 80)}\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bundle-modules.ts:148 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}