@mlc-ai/web-xgrammar
v0.1.0
Published
This folder contains the source code and emcc bindings for compiling XGrammar to Javascript/Typescript via [emscripten](https://emscripten.org/).
Downloads
240
Readme
web-xgrammar
This folder contains the source code and emcc bindings for compiling XGrammar to Javascript/Typescript via emscripten.
Build from source
Install emscripten. It is an LLVM-based compiler that compiles C/C++ source code to WebAssembly.
- Follow the installation instruction to install the latest emsdk.
- Source
emsdk_env.sh
bysource /path/to/emsdk_env.sh
, so thatemcc
is reachable from PATH and the commandemcc
works. - We can verify the successful installation by trying out
emcc
in the terminal.
Modify the content of
cmake/config.cmake
to beweb/config.cmake
.Run the following
source /path/to/emsdk_env.sh npm install npm run build
Example
To try out the test webpage, run the following
cd example
npm install
npm start
Testing
For testing in node
environment, run:
npm test