ikatyang / tree-sitter-yaml

YAML grammar for tree-sitter
https://ikatyang.github.io/tree-sitter-yaml/
MIT License
93 stars 38 forks source link

Support for Node 10.x.y #7

Closed char0n closed 3 years ago

char0n commented 3 years ago

Hi @ikatyang,

I've just noticed that the grammar.js is using Object.fromEntries function which is not part of node 10. As node@10 is still in maintenance LTS, would be great if this YAML grammar supported it.

Would you be open to replace Object.fromEntries and possibly other non node@10 functions to other implementations?

Thanks

ikatyang commented 3 years ago

Hi, the grammar.js is considered a dev-only file, which should only be used in Node 12+, though I didn't mention it anywhere. The tree-sitter-yaml npm package only guarantees that its node binding will work, which is the case for Node 10. If you'd like to use grammar.js in Node 10, I'd recommend you to use it via @babel/register and/or @babel/polyfill, for example:

NODE_OPTIONS='--require "path/to/babel-polyfill" --require "path/to/babel-register"' tree-sitter generate

or use Docker/nvm to achieve this goal.

char0n commented 3 years ago

Sure, thanks; fortunately I'm using babel and your proposed solution works. Might be problem for people without babel though.

Thanks!