Closed dherman closed 6 years ago
NAPI is stable in v10, which becomes LTS this fall. Is this another viable alternative or just something that might ease the implementation?
If there are features in neon that currently cannot be supported by NAPI, what about moving them behind a feature flag?
@kjvalencik These are really good questions. You're right that it's about time for us to start figuring out what our approach to NAPI is going to be. So I guess here are some of the questions we have to answer:
I bet RegExp etc is not particularly important, and if it is important, we can advocate for putting them into N-API.
I bet the async stuff gives us everything we need to make the UV threadpool available, but I'll investigate.
For transition strategy, my guess is all of this will take enough time that the question will become moot, but we can discuss tactics if/when necessary.
Classes might be a bigger challenge. I guess @matklad doesn't really like the class feature, but I do. :) Let me dig around and see what that would entail.
I should say, @matklad made good points, and if the only thing blocking us adopting N-API was that the classes design doesn't fit it, I'm definitely open to revisiting the classes design. The more fundamental feature that we have to support one way or another, though, is the ability to let a JS object own a Rust data structure.
OK so the place to look is the object wrapping APIs. I'll keep investigating!
I think napi_create_async_work
is the equivalent of uv_queue_work
? So that’d cover the existing Task implementation using the libuv threadpool. It looks like these functions cover async handles (what’s needed for the Rust thread RFC): https://nodejs.org/api/n-api.html#n_api_custom_asynchronous_operations
Here's my proposed course of action: we know we need to explore the N-API backend regardless, and since it sounds like N-API's ABI stability might make for a simpler story than dynamic linking the Neon runtime, we should:
Seem reasonable?
This RFC proposes a strategy for making Neon pre-builds feasible for libraries. This way Neon users can ship libraries whose downstream consumers can be completely unaware of the use of Rust and Neon. In other words, it makes it more tractable to ship native libraries written in Neon with zero requirements for what software their consumers have installed on their machine.
Rendered