{"record":{"id":"2cc65e0932c9d5f0","repo":"denoland/deno","slug":"outdir-is-required-when-bundling-html-entrypoint","errorCode":null,"errorMessage":"--outdir is required when bundling HTML entrypoints","messagePattern":"--outdir is required when bundling HTML entrypoints","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bundle/mod.rs","lineNumber":148,"sourceCode":"      init_cwd,\n      npm_resolver,\n      node_resolver,\n    );\n    plugin_handler.prepare_module_load(&roots).await?;\n    let graph = plugin_handler.module_graph_container.graph();\n    let mut fully_resolved_roots = IndexSet::with_capacity(graph.roots.len());\n    for root in &graph.roots {\n      fully_resolved_roots.insert(graph.resolve(root).clone());\n    }\n    *plugin_handler.resolved_roots.write() = Arc::new(fully_resolved_roots);\n\n    Ok(BundlerInput::Entrypoints(\n      roots.into_iter().map(|e| (\"\".into(), e.into())).collect(),\n    ))\n  } else {\n    // require an outdir when any HTML is present\n    if bundle_flags.output_dir.is_none() {\n      return Err(deno_core::anyhow::anyhow!(\n        \"--outdir is required when bundling HTML entrypoints\",\n      ));\n    }\n    if bundle_flags.output_path.is_some() {\n      return Err(deno_core::anyhow::anyhow!(\n        \"--output is not supported with HTML entrypoints; use --outdir\",\n      ));\n    }\n\n    // Prepare HTML pages and temp entry modules\n    let mut html_pages = Vec::new();\n    let mut to_cache_urls = Vec::new();\n    let mut entries: Vec<(String, String)> = Vec::new();\n    let virtual_modules = Arc::new(VirtualModules::new());\n\n    for html_path in &html_paths {\n      let entry = html::load_html_entrypoint(\n        init_cwd,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/bundle/mod.rs#L130-L166","documentation":"`deno bundle` refuses to bundle HTML entrypoints without `--outdir`. An HTML bundle produces several files (hash-renamed JS, sourcemaps, patched HTML), so stdout output or a single-file target is impossible; the command fails up-front with this message.","triggerScenarios":"Running `deno bundle page.html` (any invocation whose entrypoints include an HTML file) without an `--outdir` flag.","commonSituations":"Habit from JS bundling where `deno bundle mod.ts` prints to stdout; CI scripts and npm-style tasks that call `deno bundle` without an output directory.","solutions":["Pass an output directory: `deno bundle --outdir=dist index.html`","If you wanted a single-file JS bundle, point the command at the script module (e.g. `src/main.ts`) instead of the HTML file"],"exampleFix":"# before\ndeno bundle index.html\n\n# after\ndeno bundle --outdir=dist index.html","handlingStrategy":"validation","validationCode":"// Wrapper: require --outdir when any entry ends with .html\nconst entries = Deno.args.filter((a) => !a.startsWith(\"-\"));\nif (\n  entries.some((e) => e.endsWith(\".html\")) &&\n  !Deno.args.some((a) => a.startsWith(\"--outdir\"))\n) {\n  throw new Error(\"HTML entrypoints require --outdir\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair HTML entries with --outdir","Define bundle commands as deno.json tasks so flags are encoded once","Treat stdout-bundle habits as JS-only"],"tags":["bundle","html","cli-flags"],"backgroundTag":"missing-required-flag","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"}