Skip to content

Commit a834bb9

Browse files
committedDec 13, 2024·
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 evanw/esbuild#399 (comment)
1 parent 4f130f6 commit a834bb9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎internal/js/esbuild/batch.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -474,25 +474,25 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
474474
entryPoints = append(entryPoints, pth)
475475
}
476476

477-
for k, v := range b.scriptGroups {
478-
keyPath := k
477+
for _, g := range b.scriptGroups.Sorted() {
478+
keyPath := g.id
479479
var runners []scriptRunnerTemplateContext
480-
for _, vv := range v.runnersOptions.ByKey() {
480+
for _, vv := range g.runnersOptions.ByKey() {
481481
runnerKeyPath := keyPath + "_" + vv.Key().String()
482482
runnerImpPath := paths.AddLeadingSlash(runnerKeyPath + "_runner" + vv.Compiled().Resource.MediaType().FirstSuffix.FullSuffix)
483483
runners = append(runners, scriptRunnerTemplateContext{opts: vv, Import: runnerImpPath})
484-
addResource(k, runnerImpPath, vv.Compiled().Resource, false)
484+
addResource(g.id, runnerImpPath, vv.Compiled().Resource, false)
485485
}
486486

487487
t := &batchGroupTemplateContext{
488488
keyPath: keyPath,
489-
ID: v.id,
489+
ID: g.id,
490490
Runners: runners,
491491
}
492492

493-
instances := v.instancesOptions.ByKey()
493+
instances := g.instancesOptions.ByKey()
494494

495-
for _, vv := range v.scriptsOptions.ByKey() {
495+
for _, vv := range g.scriptsOptions.ByKey() {
496496
keyPath := keyPath + "_" + vv.Key().String()
497497
opts := vv.Compiled()
498498
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) {
502502
name: keyPath,
503503
resourceGetter: impCtx,
504504
scriptOptions: opts,
505-
dm: v.dependencyManager,
505+
dm: g.dependencyManager,
506506
})
507507

508508
bt := scriptBatchTemplateContext{
@@ -528,10 +528,10 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
528528
state.importerImportContext.Set(s, importContext{
529529
name: s,
530530
resourceGetter: nil,
531-
dm: v.dependencyManager,
531+
dm: g.dependencyManager,
532532
})
533533

534-
addResource(v.id, s, r, true)
534+
addResource(g.id, s, r, true)
535535
}
536536

537537
mediaTypes := b.client.d.ResourceSpec.MediaTypes()

0 commit comments

Comments
 (0)
Please sign in to comment.