node-tree-sitter icon indicating copy to clipboard operation
node-tree-sitter copied to clipboard

N-API version of bindings

Open drom opened this issue 7 years ago • 4 comments

N-API is a new, more portable way of creating Nodejs bindings : https://nodejs.org/api/n-api.html Does it make sense porting node-tree-sitter from NAN to NAPI ?

drom avatar Nov 26 '18 21:11 drom

The main benefit of NAPI is no need for parser recompilation when running on node 6, 8, 10, 11+ I have to use Node 8 everywhere because Atom using Node 8, and I want to use parser inside and outside of the Atom.

drom avatar Mar 02 '19 00:03 drom

I have the same problems in Visual Studio Code. It's really tedious use it in vscode :(

qarlosalberto avatar May 17 '20 19:05 qarlosalberto

there is apparently a napi branch in this repo which I was able to build but I am using the query API which seems to have been added after. I will reply again if I add NAPI bindings for the query API in a fork

EDIT: it's not done but here in case it helps anyone: https://github.com/michaelBelousov/node-tree-sitter/tree/napi-with-query-api

MichaelBelousov avatar Mar 06 '22 04:03 MichaelBelousov

can confirm my fork works for my parser and query API usage, and I've made a format for NAPI-compiled languages to be unwrapped and tested with a tiny alternate NAPI-bindings for tree-sitter-sql.

This works very well for me when developing a visual studio code extension. I use prebuildify to build against electron and (I haven't tried cross-compiling yet) for multiple platforms. If someone else needs this, I can put the work into a pull request targeting the napi branch in this repository. My fork merged the tip of master as well so it is a more up-to-date version of the napi branch here.

MichaelBelousov avatar Mar 08 '22 00:03 MichaelBelousov