Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Expose GetModuleExport APIs #148

Closed
Symbitic opened this issue Jan 30, 2024 · 4 comments · Fixed by #154
Closed

Feature request: Expose GetModuleExport APIs #148

Symbitic opened this issue Jan 30, 2024 · 4 comments · Fixed by #154
Labels
enhancement New feature or request

Comments

@Symbitic
Copy link

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.

@justjake
Copy link
Owner

justjake commented Jan 30, 2024

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.

@justjake justjake added the enhancement New feature or request label Jan 30, 2024
@Symbitic
Copy link
Author

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;

@justjake
Copy link
Owner

Work in progress here: #154

@justjake
Copy link
Owner

Published with v0.29.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants