Make js.Build fully support modules

Fixes #7816
Fixes #7777
Fixes #7916
This commit is contained in:
Bjørn Erik Pedersen 2020-10-05 13:34:14 +02:00
parent 3089fc0ba1
commit 85e4dd7370
22 changed files with 949 additions and 988 deletions

View file

@ -23,6 +23,8 @@ import (
"strings"
"sync"
"github.com/gohugoio/hugo/resources/jsconfig"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/config"
@ -76,17 +78,20 @@ func NewSpec(
}
rs := &Spec{
PathSpec: s,
Logger: logger,
ErrorSender: errorHandler,
imaging: imaging,
incr: incr,
MediaTypes: mimeTypes,
OutputFormats: outputFormats,
Permalinks: permalinks,
BuildConfig: config.DecodeBuild(s.Cfg),
FileCaches: fileCaches,
PostProcessResources: make(map[string]postpub.PostPublishedResource),
PathSpec: s,
Logger: logger,
ErrorSender: errorHandler,
imaging: imaging,
incr: incr,
MediaTypes: mimeTypes,
OutputFormats: outputFormats,
Permalinks: permalinks,
BuildConfig: config.DecodeBuild(s.Cfg),
FileCaches: fileCaches,
PostBuildAssets: &PostBuildAssets{
PostProcessResources: make(map[string]postpub.PostPublishedResource),
JSConfigBuilder: jsconfig.NewBuilder(),
},
imageCache: newImageCache(
fileCaches.ImageCache(),
@ -121,8 +126,15 @@ type Spec struct {
ResourceCache *ResourceCache
FileCaches filecache.Caches
// Assets used after the build is done.
// This is shared between all sites.
*PostBuildAssets
}
type PostBuildAssets struct {
postProcessMu sync.RWMutex
PostProcessResources map[string]postpub.PostPublishedResource
JSConfigBuilder *jsconfig.Builder
}
func (r *Spec) New(fd ResourceSourceDescriptor) (resource.Resource, error) {