-
Notifications
You must be signed in to change notification settings - Fork 119
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
Invalid language object with tree-sitter v0.21 - caused by NAPI? #193
Comments
Same here. All languages I've tested (JS, TS and TSX) failed to load with "Invalid language object". Downgrading to 0.20.6 solved the problem. |
With node-tree-sitter 0.21.0, the bindings switch to NAPI instead of NaN #190, so you need to change the binding.cc file of all the languages you want to use with node-tree-sitter 0.21.0+ to be a NAPI binding.cc file. If you have just a normal binding.cc right now then you can update your tree-sitter generate If you've made changes to your language's binding.cc file previously, you will have to port those changes to NAPI after re-generating the file. This command also now generates more bindings for other programming languages, by the way, which you may or may not want to keep. This has been done for some languages in the tree-sitter org, you can see how it was done for tree-sitter-python or for tree-sitter-bash. Like I said, it's just re-running By the way, with 0.21 there's also a handful of backwards incompatible changes to make the Node and Wasm bindings interchangeable (crazy, but they weren't before), namely in Node |
related to this issue: tree-sitter/node-tree-sitter#193 (comment)
I started creating a module that should allow loading older grammars using the new node-tree-sitter as a stop-gap solution until they all get updated https://github.com/segevfiner/node-tree-sitter-compat, haven't published it to npm just yet, but I likely will. |
I tried updating to tree-sitter 0.21 for our project https://github.com/dodona-edu/dolos/tree/main/parsers which builds a collection of parsers to be used in our tool. We do this by importing each parser as a submodule and using a simple
binding.gyp
including the gyp-files of each parser.This worked fine with the node package of tree-sitter 0.20.6. With the latest release 0.21.0, building using
node-gyp
succeeds, but actually using the parser fails.Consider the following snippet:
Which is thrown on line 338 in
index.js
, calling thesetLanguage
function from the nativetree-sitter_runtime
binding:node-tree-sitter/index.js
Lines 329 to 345 in 2bdc76a
I noticed in the commits between v0.20.6...v0.21.0 that the bindings were changed to NAPI instead of Node. I guess this might be caused by this refactor?
Does anything need to be changed to the parsers themselves to work with NAPI? Is this something that I could fix in my
binding.gyp
or will this require changes in the parsers?The text was updated successfully, but these errors were encountered: