Skip to content

Commit

Permalink
js/esbuild: Add runners after scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Dec 16, 2024
1 parent 4cbd4ef commit 7de5317
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions internal/js/esbuild/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,18 +476,10 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {

for _, g := range b.scriptGroups.Sorted() {
keyPath := g.id
var runners []scriptRunnerTemplateContext
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(g.id, runnerImpPath, vv.Compiled().Resource, false)
}

t := &batchGroupTemplateContext{
keyPath: keyPath,
ID: g.id,
Runners: runners,
}

instances := g.instancesOptions.ByKey()
Expand Down Expand Up @@ -521,6 +513,13 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
t.Scripts = append(t.Scripts, bt)
}

for _, vv := range g.runnersOptions.ByKey() {
runnerKeyPath := keyPath + "_" + vv.Key().String()
runnerImpPath := paths.AddLeadingSlash(runnerKeyPath + "_runner" + vv.Compiled().Resource.MediaType().FirstSuffix.FullSuffix)
t.Runners = append(t.Runners, scriptRunnerTemplateContext{opts: vv, Import: runnerImpPath})
addResource(g.id, runnerImpPath, vv.Compiled().Resource, false)
}

r, s, err := b.client.buildBatchGroup(ctx, t)
if err != nil {
return nil, fmt.Errorf("failed to build JS batch: %w", err)
Expand Down

0 comments on commit 7de5317

Please sign in to comment.