Skip to content

Commit

Permalink
Also set "options" on the "exports" not just in the runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed May 4, 2020
1 parent d9a307b commit 4c391e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down

0 comments on commit 4c391e5

Please sign in to comment.