From 34db6457ac9f71b9782950ddec68b3c316b7e058 Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 16 Aug 2026 17:44:52 +0530 Subject: [PATCH] feat(testrun): expose the seeded bundle a run loaded BundleSpec produces the goja bundle a run of a spec loaded, seeded as that run was. an offline replay has to load the same javascript, and the seed is one of the bundle's defines, so it is part of the bundle's identity. --- internal/testrun/testrun.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/testrun/testrun.go b/internal/testrun/testrun.go index 8cc53a7..e822c43 100644 --- a/internal/testrun/testrun.go +++ b/internal/testrun/testrun.go @@ -266,6 +266,23 @@ func (e ViolationsError) Error() string { return fmt.Sprintf("%d violation record(s)", e.Count) } +// BundleSpec produces the goja bundle a run of this spec loaded, seeded as that +// run was. An offline replay of the run's trace has to load the same JavaScript +// the run did, and the seed is one of the bundle's defines, so it is part of +// the bundle's identity. +func BundleSpec(specPath string, seed int64) (bundler.Result, error) { + inputs, err := prepareBundleInputs(Options{Spec: specPath, Seed: seed}) + if err != nil { + return bundler.Result{}, err + } + return bundler.Bundle(bundler.Options{ + EntryFile: specPath, + RuntimeFile: inputs.gojaRuntimePath, + Defines: inputs.defines, + Aliases: inputs.aliases, + }) +} + // bundleInputs holds the pre-driver assembly: alias map, seed, esbuild defines, // and the resolved spec-API/goja-runtime paths the bundler consumes. type bundleInputs struct {