{"record":{"id":"0ac197dcd4fea7d2","repo":"windmill-labs/windmill","slug":"build-failed-with-errors","errorCode":null,"errorMessage":"Build failed with errors","messagePattern":"Build failed with errors","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/app/bundle.ts","lineNumber":446,"sourceCode":"    // read anyway. Native esbuild supports write:false + outputFiles too.\n    write: false as const,\n    define: {\n      \"process.env.NODE_ENV\": production ? '\"production\"' : '\"development\"',\n    },\n    plugins: [...frameworkPlugins, wmillPlugin, ...sharedUiPlugins],\n  };\n\n  log.info(colors.blue(\"📦 Building bundle...\"));\n\n  try {\n    const result = await esbuild.build(buildOptions);\n\n    if (result.errors.length > 0) {\n      log.error(colors.red(\"❌ Build failed:\"));\n      result.errors.forEach((error: any) => {\n        log.error(colors.red(error.text));\n      });\n      throw new Error(\"Build failed with errors\");\n    }\n\n    log.info(colors.green(\"✅ Bundle created successfully\"));\n\n    const outputFiles = result.outputFiles ?? [];\n    const jsFile = outputFiles.find((f) => f.path.endsWith(\".js\"));\n    const cssFile = outputFiles.find((f) => f.path.endsWith(\".css\"));\n\n    if (!jsFile) {\n      throw new Error(\"Expected a JS bundle in esbuild output but none found\");\n    }\n\n    try {\n      fs.rmSync(distDir, { recursive: true });\n    } catch {\n      //ignore\n    }\n    return { js: jsFile.text, css: cssFile?.text ?? \"\" };","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/app/bundle.ts#L428-L464","documentation":"Post-build guard in createBundle: esbuild returned from build() without throwing, but result.errors is non-empty — esbuild reports some errors (e.g. unresolved imports, syntax errors in imported files) through the result object rather than as a thrown exception. Each error's text is logged to the console before this Error is thrown, so the terminal already shows the specific esbuild diagnostics; this throw converts the soft-failure into a hard stop so no half-built bundle is used.","triggerScenarios":"Thrown at cli/src/commands/app/bundle.ts:446 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Scroll up to the '❌ Build failed:' block — each printed line is one esbuild error.text; fix those source/typing issues and re-bundle","For unresolved imports, ensure dependencies are in package.json and node_modules exists (the bundler can run npm install via ensureNodeModules)","For JSX/TS syntax errors, check the entry file extension matches the framework (tsx for React, ts for Svelte)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}