diff --git a/js/bundle.go b/js/bundle.go index 30dab0bf76d..aae3be50418 100644 --- a/js/bundle.go +++ b/js/bundle.go @@ -227,7 +227,9 @@ func (b *Bundle) Instantiate() (bi *BundleInstance, instErr error) { var jsOptionsObj *goja.Object if jsOptions == nil || goja.IsNull(jsOptions) || goja.IsUndefined(jsOptions) { jsOptionsObj = rt.NewObject() - rt.Set("options", jsOptionsObj) + if err := exports.Set("options", jsOptionsObj); err != nil { + return nil, err + } } else { jsOptionsObj = jsOptions.ToObject(rt) } diff --git a/js/runner_test.go b/js/runner_test.go index 9da3bc11f86..05a943b479a 100644 --- a/js/runner_test.go +++ b/js/runner_test.go @@ -146,6 +146,7 @@ func TestOptionsSettingToScript(t *testing.T) { t.Run(fmt.Sprintf("Variant#%d", i), func(t *testing.T) { t.Parallel() data := variant + ` + exports.options = options; exports.default = function() { if (!options) { throw new Error("Expected options to be defined!");