docs(web): add instructions for Vite

This commit is contained in:
Felix Roos 2023-12-21 09:44:44 +01:00 committed by Amaan Qureshi
parent 07aaf2322e
commit 6c4a50a9c7
2 changed files with 111 additions and 96 deletions

View file

@ -27,7 +27,22 @@ const Parser = require('web-tree-sitter');
Parser.init().then(() => { /* the library is ready */ });
```
You can use this module with [deno](https://deno.land/):
or Vite:
```js
import Parser from 'web-tree-sitter';
Parser.init().then(() => { /* the library is ready */ });
```
With Vite, you also need to make sure your server provides the `tree-sitter.wasm`
file to your `public` directory. You can do this automatically with a `postinstall`
[script](https://docs.npmjs.com/cli/v10/using-npm/scripts) in your `package.json`:
```js
"postinstall": "cp node_modules/web-tree-sitter/tree-sitter.wasm public"
```
You can also use this module with [deno](https://deno.land/):
```js
import Parser from "npm:web-tree-sitter";