-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hello!
I might just have missed it from the docs, but I can't seem to access functions from evaluated modules that don't do a default export:
vm, _ := qjs.New()
ctx := vm.Context()
foo, _ := ctx.Eval("foo.js", qjs.Code(`
export default function foo(x) {
return x * 2;
}
`), qjs.TypeModule())
// prints "function foo(x)... yadda yadda"
fmt.Printf("foo: %+v\n", foo)
bar, _ := ctx.Eval("bar.js", qjs.Code(`
export function foo(x) {
return x * 2;
}
`), qjs.TypeModule())
// prints "undefined"
fmt.Printf("bar: %+v\n", bar)My use case is that I receive scripts that are supposed to export a function with a particular name, and I need to call it from go. Is there a way to do this besides writing an extra script that imports from the module and re-exports it as default?
Cheers!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels