Using Node-API from a classic addon module #52557
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
-
As a stop-gap for compatibility, I wanted to try and create a module that converts v8/NaN tree-sitter language object (Which is a
v8::Object
with an internal pointer) to a napi language object (A type taggedNapi::External
).Such a module is technically a classic Node ABI dependent module, so should use the
NODE_MODULE
way of init so that Node.js will properly block it from loading if built agains't the wrong version, as it is going to use v8/NaN API to access the v8/Nan language object, but then since I don't have anapi_env
, I can't create the napi external or use napi at all from such a module.On the other hand, if I use the
NAPI_MODULE
, then Node.js will likely agree to load such module across different ABI versions even if it technically depends on a specific Node.js ABI version, but I will have anapi_env
and can technically use v8 API from a Node-API module by way ofv8::Isolate::GetCurrent
and friends.Is there a supported way to create such a module?
Beta Was this translation helpful? Give feedback.
All reactions