You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current embedding API gives you to ability to run a CJS script (That seems to need to bootstrap require by itself), or to get a callback with a runCjs function, but what's the right way to run ESM when embedding? The current sample https://nodejs.org/docs/latest-v20.x/api/embedding.html uses runInThisContext which doesn't support dynamic import by default without vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER which dumps an experimental warning, and vm.SourceTextModule is experimental, which I'm not sure how to correctly enable when embedding, and also seems incomplete such as requiring a link callback without giving you access to the default resolution algorithm, and so on... And the CJS main execution is sync, so if you import, how would you wait for the resulting promise to finish from embedding code?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The current embedding API gives you to ability to run a CJS script (That seems to need to bootstrap
require
by itself), or to get a callback with arunCjs
function, but what's the right way to run ESM when embedding? The current sample https://nodejs.org/docs/latest-v20.x/api/embedding.html usesrunInThisContext
which doesn't support dynamic import by default withoutvm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
which dumps an experimental warning, andvm.SourceTextModule
is experimental, which I'm not sure how to correctly enable when embedding, and also seems incomplete such as requiring alink
callback without giving you access to the default resolution algorithm, and so on... And the CJS main execution is sync, so if youimport
, how would you wait for the resulting promise to finish from embedding code?Beta Was this translation helpful? Give feedback.
All reactions