{"record":{"id":"b1c8b68a02a5ea04","repo":"rolldown/rolldown","slug":"expected-the-standalone-runtime-to-start-with-a-he","errorCode":null,"errorMessage":"Expected the standalone runtime to start with a helper import","messagePattern":"Expected the standalone runtime to start with a helper import","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/rolldown/src/utils/default-dev-runtime.ts","lineNumber":18,"sourceCode":"import fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\n// defined in the build step\ndeclare const __RUNTIME_STRING__: string | undefined;\n\n// The public entry's generated first line imports helpers for standalone ESM use. Remove it before\n// appending the source to Rolldown's internal runtime module, where those helpers are already in\n// scope.\nexport function getDefaultDevRuntime(host = 'localhost', port = 3000): string {\n  if (typeof __RUNTIME_STRING__ !== 'undefined') {\n    return __RUNTIME_STRING__.replaceAll('$ADDR', `${host}:${port}`);\n  }\n\n  const runtimeEntry = fs.readFileSync(fileURLToPath(import.meta.resolve('#runtime')), 'utf8');\n  const runtimeHelperImportEnd = runtimeEntry.indexOf('\\n');\n  if (!runtimeEntry.startsWith('import ') || runtimeHelperImportEnd === -1) {\n    throw new Error('Expected the standalone runtime to start with a helper import');\n  }\n  const runtime = runtimeEntry.slice(runtimeHelperImportEnd + 1);\n  const defaultRuntime = fs.readFileSync(\n    fileURLToPath(import.meta.resolve('#default-runtime')),\n    'utf8',\n  );\n  return `${runtime}\\n${defaultRuntime.replaceAll('$ADDR', `${host}:${port}`)}`;\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/rolldown/rolldown/blob/91b44b9d7bcfb5725533478e044e3891a251b2c5/packages/rolldown/src/utils/default-dev-runtime.ts#L1-L27","documentation":"Build-time invariant in getDefaultDevRuntime: when assembling the dev runtime source, the code strips the public entry's generated first line (a helper import for standalone ESM use) before appending to the internal runtime module. If that first line is not the expected helper import, the assumption about the generated runtime entry is violated and the error is thrown. The input at fault is the generated runtime entry file's first line.","triggerScenarios":"Thrown at packages/rolldown/src/utils/default-dev-runtime.ts:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild the runtime entry (the build step that generates `__RUNTIME_STRING__` / the public entry) so its first line is the expected helper import","If the runtime entry format changed intentionally, update the first-line check and stripping logic together"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"91b44b9d7bcfb5725533478e044e3891a251b2c5","analyzedAt":"2026-09-07T16:04:13.504Z","contentChangedAt":"2026-09-07T16:04:13.504Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}