Embedding Node.js ESM #52432
Unanswered
segevfiner
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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