{"record":{"id":"4117db53ea0d026f","repo":"denoland/deno","slug":"failed-to-locate-output-for-html-entry-js-e","errorCode":null,"errorMessage":"failed to locate output for HTML entry '{}'; {js_entry_name}","messagePattern":"failed to locate output for HTML entry '(.+?)'; (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bundle/html.rs","lineNumber":509,"sourceCode":"    }\n\n    let entry_name = format!(\"{}{}\", self.entry_name, VIRTUAL_ENTRY_SUFFIX);\n    let js_entry_name = format!(\"{}.js\", entry_name);\n\n    let mut js_out_no_hash = None;\n    let js_out = html_output_files\n      .get_and_update_path(&js_entry_name, |p, f| {\n        let p = p.to_string_lossy();\n        js_out_no_hash = Some(\n          p.replace(entry_name.as_str(), &original_entry_name)\n            .replace(&format!(\"-{}\", f.hash), \"\")\n            .into(),\n        );\n\n        p.replace(entry_name.as_str(), &original_entry_name).into()\n      })\n      .ok_or_else(|| {\n        anyhow::anyhow!(\n          \"failed to locate output for HTML entry '{}'; {js_entry_name}\",\n          self.entry_name\n        )\n      })?;\n    let html_out_path = js_out_no_hash\n      .unwrap_or_else(|| js_out.clone())\n      .with_extension(\"html\");\n\n    // esbuild emits the external/linked sourcemap (`*.js.map`) for the entry\n    // under the internal virtual-entry name. Rename it to match the renamed JS\n    // bundle (e.g. `index-HASH.js.map`) and fix the JS `sourceMappingURL`\n    // reference so the emitted output doesn't leak the `deno-bundle-html.entry`\n    // implementation detail. See denoland/deno#30750.\n    let map_entry_name = format!(\"{}.js.map\", entry_name);\n    let mut old_map_name = None;\n    let new_map_out =\n      html_output_files.get_and_update_path(&map_entry_name, |p, _| {\n        old_map_name = p","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/bundle/html.rs#L491-L527","documentation":"During `deno bundle` of an HTML entrypoint, Deno looks up the JavaScript output esbuild produced for the page's script entry by its internal entry name. If no output file matches, this error fires: the HTML pipeline needs that JS output to rewrite the `<script>` tag and hash-rename files, so it cannot proceed.","triggerScenarios":"Bundling an HTML page where esbuild emitted no matching JS entry output — the referenced script module is empty or fully externalized, output naming was altered, or the response shape changed between esbuild versions.","commonSituations":"An HTML page whose script points at an empty module or one with no local code; stale hashed outputs in the outdir from a previous run; mixing `--output` with HTML entrypoints.","solutions":["Make sure the HTML references at least one real, non-empty local script module","Use only `--outdir` with HTML entrypoints (drop `--output`)","Clear the outdir and re-run to rule out stale hashed outputs colliding with the lookup","If it persists with a plain page, file a deno issue with the HTML and exact command — this is an internal invariant"],"exampleFix":"<!-- before: empty script module -->\n<script type=\"module\" src=\"./empty.js\"></script>\n\n<!-- after: script with actual local code -->\n<script type=\"module\" src=\"./main.js\"></script>","handlingStrategy":"validation","validationCode":"// Before bundling, verify every script entry referenced by the HTML is a non-empty local file\nconst html = await Deno.readTextFile(\"index.html\");\nfor (const m of html.matchAll(/<script[^>]+src=\"([^\"]+)\"/g)) {\n  const url = new URL(m[1], import.meta.resolve(\"./index.html\"));\n  if (url.protocol !== \"file:\") throw new Error(`script ${m[1]} is not local`);\n  const stat = await Deno.stat(url);\n  if (stat.size === 0) throw new Error(`script ${m[1]} is empty`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep at least one non-empty local script per HTML entrypoint","Bundle HTML with only --outdir, never --output","Rebuild into a clean outdir to avoid stale hashed outputs"],"tags":["bundle","html","esbuild"],"backgroundTag":"bundler-output-missing","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}