Backtestshugorun-20260922-141813#15307

Issue #15307 Merged fix PR # Run 22 Sep 2026 · run-20260922-141813 gohugoio/hugo

js.Build should support es2025 as target

Par

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 exactly `"es2025": api.ES2025,` to the target map in internal/js/esbuild/options.go (the root cause — the missing map entry is precisely why esbuild rejected the target), and both add the identical `{"es2024", api.ES2024}` and `{"es2025", api.ES2025}` cases to TestToBuildOptionsTarget. Correctness, tests, scope, and craft are indistinguishable because the patches are the same text. No criterion separates them.

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

20m 4s19 turns

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

Hugo'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

Our patch+3 −0
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}, 	} { 
Merged fix · PR #+3 −0
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.

Summary

What was wrong: Hugo's js.Build translates the target option string to an esbuild api.Target constant via the nameTarget map in internal/js/esbuild/options.go. That map stopped at es2024, so "es2025" fell through to the "no target matched" branch and returned unsupported target: [es2025] — exactly the reported error. esbuild added api.ES2025 in v0.27.5, and Hugo now pins v0.28.2 (go.mod), so the constant is available.

What I changed (uncommitted working-tree edits):

  • internal/js/esbuild/options.go — added one line, "es2025": api.ES2025,, after the es2024 entry in the nameTarget map.
  • internal/js/esbuild/options_test.go — added regression cases {"es2024", api.ES2024} and {"es2025", api.ES2025} to the existing table-driven TestToBuildOptionsTarget (the table previously stopped at es2023).

Test evidence:

  • Before the fix, the new TestToBuildOptionsTarget/es2025 failed at runtime with got non-nil error … "unsupported target: [es2025]" — the exact reported behavior. The test compiled, proving api.ES2025 exists in the pinned esbuild.
  • After the fix, ./bt-test internal/js/esbuild passes fully: ok github.com/gohugoio/hugo/internal/js/esbuild — all subtests including es2024, es2025, and every pre-existing test (TestToBuildOptions, TestDecodeExternalOptions…, batch tests, etc.).
  • A build-fail | internal/js/esbuild record also appears in the report, but I confirmed it's a bt-test harness artifact (the untouched bufferpool package produces the identical dual record); the real module-path result is a clean PASS.

Blast radius: The change only adds a new map entry — no existing code path is removed, gated, or altered — so existing behavior is unchanged. Reviewer confirmed the diff is correct, minimal, and scoped to the two files (the AGENTS.md/CLAUDE.md deletions in git status are pre-existing and unrelated).

Requirements checklist:

  1. Support es2025 as a js.Build target — Implemented (nameTarget entry) with test evidence (regression test fails before / passes after).

No other explicit asks were in the report.