{"record":{"id":"b8b2678c296a68eb","repo":"gohugoio/hugo","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/build.go","lineNumber":109,"sourceCode":"\n\t\t\tif m == nil {\n\t\t\t\treturn api.BuildResult{}, fmt.Errorf(\"inject: file %q not found\", ext)\n\t\t\t}\n\n\t\t\topts.Inject[i] = m.Filename\n\n\t\t}\n\n\t\topts.compiled.Inject = opts.Inject\n\n\t}\n\n\tresult := api.Build(opts.compiled)\n\n\tif len(result.Errors) > 0 {\n\t\tcreateErr := func(msg api.Message) error {\n\t\t\tif msg.Location == nil {\n\t\t\t\treturn errors.New(msg.Text)\n\t\t\t}\n\t\t\tvar (\n\t\t\t\tcontentr     hugio.ReadSeekCloser\n\t\t\t\terrorMessage string\n\t\t\t\tloc          = msg.Location\n\t\t\t\terrorPath    = loc.File\n\t\t\t\terr          error\n\t\t\t)\n\n\t\t\tvar resolvedError *ErrorMessageResolved\n\n\t\t\tif opts.ErrorMessageResolveFunc != nil {\n\t\t\t\tresolvedError = opts.ErrorMessageResolveFunc(msg)\n\t\t\t}\n\n\t\t\tif resolvedError == nil {\n\t\t\t\tif errorPath == stdinImporter {\n\t\t\t\t\terrorPath = opts.StdinSourcePath","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/js/esbuild/build.go#L91-L127","documentation":"Returned by the esbuild Build wrapper in internal/js/esbuild/build.go:109 when esbuild reports an error message (api.Message) whose Location is nil. Because there is no source position, Hugo surfaces the raw msg.Text rather than a file-position error. The {} placeholder denotes the message is whatever esbuild produced.","triggerScenarios":"Calling js.Build / css.Build (or BuildClient.Build in Go) and esbuild emits a non-located error: an invalid build option, a top-level resolution failure with no file context, or an internal esbuild error. These are errors esbuild itself cannot tie to a source line.","commonSituations":"Passing unsupported options to js.Build (e.g. an unknown target/sourceMap value), a bundler-level failure before any file is parsed, or an esbuild version mismatch producing a generic error string.","solutions":["Read the full error text (Hugo prints msg.Text) for the esbuild-specific cause.","Validate the options map passed to js.Build / opts.validate() against esbuild's supported options.","Simplify the build (disable minify, sourceMap, or splitting) to isolate which option triggers the message.","Check that the entry source is non-empty and reachable before bundling."],"exampleFix":"// before\n{{ $js = resources.Get \"main.js\" | js.Build (dict \"sourceMap\" \"invalid\") }}\n// after\n{{ $js = resources.Get \"main.js\" | js.Build (dict \"sourceMap\" \"inline\") }}","handlingStrategy":"try-catch","validationCode":"// Validate options before building where possible.\n// Hugo's opts.validate() checks struct fields; confirm dict keys are valid esbuild options.","typeGuard":null,"tryCatchPattern":"// Wrap js.Build so build failures don't abort rendering if optional.\n{{ with resources.Get \"main.js\" }}\n  {{ with js.Build . | try }}{{ . }}{{ else }}{{ warnf \"js.Build failed: %s\" . }}{{ end }}\n{{ end }}","preventionTips":["Cross-check option names/values against esbuild's API docs.","Build with a minimal options map first, then add complexity.","Log the full esbuild message text when catching."],"tags":["esbuild","javascript","bundling","css"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}