-
Notifications
You must be signed in to change notification settings - Fork 46
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
Switch to NAPI #138
Comments
👍 for this I'm trying to get I tried to port |
Thank for the work on msgpackr-extract, I'll take a look at it! FWIW, you should already be able to run lmdb-js on Deno, as it supports the Deno FFI API and even includes some simple unit tests in the CI tasks. And msgpackr-extract is an optional dependency, so it is not necessary for lmdb-js or msgpackr to run on Deno. They should run fine without, msgpackr-extract just provides some performance boosting (although it would definitely be cool to get it working on Deno!). But maybe you are already aware of all this and your goal is more of using parcel as a test piece for verifying the proposed NAPI implementation for Deno (I realized that your work has been mostly on Deno)? Certainly getting parcel running on Deno would be an impressive verification of binary add-on compatibility with all the different binaries that are used! Anyway, thanks for your efforts, the msgpackr branch will be a good chance for me to get more practice using NAPI as well, and hopefully pave the way for eventually similar work on lmdb-js. |
Hey @kriszyp!
Yeah, we tried to "polyfill" lmdb that parcel uses with the version available for Deno, unfortunately that doesn't work in this case - we need to make it available via
This 100%. Parcel seems to be complex enough project that should allow us to validate that our NAPI integration is proper for broad usage. |
lmdb-js isn't working on Deno because it uses Since you are working on this in Deno, I have questions :). First, I am curious if I can just use NAPI as an "entry point" for the loading a module, and then cast the module exports to the V8 object (v8::Localv8::Object), and directly use the V8 apis in my code? Both lmdb-js and msgpackr-extract directly interact with the V8 APIs quite a bit, and it might actually be a lot easier to transition the code, at least in the short term/interim, to using NAPI as the entry point and then build classes and manipulate values with the V8 APIs. Of course I realize this undermines the goal of NAPI, ABI stability, but maybe possible as a transitional approach to getting it running (and then transition from internal use of V8 -> NAPI). Also, I'm curious if the goal is NAPI would only be available in --compat mode? Or do you see it as eventually being more of the primary/first-class way to load binary add-ons (outside of WASM, at least)? Or should I not consider deno --compat to be second class? Anyway, I'm impressed with how quickly you are making progress on this, I know NAPI in Deno is a big endeavor! |
It does work, it's just we can't use it for
I'm not sure I fully understand what you mean by "entrypoint" here. All in all, supporting NAPI is already a compromise to our goal of not exposing
Unclear at this point - but I would be leaning towards NAPI being always available. That would be third way to load binary addons (after WASM and FFI API). We are having internal discussion if |
I don't think that's possible, NAPI by design hides the underlying layout and just exposes an opaque pointer for
Yessss! |
Ok denosaurs, @littledivy and @bartlomieju, I've published a pre-release version of v2.3.0 (https://www.npmjs.com/package/lmdb/v/2.3.0-alpha.1) with the rewrite to use NAPI. I have verified running parcel with this, so this hopefully this should give you something viable to test Deno with NAPI. A few notes on this:
Anyway, hopefully that gives you something to work with for the parcel-on-deno project, good luck! And long-term this will certainly be a great way for high-performance binaries to run on Deno, so thank you for your efforts! |
Sounds good, Thanks for keeping us updated! |
Looking into the PR a little, would it be reasonable/preferable for me to specifically target Deno and use |
Currently that's not very probable. As a rule of thumb |
@bartlomieju I'm also curious about the intended or suggested means of distribution. Presumably lmdb-js could run in Deno as a Node-style transient dependency package within a set of NPM installed packages alongside Parcel and friends, and loaded via node-compatible
|
Hi @kriszyp.
Right, I think this will be the main way of consuming at it will work transparently for users.
There's no decision yet if NAPI will require I'm curious to learn your thoughts on this matter, which option in your mind would be the best from the DX standpoint? |
Yes, this proposal certainly does seem like it could provide a more elegant approach to loading binary modules. As far as my dev experience, simply installing packages with npm (or yarn or whatever) is the easiest to support, since that is already the supported approach in node. I just thought Deno was continuing to push for the URL-based module system, so wanted to support idiomatic, best-practice Deno packaging of modules as much as possible. But I certainly don't mind waiting to see if and when there is a better supported method that comes along. Using npm (and |
Anyway, thanks for the help. BTW, do you have any estimate on when you are hoping NAPI might land? |
Hoping to get it in in 1.21 or 1.22, so in April or May. |
lmdb-js currently uses the NAN API for the native add-on C/C++ code, but the NAPI API provides better ABI stability and would require fewer versioned builds. Supposedly Deno is working on supporting NAPI (https://twitter.com/biwanczuk/status/1487122575012548612), so this might be much easier way to support Deno + Node. However, this would require conversion of a lot of code, and not sure if everything we do is even supported by NAPI, so would need more investigation.
The text was updated successfully, but these errors were encountered: