Skip to content

Commit

Permalink
docs(wasm): add information for web bundlers
Browse files Browse the repository at this point in the history
This adds the steps that might be needed when using the web
wasm API with parallel support for rayon.

These are important to document, otherwise the user might not be able to
make his project work.
  • Loading branch information
tmontaigu committed Nov 28, 2024
1 parent 04917d3 commit b669ba1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tfhe/docs/guides/js_on_wasm_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ The compiled WASM packages are located in `tfhe/pkg`.
The browser API and the Node.js API are available as npm packages. Using `npm i tfhe` for the browser API and `npm i node-tfhe` for the Node.js API.
{% endhint %}

### Extra steps for web bundlers

When using the browser API _with parallelism_, some extra step might be needed depending on the bundler used:

#### Usage with Webpack

If you're using Webpack v5 (version >= 5.25.1), you don't need to do anything special, as it already supports [bundling Workers](https://webpack.js.org/guides/web-workers/) out of the box.

#### Usage with Parcel

Parcel v2 also recognises the used syntax and works out of the box.

#### Usage with Rollup

For Rollup, you'll need [`@surma/rollup-plugin-off-main-thread`](https://github.com/surma/rollup-plugin-off-main-thread) plugin (version >= 2.1.0) which brings the same functionality and was tested with this crate.

Alternatively, you can use [Vite](https://vitejs.dev/) which has necessary plugins built-in.

(Taken from [RReverser/wasm-bindgen-rayon](https://github.com/RReverser/wasm-bindgen-rayon?tab=readme-ov-file#usage-with-various-bundlers))

## Using the JS on WASM API

**TFHE-rs** uses WASM to provide a JavaScript (JS) binding to the client-side primitives, like key generation and encryption within the Boolean and shortint modules.
Expand Down

0 comments on commit b669ba1

Please sign in to comment.