Open agniokas opened 4 weeks ago
You'll have to make a personal fork of curlconverter, sorry. I want to keep the interface simple.
Not exactly what you're asking, I but I tried making it look for the wasm files in a relative directory #649 but that doesn't work for https://curlconverter.com/ because you can open it like https://curlconverter.com/go/ (for example), which requests the wasm from https://curlconverter.com/go/tree-sitter.wasm which wouldn't work, unless we copy the wasm to each directory but I don't want to duplicate it like that...
Another alternative would be replacing tree-sitter with https://github.com/withfig/lezer-bash
There is a problem, when trying to host curlconverter in nextjs project, which is aknowleged by tree-sitter. It also has a solution (see below), however, i am not able to use it, i assume because, when curl converter initializes Parser, it overrides locateFunction. For the moment, i relocate tree-sitter.wasm files to each page in .next/static/chunk/pages, but i would like a nicer solution to this. Is there a way?
For server side frameworks like NextJS, this can be tricky as pages are often served from a path such as http://localhost:3000/_next/static/chunks/pages/index.js. The loader will therefore look for the wasm file at http://localhost:3000/_next/static/chunks/pages/tree-sitter.wasm. The solution is to pass a locateFile function in the moduleOptions argument to Parser.init():