Open eknathyadav opened 4 months ago
There is no way currently, you would have to fork the repo and change these two lines
to something like
await Parser.init({
locateFile(scriptName: string, scriptDirectory: string) {
return '/some/other/path/tree-sitter.wasm';
},
});
const Bash = await Parser.Language.load("/some/other/path/tree-sitter-bash.wasm");
The reason a way to pass these file names hasn't been implemented is so the normal usecase is simpler, you can just do
import * as curlconverter from 'curlconverter';
curlconverter.toPython('curl example.com');
instead of having to do
import * as curlconverterInit from 'curlconverter';
const curlconverter = curlconverterInit();
curlconverter.toPython('curl example.com');
and there's as little distinction between the native version of the library and the WASM version of the library, the only difference is just this line in package.json
I'm bumping an old issue here, but the way this is at the moment, it works fine if your website lives at the root of your domain (e.g: https://curlconverter.com ) but if your website lives in a subdirectory (e.g: https://username.github.io/my-static-site ) the library tries to load tree-sitter-bash.wasm
from
https://username.github.io/tree-sitter-bash.wasm instead of https://username.github.io/my-static-site/tree-sitter-bash.wasm
This makes it impossible to use the library in a site that is deployed to a subdirectory.
The other thing I noticed trying to use this in a browser is that although the docs say tree-sitter.wasm
is also loaded from the root, that one seems to actually be loaded relative to the js file that tries to load it. So if my js bundle is https://username.github.io/my-static-site/js/app.js then tree-sitter.wasm
will be loaded from https://username.github.io/my-static-site/js/tree-sitter.wasm
It would be useful if those two worked the same way, but the inconsistency is less of an issue.
Dear Team,
Is there any way I could customize the path? Rather than considering the server root path (i.e http://127.0.0.1:8000/tree-sitter-bash.wasm) for
'tree-sitter-bash.wasm
file, is there any possibility that I can specify my customized path? The thing is I don't want to serve that file from the server root path.