You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Debt] Make tvmjs an npm package, simplify build from source (#570)
In the past, building WebLLM from source could be cumbersome as users
needed to build TVMjs by themselves by setting up `emscripten` and
running `./scripts/prep_deps.sh`, while TVMjs is, most of the time, not
where the users may want to modify the code.
This PR modifies `package.json`'s `"tvmjs": "file:./tvm_home/web",` to
`"@mlc-ai/tvmjs": "0.18.0-dev0",`, as we uploaded TVMjs as an npm
package, so users no longer need to run `./scripts/prep_deps.sh`.
We update `README.md`'s directions for building from source accordingly.
Users can still build TVMjs from source with similar steps as before, as
described in the `README.md`.
Note that an extra step required by this change is addressing `"import
require$$4 from 'ws'"` and `const WebSocket = require(\"ws\")` in
`lib/index.js` and `lib/index.js.map` after `npm run build`. We take
care of it in `cleanup-idnex-js.sh` by following similar measures for
`perf_hooks`.
Copy file name to clipboardExpand all lines: README.md
+46-20Lines changed: 46 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -360,30 +360,56 @@ see `webllm.prebuiltAppConfig`.
360
360
361
361
## Build WebLLM Package From Source
362
362
363
-
NOTE: you don't need to build by yourself unless you would
364
-
like to change the WebLLM package. To simply use the npm, follow [Get Started](#get-started) or any of the [examples](examples) instead.
363
+
NOTE: you don't need to build from source unless you would like to modify the WebLLM package.
364
+
To use the npm, simply follow [Get Started](#get-started) or any of the [examples](examples) instead.
365
365
366
-
WebLLM package is a web runtime designed for [MLC LLM](https://github.com/mlc-ai/mlc-llm).
366
+
To build from source, simply run:
367
367
368
-
1. Install all the prerequisites for compilation:
368
+
```bash
369
+
npm install
370
+
npm run build
371
+
```
372
+
373
+
Then, to test the effects of your code change in an example, inside `examples/get-started/package.json`, change from `"@mlc-ai/web-llm": "^0.2.65"` to `"@mlc-ai/web-llm": ../..`.
374
+
375
+
Then run:
376
+
377
+
```bash
378
+
cd examples/get-started
379
+
npm install
380
+
npm start
381
+
```
382
+
383
+
Note that sometimes you would need to switch between `file:../..` and `../..` to trigger npm to recognize new changes. In the worst case, you can run:
WebLLM's runtime largely depends on TVMjs: https://github.com/apache/tvm/tree/main/web
395
+
396
+
While it is also available as an npm package: https://www.npmjs.com/package/@mlc-ai/web-runtime, you can build it from source if needed by following the steps below.
397
+
398
+
1. Install [emscripten](https://emscripten.org). It is an LLVM-based compiler that compiles C/C++ source code to WebAssembly.
399
+
- Follow the [installation instruction](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended) to install the latest emsdk.
400
+
- Source `emsdk_env.sh` by `source path/to/emsdk_env.sh`, so that `emcc` is reachable from PATH and the command `emcc` works.
401
+
402
+
We can verify the successful installation by trying out `emcc` terminal.
369
403
370
-
1.[emscripten](https://emscripten.org). It is an LLVM-based compiler that compiles C/C++ source code to WebAssembly.
371
-
- Follow the [installation instruction](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended) to install the latest emsdk.
372
-
- Source `emsdk_env.sh` by `source path/to/emsdk_env.sh`, so that `emcc` is reachable from PATH and the command `emcc` works.
373
-
2. Install jekyll by following the [official guides](https://jekyllrb.com/docs/installation/). It is the package we use for website. This is not needed if you're using nextjs (see next-simple-chat in the examples).
374
-
3. Install jekyll-remote-theme by command. Try [gem mirror](https://gems.ruby-china.com/) if install blocked.
375
-
`shell
376
-
gem install jekyll-remote-theme
377
-
`
378
-
We can verify the successful installation by trying out `emcc` and `jekyll` in terminal, respectively.
404
+
Note: We recently found that using the latest `emcc` version may run into issues during runtime. Use `./emsdk install 3.1.56` instead of `./emsdk install latest` for now as a workaround. The error may look like
function="proc_exit": function import requires a callable
408
+
```
379
409
380
-
Note: We recently found that using the latest `emcc` version may run into issues during runtime. Use `./emsdk install 3.1.56` instead of `./emsdk install latest` for now as a workaround. The error may look like
0 commit comments