{"id":"234df0970d37ce85","repo":"gohugoio/hugo","slug":"unsupported-target-v","errorCode":null,"errorMessage":"unsupported target: %v","messagePattern":"unsupported target: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/options.go","lineNumber":293,"sourceCode":"\n\tvar engines []api.Engine\n\nOUTER:\n\tfor _, value := range opts.Target {\n\t\tfor _, engine := range engineKeysSorted {\n\t\t\tif strings.HasPrefix(value, engine) {\n\t\t\t\tversion := value[len(engine):]\n\t\t\t\tif version == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"invalid engine version: %q\", value)\n\t\t\t\t}\n\t\t\t\tengines = append(engines, api.Engine{Name: engineName[engine], Version: version})\n\t\t\t\tcontinue OUTER\n\t\t\t}\n\t\t}\n\t}\n\n\tif target == 0 && len(engines) == 0 && len(opts.Target) > 0 {\n\t\treturn fmt.Errorf(\"unsupported target: %v\", opts.Target)\n\t}\n\n\tif target == 0 {\n\t\ttarget = api.ESNext\n\t}\n\n\tvar loaders map[string]api.Loader\n\tif opts.IsCSS {\n\t\tloaders = make(map[string]api.Loader)\n\t\t// Add default CSS file loaders.\n\t\t// May be overridden by opts.Loaders.\n\t\tmaps.Copy(loaders, extensionToLoaderMapCSS)\n\t}\n\tif opts.Loaders != nil {\n\t\tif loaders == nil {\n\t\t\tloaders = make(map[string]api.Loader)\n\t\t}\n","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/internal/js/esbuild/options.go#L275-L311","documentation":"After trying to interpret each `target` entry as either an ES version or an engine+version, Hugo checks whether anything matched. If targets were supplied but none resolved to a known ES version (es5–es2024, esnext) or engine prefix (chrome, firefox, safari, edge, node, etc.), the whole option set is rejected as unsupported.","triggerScenarios":"`js.Build` with a `target` list where every entry is unrecognized — e.g. \"es7\" instead of \"es2016\", \"ie11\" (esbuild has no IE engine target), or a misspelled engine like \"chorme90\". target != 0 or a matched engine suppresses the error, so it fires only when all entries fail to parse.","commonSituations":"Porting browserslist strings (\"ie 11\", \"> 0.5%\") directly into the target option; using informal ES names like es7/es8; upgrading Hugo/esbuild and using a target string from another bundler's docs.","solutions":["Use a valid ES version (\"es2015\"–\"es2024\", \"esnext\") or engine+version (\"chrome90\", \"node18\", \"safari15\") in target.","Replace browserslist-style entries — esbuild targets don't support queries or IE.","Check the esbuild target docs for the exact accepted names and spell them without spaces."],"exampleFix":"{{/* before */}}\n{{ $opts := dict \"target\" \"es7\" }}\n{{/* after */}}\n{{ $opts := dict \"target\" \"es2016\" }}","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"es5\":true,\"es6\":true,\"es2015\":true,\"es2016\":true,\"es2017\":true,\"es2018\":true,\"es2019\":true,\"es2020\":true,\"es2021\":true,\"es2022\":true,\"es2023\":true,\"esnext\":true}\nif !valid[strings.ToLower(target)] {\n    return fmt.Errorf(\"unsupported js.Build target %q\", target)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only esbuild-supported target names (esXXXX/esnext) in js.Build options","Check the Hugo docs for the target list matching your Hugo/esbuild version","Centralize the target in site config so it's set in one validated place"],"tags":["hugo","js-build","esbuild","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}