ast-grep(sg) is a lightning fast and user friendly tool for code searching, linting, rewriting at large scale.
This is the website source for ast-grep!
Unfortunately wasm-pack does not support compiling C dependency with stdlib.
We have to use emcc.
We have to use web-tree-sitter
To setup:
wasm-pack build --target web
. This will build the wasm in pkg
folderpnpm install
pnpm dev
cd website/.vitepress/cache/deps
ln -s ../../../../pkg/ast_grep_wasm_bg.wasm
cd ../../../..
You need to upgrade tree-sitter to the latest version.
You also need to copy the tree-sitter.wasm to the public directory because vite's building convention.
You will usually have weird error messages like tree-sitter.wasm
is not found
or having wrong LinkError
of undefined methods like exit
.
emcc setup is not used any more
~~
rustup target add wasm32-unknown-emscripten
https://github.com/MolotovCherry/tree-sitter-wasm https://github.com/rustwasm/wasm-pack/issues/741 https://stackoverflow.com/questions/67474533/error-in-compiling-rust-into-webassembly-using-emscripten-on-windows https://github.com/rustwasm/wasm-pack/blob/master/src/command/build.rs ~~
It requires tree-sitter.wasm and tree-sitter-{lang}.wasm available in public directory.
Language specific wasm must be built with the same emcc version of the tree-sitter.wasm.
Mismatching emcc version will raise RuntimeError.