aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-12-13 11:00:04 +0100
committerBjørn Erik Pedersen <[email protected]>2024-12-13 13:29:35 +0100
commita834bb9f7e14298a8df75f7ffb69e31f2a36e655 (patch)
tree150aa2ac5797c76fd1673b25a9cddb1aaaea6604 /internal
parent4f130f6e4f891d7df1029a29336efe9e1475d17f (diff)
downloadhugo-a834bb9f7e14298a8df75f7ffb69e31f2a36e655.tar.gz
hugo-a834bb9f7e14298a8df75f7ffb69e31f2a36e655.zip
js/esbuild: Build groups in order of their ID
We already do this for scripts e.g. inside a group. This makes sure that group A's entry points gets added before B's, which can be an important property, see https://github.com/evanw/esbuild/issues/399#issuecomment-1458680887
Diffstat (limited to 'internal')
-rw-r--r--internal/js/esbuild/batch.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/js/esbuild/batch.go b/internal/js/esbuild/batch.go
index 43e2da444..1a8a7b09a 100644
--- a/internal/js/esbuild/batch.go
+++ b/internal/js/esbuild/batch.go
@@ -474,25 +474,25 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
entryPoints = append(entryPoints, pth)
}
- for k, v := range b.scriptGroups {
- keyPath := k
+ for _, g := range b.scriptGroups.Sorted() {
+ keyPath := g.id
var runners []scriptRunnerTemplateContext
- for _, vv := range v.runnersOptions.ByKey() {
+ for _, vv := range g.runnersOptions.ByKey() {
runnerKeyPath := keyPath + "_" + vv.Key().String()
runnerImpPath := paths.AddLeadingSlash(runnerKeyPath + "_runner" + vv.Compiled().Resource.MediaType().FirstSuffix.FullSuffix)
runners = append(runners, scriptRunnerTemplateContext{opts: vv, Import: runnerImpPath})
- addResource(k, runnerImpPath, vv.Compiled().Resource, false)
+ addResource(g.id, runnerImpPath, vv.Compiled().Resource, false)
}
t := &batchGroupTemplateContext{
keyPath: keyPath,
- ID: v.id,
+ ID: g.id,
Runners: runners,
}
- instances := v.instancesOptions.ByKey()
+ instances := g.instancesOptions.ByKey()
- for _, vv := range v.scriptsOptions.ByKey() {
+ for _, vv := range g.scriptsOptions.ByKey() {
keyPath := keyPath + "_" + vv.Key().String()
opts := vv.Compiled()
impPath := path.Join(PrefixHugoVirtual, opts.Dir(), keyPath+opts.Resource.MediaType().FirstSuffix.FullSuffix)
@@ -502,7 +502,7 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
name: keyPath,
resourceGetter: impCtx,
scriptOptions: opts,
- dm: v.dependencyManager,
+ dm: g.dependencyManager,
})
bt := scriptBatchTemplateContext{
@@ -528,10 +528,10 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
state.importerImportContext.Set(s, importContext{
name: s,
resourceGetter: nil,
- dm: v.dependencyManager,
+ dm: g.dependencyManager,
})
- addResource(v.id, s, r, true)
+ addResource(g.id, s, r, true)
}
mediaTypes := b.client.d.ResourceSpec.MediaTypes()