js: Fix js.Batch for multihost setups

Note that this is an unreleased feature.

Fixes #13151
This commit is contained in:
Bjørn Erik Pedersen
2024-12-16 08:34:17 +01:00
parent 48dd6a918a
commit 565c30eac9
8 changed files with 190 additions and 71 deletions

View File

@@ -42,6 +42,7 @@ import (
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/hugolib/doctree"
"github.com/gohugoio/hugo/hugolib/pagesfromdata"
"github.com/gohugoio/hugo/internal/js/esbuild"
"github.com/gohugoio/hugo/internal/warpc"
"github.com/gohugoio/hugo/langs/i18n"
"github.com/gohugoio/hugo/modules"
@@ -205,6 +206,12 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
return nil, err
}
batcherClient, err := esbuild.NewBatcherClient(firstSiteDeps)
if err != nil {
return nil, err
}
firstSiteDeps.JSBatcherClient = batcherClient
confm := cfg.Configs
if err := confm.Validate(logger); err != nil {
return nil, err
@@ -313,7 +320,6 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
return li.Lang < lj.Lang
})
var err error
h, err = newHugoSites(cfg, firstSiteDeps, pageTrees, sites)
if err == nil && h == nil {
panic("hugo: newHugoSitesNew returned nil error and nil HugoSites")