jeff-hykin/experimental-tree-sitter

Cross platform support

Closed this issue · 4 comments

Use tree-sitter wasm to get cross platform support. (Done)

I'm mostly just making this issue to let you guys know about this. @EvgeniyPeshkov @georgewfraser Feel free to pull this into your own repo's its not super complex, I only made my own so that I could test and make changes easier. Everything in this repo is based on @EvgeniyPeshkov 's repo.

Thanks for showing how to do this! I've updated https://github.com/georgewfraser/vscode-tree-sitter to use WASM so it supports all platforms now. I did some JS profiling and verified it has similar performance.

Hello @jeff-hykin , Thank you so much for your contribution.
WASM solution works perfectly. I've embedded it into the extension, now it works on all platforms.

I would like to share with you my workaround, that I've just finished. Maybe it will be helpful somewhere else.
It utilizes npmi. The idea was to publish version, pre-compiled for Windows, where it's hard to install build tools. And let extension recompile native modules on other OSes, where it's very likely, that g++ is already installed.

Your solution is waaay better. Thank you very much again.

One thing I can't grasp about this, is that you guys don't seem to need to copy the wasm files to the out folder? I needed to do that to make it work, but i'm building a language server, so it might be rooted in that. elm-tooling/elm-language-server@f6f1966#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R37

The other problem at the moment is that descendantsOfType isn't implemented for wasm. Really surprised me, as I would have thought that your addons would use it this too. tree-sitter/tree-sitter#349 (comment)

That's a shame, I didn't know wasm was missing support for anything. To be honest though I don't know what the descendantsOfType is.

As for the /out folder, I think you can access the outside files, I think the path just needs to be relative from the /out folder. If it says it doesn't exist I'd try printing out the pwd or cwd to see if its a pathing issue.