{"record":{"id":"a20ec3e535f5278d","repo":"denoland/deno","slug":"bundling-failed","errorCode":null,"errorMessage":"bundling failed","messagePattern":"bundling failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bundle/mod.rs","lineNumber":374,"sourceCode":"      )\n      .await?;\n  }\n  let bundler = bundle_init(flags.clone(), &bundle_flags, None).await?;\n  let init_cwd = bundler.cwd.clone();\n  let start = std::time::Instant::now();\n  let response = bundler.build().await?;\n  let end = std::time::Instant::now();\n  let duration = end.duration_since(start);\n\n  if bundle_flags.watch {\n    if !response.errors.is_empty() || !response.warnings.is_empty() {\n      handle_esbuild_errors_and_warnings(\n        &response,\n        &init_cwd,\n        &bundler.plugin_handler.take_deferred_resolve_errors(),\n      );\n      if !response.errors.is_empty() {\n        deno_core::anyhow::bail!(\"bundling failed\");\n      }\n    }\n    return bundle_watch(\n      flags,\n      bundler,\n      bundle_flags.minify,\n      bundle_flags.platform,\n      bundle_flags.output_dir.as_ref().map(Path::new),\n    )\n    .await;\n  }\n\n  handle_esbuild_errors_and_warnings(\n    &response,\n    &init_cwd,\n    &bundler.plugin_handler.take_deferred_resolve_errors(),\n  );\n","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/bundle/mod.rs#L356-L392","documentation":"Watch-mode bundling: esbuild returned a BuildResponse containing errors. handle_esbuild_errors_and_warnings prints them (with file:line:col) first, then the run bails with this generic message to force a non-zero exit (cli/tools/bundle/mod.rs:366-375) instead of entering the watch loop on a broken graph.","triggerScenarios":"deno bundle --watch with a syntax error, an unresolvable import, or a plugin onResolve failure in the entry graph; a file edit that temporarily breaks the graph (half-saved file); missing npm/jsr dependency not yet installed.","commonSituations":"Editor autosave writing mid-edit buffers during watch; importing a file with a missing ./extension (Deno requires explicit extensions); deleting/renaming a module that the entry imports while watching.","solutions":["Read the esbuild diagnostics printed immediately above - they carry the exact file, line, and column of the first error","Fix imports first: use explicit extensions (./util.ts not ./util), and run deno install if an npm:/jsr: dependency is missing","Verify the project type-checks/compiles once outside watch mode (deno check <entry>, deno bundle <entry>) before restarting watch","If errors come from half-written files on save, configure the editor to write atomically or debounce saves"],"exampleFix":"// before: extensionless import trips esbuild resolution under watch\nimport { helper } from './util';\n// after\nimport { helper } from './util.ts';","handlingStrategy":"try-catch","validationCode":"# Gate the watch session on a clean one-shot bundle first\ndeno bundle --outdir /tmp/gate src/main.ts || { echo 'fix bundle errors before watching'; exit 1; }\ndeno bundle --watch --outdir dist src/main.ts","typeGuard":null,"tryCatchPattern":"# Wrapper: surface the real esbuild diagnostics when watch aborts\nlog=$(mktemp)\ndeno bundle --watch --outdir dist src/main.ts 2>&1 | tee \"$log\" || {\n  echo '--- watch exited; first error: ---'\n  grep -m1 -A3 'ERROR' \"$log\"\n}","preventionTips":["Use explicit .ts/.js extensions on relative imports","Run deno install before watch sessions on fresh checkouts","Configure editors to write files atomically/debounced so half-saved buffers don't break the graph"],"tags":["bundle","esbuild","watch-mode","diagnostics"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}