-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Look at N-API to see if it would help our binding portablitiy #1988
Comments
I've been following N-API closely. My bet is the that the community is blocked until nan adds support. There is currently no tracking issue with nan yet. |
I do not think that squeezing N-API into NAN is possible. I am looking right now if our low-level uv callback stuff can be converted into N-API, which offers some callback and async job handling. |
N-API is meant to be mostly a replacement for NAN in that N-API is designed to be non-leaky about V8 or engine details and provide a flat, stable ABI surface. An N-API enabled native module binary shouldn't have to be re-compiled to continue working with future versions of Node.js. But I'm not going to go completely into the sales pitch here, you can read about it. 😁 We (N-API team) have built a preliminary port of node-sass on top of N-API as part of our effort to understand the API surface used by native modules. We used this port and the port of some other modules to determine which areas to focus on converting to N-API. This port has all of the NAN and V8-specific code removed and replaced by N-API equivalents. I doubt this port meets the quality level to go in as-is, but it would certainly be a springboard if someone on node-sass was serious about doing the conversion to N-API. 😄 Please take a look if you're interested. I will be happy to answer questions about the port, help with coding it, point to documentation/code, etc. |
@boingoing if Nan is replaced with the napi convention, would we still be able to produce builds compatible with at least the current LTS versions of Node (4+) or is this only going to work for 8+ |
The N-API enabled module binary can be loaded by older Node versions as well (4 and 6) by relying on an NPM package. There are more details in the documentation of the package: |
Thank you @boingoing this is very helpful. From what I can see some It looks fairly complete and maybe even works, nice! :) |
I'm one of the developers on the N-API project. Unfortunately, NAN cannot ever support N-API directly. NAN is only a partial abstraction over the V8 APIs: when you use NAN, you're still using a lot of V8-specific types and other constructs. N-API is a higher-level, more complete abstraction: when using N-API, you shouldn't need to even include We discussed the possibility of branding the N-API C++ library as "NAN 3.0" with @kkoopa, the top contributor to NAN. (He has also been reviewing some of the N-API code.). While NAN has some precedent of breaking changes between major versions, this is more of a complete redesign than a "breaking change", so that branding didn't seem appropriate. Anyway, Node.js will need to continue to support native addons that use the V8 APIs for the foreseeable future, because some addons might not ever be updated to N-API since the changes are non-trivial. NAN should continue to support those addons the same way it does now. |
Sorry I was looking at an older version of this page and didn't see @boingoing's replies until after I posted mine. It looks like we've said mostly the same things! |
Right, at this time it is not a goal for N-API to cover all of the |
Regarding the I'd assume you don't want to immediately take a dependency on a feature that is still has "experimental" status. The best case scenario from our point of view might be if the |
Frankly, were libsass a C library, I would be happy to switch to 100% C for portability. We have lots of reports from various users where the binding does not even load and recompiling magically helps. I find it hard to keep compatibility with C++ runtimes working for everybody alike. |
Noticed this issue is still hanging-around. Is there anything we can do to help or any feedback on the particulars of the N-API? We have a weekly working group meeting every Thursday at 1:30 Eastern / 10:30 Pacific US time if you're interested in sitting-in. We would be able to spend some time going over any issues you have adopting N-API either technical, philosophical, or whatever. 😀 Here are just a couple more notes for N-API. We typically track N-API-specific issues in the abi-stable-node repo. Issues can also be opened in the ordinary nodejs/node repo, as well, with the n-api tag but abi-stable-node is really only used for discussions about N-API. There is official documentation for N-API in the node docs. We did mention the c++ wrapper for N-API which provides a very Nan-like interface and lives in a separate repo from nodejs/node (similar to the Nan shipping story). This can be used to bring N-API compatibility to versions of node without N-API, as well. |
Hello, sorry for the silence. I've been on the job search and recently hurt my back 😱 I'm definitely interested in pushing this forward. We have some big changes landing in LibSass very soon which will results in node-sass@v5 and v6. I would N-API to land in node-sass@v5. I'll create a meta issue documenting the plan for v5 and v6 this weekend. I'll be sure to cc @boingoing |
@boingoing I have a couple questions around N-API and Web Assembly. We've started looking into shipping node-sass as a WASM module for supported environments. However it appears our usage of libuv to schedule async execution of libsass could be a blocker. I've been reading over the recent updates in N-API around C++ Promise and AsyncWorker support and I'm curious as to whether
|
Now that Node 10 has been released, N-API is no longer experimental. So if WebAssembly is not the way to go, maybe we should give N-API a try. @xzyfer Regarding your question on |
@nschonni also mentioned using https://github.com/nodejs/node-addon-api as a N-API shim for older versions of Node. This is certainly a step towards WASM. |
For those following along at home I've picked up work on this again in #2440. It's getting pretty close (I think). I'm hoping to get N-API support out in a v5 beta. |
As previous, It seem the best time to migrate is around the corner. Node.js remove version dependencies |
Still experimental with 8, but it looks like they're trying to integrate the Nan approach (with some other stuff) into the platform https://nodejs.org/api/n-api.html
/cc @mgol and @saper who were talking about this in Slack too
The text was updated successfully, but these errors were encountered: