Backtestshugorun-20260917-015623#15307
js.Build should support es2025 as target
Our patch was judged on par with the merged fix.
In this judgment, Patch B = our agent, Patch A = the merged fix.
The two diffs are byte-for-byte identical. Both add the exact same one-line mapping `"es2025": api.ES2025` to the target map in internal/js/esbuild/options.go — the correct root-cause fix, since the reported error `unsupported target: [es2025]` comes from that lookup table lacking the entry now that esbuild exposes api.ES2025. Both make the identical edit to options_test.go, adding `{"es2024", api.ES2024}` and `{"es2025", api.ES2025}` to the table-driven TestToBuildOptionsTarget cases, which would fail before the map change and pass after. Correctness, tests, scope (minimal, no drive-by churn), and craft are indistinguishable because there is literally nothing to distinguish — the patches are the same text. This is a genuine tie, not a hard comparison resolved arbitrarily.
The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.
Solve
15m 48s1 turn
Wall-clock time in the container
Full test suite
No new failures
3,753 passed · 100 skipped · 3,859 total
Contamination audit
Unknown
See the audit notes for this run
Patch size
3vs 3 merged
Changed lines, ours vs merged
The issue
View on GitHubHugo's built-in js.Build function currently doesnt support and/or list es2025 as available target parameter.
As far as i understood js.Build relies on evanw/esbuild for bundling, transforming and minifying javascript ressources.
According to hugo's own release notes esbuild was just bumped to 0.28.2.
According to esbuild's release notes, support for es2025 as target parameter exists since 0.27.5.
Hugo should therefore support es2025 as target parameter.
However when doing something like this:
{{- $buildParams := dict
"minify" true
"sourceMap" "none"
"target" "es2025"
}}
{{- with . | js.Build $buildParams }}
<script>{{ .Content | safeJS }}</script>
{{- end }}
results in the following error message:
`
... JSBUILD: failed to transform "/ts/test.ts" (text/typescript): unsupported target: [es2025] ...
`
What version of Hugo are you using (hugo version)?
hugo v0.165.0
Does this issue reproduce with the latest release?
Yes
The two patches
internal/js/esbuild/options.goindex 4176438e8..9248701f7 100644@@ -49,6 +49,7 @@ var ( "es2022": api.ES2022, "es2023": api.ES2023, "es2024": api.ES2024,+ "es2025": api.ES2025, } engineName = map[string]api.EngineName{internal/js/esbuild/options_test.goindex b60dcbc4a..683a32db0 100644@@ -189,6 +189,8 @@ func TestToBuildOptionsTarget(t *testing.T) { {"es2021", api.ES2021}, {"es2022", api.ES2022}, {"es2023", api.ES2023},+ {"es2024", api.ES2024},+ {"es2025", api.ES2025}, {"", api.ESNext}, {"esnext", api.ESNext}, } {
internal/js/esbuild/options.goindex 4176438e8..9248701f7 100644@@ -49,6 +49,7 @@ var ( "es2022": api.ES2022, "es2023": api.ES2023, "es2024": api.ES2024,+ "es2025": api.ES2025, } engineName = map[string]api.EngineName{internal/js/esbuild/options_test.goindex b60dcbc4a..683a32db0 100644@@ -189,6 +189,8 @@ func TestToBuildOptionsTarget(t *testing.T) { {"es2021", api.ES2021}, {"es2022", api.ES2022}, {"es2023", api.ES2023},+ {"es2024", api.ES2024},+ {"es2025", api.ES2025}, {"", api.ESNext}, {"esnext", api.ESNext}, } {
What the agent reported
The fix is complete and verified. Final report:
What was wrong
Hugo's js.Build maps a target string (e.g. "es2020") to an esbuild target enum via the nameTarget map in internal/js/esbuild/options.go. That map stopped at "es2024". When "es2025" was requested, the lookup in compile() found nothing, target stayed 0, and the guard if target == 0 && len(engines) == 0 && len(opts.Target) > 0 fired, producing the reported error unsupported target: [es2025]. The evanw/esbuild dependency (v0.28.2, which includes ES2025 support since 0.27.5) already exposed the api.ES2025 constant — Hugo simply never mapped it.
What I changed
Two files, one line each:
internal/js/esbuild/options.go— added"es2025": api.ES2025,to thenameTargetmap, right after thees2024entry.internal/js/esbuild/options_test.go— added{"es2024", api.ES2024}and{"es2025", api.ES2025}table entries to the existingTestToBuildOptionsTarget(which previously only covered up toes2023).
I left the stale Target doc comment (which already omits es2021–es2024) untouched to keep the change minimal — it's pre-existing and out of scope.
Verification
- I confirmed
api.ES2025exists in the esbuild v0.28.2 module cache inside the build container. - Gate run:
./bt-test -run 'TestToBuildOptions|TestDecodeExternalOptions' ./internal/js/esbuild/— all esbuild option tests pass, including the newTestToBuildOptionsTarget/es2024andTestToBuildOptionsTarget/es2025subtests, with no failures anywhere in the report. The regression test is genuine: without the map entry,es2025would error (unsupported target) rather than mapping toapi.ES2025. - The reviewer confirmed the fix targets exactly the reported code path, the regression test is real, no existing test was weakened, and the diff is limited to these two files (plus the pre-existing
AGENTS.md/CLAUDE.mddeletions from the initial working-tree state).
All changes are left uncommitted in the working tree.