diff --git a/go.mod b/go.mod index 37ee48af9..f9f4dbfc2 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 github.com/clbanning/mxj/v2 v2.7.0 github.com/dustin/go-humanize v1.0.1 - github.com/evanw/esbuild v0.28.0 + github.com/evanw/esbuild v0.28.1 github.com/fatih/color v1.18.0 github.com/fortytw2/leaktest v1.3.0 github.com/frankban/quicktest v1.14.6 diff --git a/go.sum b/go.sum index 218df97c1..c89317796 100644 --- a/go.sum +++ b/go.sum @@ -237,6 +237,8 @@ github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/evanw/esbuild v0.28.0 h1:V96ghtc5p5JnNUQIUsc5H3kr+AcFcMqOJll2ZmJW6Lo= github.com/evanw/esbuild v0.28.0/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= +github.com/evanw/esbuild v0.28.1 h1:ds+yuRyUaZGx++GR56CrCeuXh8PVhVM4xq8v7PNELFc= +github.com/evanw/esbuild v0.28.1/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= diff --git a/internal/js/esbuild/batch_integration_test.go b/internal/js/esbuild/batch_integration_test.go index 16309985c..ca85cb4a7 100644 --- a/internal/js/esbuild/batch_integration_test.go +++ b/internal/js/esbuild/batch_integration_test.go @@ -243,8 +243,8 @@ Defer: ` b := hugolib.Test(t, files, hugolib.TestOptWithOSFs()) b.AssertPublishDir( - "en/mybatch/chunk-TOZKWCDE.js", "en/mybatch/mygroup.js ", - "fr/mybatch/mygroup.js", "fr/mybatch/chunk-TOZKWCDE.js") + "en/mybatch/chunk-MO3Q4WT6.js", "en/mybatch/mygroup.js ", + "fr/mybatch/mygroup.js", "fr/mybatch/chunk-MO3Q4WT6.js") } func TestBatchRenameBundledScript(t *testing.T) { @@ -402,7 +402,7 @@ export default function P1Script() {}; b.AssertFileContent("public/mybatch/mygroup.js", "sourceMappingURL=mygroup.js.map") b.AssertFileContent("public/mybatch/p1.js", "sourceMappingURL=p1.js.map") b.AssertFileContent("public/mybatch/mygroup_run_runner.js", "sourceMappingURL=mygroup_run_runner.js.map") - b.AssertFileContent("public/mybatch/chunk-UQKPPNA6.js", "sourceMappingURL=chunk-UQKPPNA6.js.map") + b.AssertFileContent("public/mybatch/chunk-3REXYBSZ.js", "sourceMappingURL=chunk-3REXYBSZ.js.map") checkMap := func(p string, expectLen int) { s := b.FileContent(p) @@ -421,7 +421,7 @@ export default function P1Script() {}; checkMap("public/mybatch/mygroup.js.map", 1) checkMap("public/mybatch/p1.js.map", 1) checkMap("public/mybatch/mygroup_run_runner.js.map", 0) - checkMap("public/mybatch/chunk-UQKPPNA6.js.map", 1) + checkMap("public/mybatch/chunk-3REXYBSZ.js.map", 1) } func TestBatchErrorRunnerResourceNotSet(t *testing.T) { diff --git a/internal/js/esbuild/build.go b/internal/js/esbuild/build.go index 355732503..779b112e0 100644 --- a/internal/js/esbuild/build.go +++ b/internal/js/esbuild/build.go @@ -217,7 +217,12 @@ func (c *BuildClient) Build(opts Options) (api.BuildResult, error) { } if !strings.HasPrefix(s, PrefixHugoVirtual) { - if !filepath.IsAbs(s) { + // A leading slash marks a synthetic import key rooted in Hugo's + // virtual namespace (see paths.AddLeadingSlash in batch.go); it is + // not an OutDir-relative path. filepath.IsAbs only reports true for + // such paths on Unix, so check it explicitly to behave the same on + // Windows. + if !filepath.IsAbs(s) && !strings.HasPrefix(s, "/") { s = filepath.Join(opts.OutDir, s) } }