Closed Symbitic closed 4 months ago
I'd follow upstream here, which is to expose JS_GetModuleNamespace
. Can you propose an interface for how it's used in Javascript code? quickjs-emscripten doesn't have any public APIs that use JSModuleDef, I'm curious what would work for your use-case.
The use case is for when you want to get a value from a JavaScript file instead of evaluating code. So instead of something like vm.evalCode
, you'd have:
const result = vm.getExports(code);
const { name, resolveId, preconfigure } = result.default;
Work in progress here: #154
Published with v0.29.0
quickjs-ng (and most forks/patches of the original quickjs) expose
JS_GetModuleExport
and related functions that allow accessing the value of an ESM export, which makes it great for a plugin system. Work is still ongoing in the original quickjs (see bellard/quickjs#35), so there may need to be placeholders that throw an exception when a non-quickjs-ng build is used, but I would really like to see this added.