{"id":"9c54ef6e45e56b9b","repo":"vitejs/vite","slug":"runtime-result-runtime-is-not-supported-9c54ef","errorCode":null,"errorMessage":"{ runtime: \"${result.runtime}\" } is not supported for assets in ${hostType} files: ${filename}","messagePattern":"(.+?) is not supported for assets in (.+?) files: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/build.ts","lineNumber":1715,"sourceCode":"  filename: string,\n  type: 'asset' | 'public',\n  hostId: string,\n  hostType: 'js' | 'css' | 'html',\n  config: ResolvedConfig,\n  toRelative: (filename: string, hostId: string) => string,\n): string {\n  const { renderBuiltUrl } = config.experimental\n  let relative = config.base === '' || config.base === './'\n  if (renderBuiltUrl) {\n    const result = renderBuiltUrl(filename, {\n      hostId,\n      hostType,\n      type,\n      ssr: !!config.build.ssr,\n    })\n    if (typeof result === 'object') {\n      if (result.runtime) {\n        throw new Error(\n          `{ runtime: \"${result.runtime}\" } is not supported for assets in ${hostType} files: ${filename}`,\n        )\n      }\n      if (typeof result.relative === 'boolean') {\n        relative = result.relative\n      }\n    } else if (result) {\n      return result\n    }\n  }\n  if (relative && !config.build.ssr) {\n    return toRelative(filename, hostId)\n  } else {\n    return joinUrlSegments(config.decodedBase, filename)\n  }\n}\n\nexport const toOutputFilePathInCss: typeof toOutputFilePathWithoutRuntime =","sourceCodeStart":1697,"sourceCodeEnd":1733,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/build.ts#L1697-L1733","documentation":"In toOutputFilePathWithoutRuntime (build.ts:1707-1717), when the experimental.renderBuiltUrl hook returns an object containing a runtime property for an asset, Vite throws. Runtime-lazy URL resolution ({ runtime }) is only meaningful for JS module imports, not for assets referenced inside CSS/HTML/JS host files at build time, so it is rejected for assets.","triggerScenarios":"Implementing experimental.renderBuiltUrl and returning { runtime: '...' } for a file whose type is 'asset' (i.e. for an asset URL computed while rendering a js/css/html host file).","commonSituations":"Customizing built asset URLs via renderBuiltUrl and accidentally returning a runtime value for static assets; copying a runtime pattern valid for JS imports into asset handling.","solutions":["For assets, return a plain string URL or an object with only { relative } — never { runtime }.","Restrict { runtime } returns to non-asset (JS import) contexts by checking the type argument.","If you need runtime resolution, handle it in client code rather than via renderBuiltUrl for assets."],"exampleFix":"// before\nrenderBuiltUrl(filename, { type, hostType }) {\n  return { runtime: `import.meta.env.BASE_URL + '${filename}'` } // throws for assets\n}\n// after\nrenderBuiltUrl(filename, { type }) {\n  if (type === 'asset') return `/assets/${filename}` // string only\n  return { runtime: `import.meta.env.BASE_URL + '${filename}'` }\n}","handlingStrategy":"type-guard","validationCode":"experimental: {\n  renderBuiltUrl(filename, { type }) {\n    if (type === 'asset') return undefined // let Vite default\n    return undefined\n  }\n}","typeGuard":"function isSafeAssetResult(result: unknown): boolean {\n  return !(typeof result === 'object' && result !== null && 'runtime' in result)\n}","tryCatchPattern":null,"preventionTips":["In renderBuiltUrl, branch on the type argument and never return { runtime } for assets.","Return a string or { relative } for asset URLs.","Unit-test the hook against an asset input before enabling in build."],"tags":["build","assets","render-built-url","experimental"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}