-
Notifications
You must be signed in to change notification settings - Fork 29
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
Document how to use from Node.js/browser #725
Comments
Hello, I think you should be able to use the demo app as an example, as the playground is nothing special in the end. Bootstrap a simple React app (or whatnot). Then you can just import Topiary functions exported as WASM: topiary/web-playground/src/App.tsx Lines 5 to 9 in b4a8426
You still need to make this topiary/.github/workflows/ci.yml Lines 48 to 56 in b4a8426
The Lines 139 to 163 in b4a8426
There's no particular hidden coupling, to the best of my knowledge, between Topiary and the web playground, so it should indeed be reasonably straightforward to use Topiary from your own web app! |
Thanks, I should have been more specific: my actual use-case is that I want to use Topiary as a library from a Node.js program. So you're quite right: I could probably work out how to use it in a web app from the example. But I felt that it would take a lot of effort to work out how to use it as a Node.js library. But I'll take a look at your explanation and see if I can transpose what you say from browser to Node. |
I'm not well versed in the Node ecosystem, but then I think the important bit is that |
Not expecting you to do anything @yannham, just noting I tried a non-nix build (as I'd like ideally to have this as part of a plain npm build) and had the following problem: $ cargo build -p topiary-playground --no-default-features --target wasm32-unknown-unknown
cargo:warning=/home/rrt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/./alloc.h:9:10: fatal error: 'stdio.h' file not found
cargo:warning= 9 | #include <stdio.h>
cargo:warning= | ^~~~~~~~~
cargo:warning=1 error generated. In other words, while building tree-sitter, the C compiler couldn't find |
It's strange. From what I recall, |
Thanks, both. Getting this working is not a high priority for me at present (I am content to invoke topiary via the command line from my Node program), but I will want to get it working at some point. |
I would like to use Topiary (compiled to WASM) as a library in a Node.js project.
This should clearly be possible, but it's not obvious how to separate Topiary from e.g. the demo web app.
Thanks for Topiary! I was easily able to add a formatter for a new language.
The text was updated successfully, but these errors were encountered: