-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[embind] Export embind exports as ESM exports for MODULARIZE=instance. #23404
base: main
Are you sure you want to change the base?
[embind] Export embind exports as ESM exports for MODULARIZE=instance. #23404
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear this only works in AOT mode? What happens in non-AOT mode?
src/embind/embind_gen.js
Outdated
out.push('}\n'); | ||
let updateExports = '() => {\n'; | ||
for (const publicSymbol of publicSymbols) { | ||
updateExports += `__exp_${publicSymbol} = Module['${publicSymbol}'];\n` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these extra assignment happen during onInit
in the final output module? They don't happen at AOT time, right? Or do they happen both at AOT time and at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They happen just in the final output at runtime.
In non-aot mode, the user would have to get the bindings off the module object from init. e.g. const module = await init();
module.foo(); We could require that modularize instance + embind only works with embind_aot, or enable embind_aot in instance mode by default. I lean towards the latter. |
src/embind/embind.js
Outdated
$InvokerFunctions: '<<< EMBIND_AOT_OUTPUT >>>', | ||
$InvokerFunctions: '<<< EMBIND_AOT_INVOKERS >>>', | ||
#if MODULARIZE == 'instance' | ||
$embindUpdateExports: '<<< EMBIND_AOT_UPDATE_EXPORTS >>>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding some comments here about that embindUpdateExports
does and when?
Using the embind AOT mode we can generate a list of all the embind bindings and export them as ES module exports.
f66d559
to
28d8a57
Compare
Using the embind AOT mode we can generate a list of all the embind bindings and export them as ES module exports.