From 5124bac95211dfde6311dc201cc8d8e1eebf80dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Mon, 18 Sep 2023 15:24:26 +0200 Subject: [PATCH 1/2] Readd troubloeshooting with wasm --- docs/sdk/getting_started.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/sdk/getting_started.md b/docs/sdk/getting_started.md index 5e8854a..db2cc34 100644 --- a/docs/sdk/getting_started.md +++ b/docs/sdk/getting_started.md @@ -67,9 +67,23 @@ init().then((instance) => { You can take a look at [this template](https://github.com/zama-ai/fhevmjs-react-template) for an example using Vite, React and TypeScript. -#### Troubleshooting +### Troubleshooting -##### Issue with importing ESM version +#### Webpack: "Module not found: Error: Can't resolve 'tfhe_bg.wasm'" + +In the codebase, there is a `new URL('tfhe_bg.wasm')` which triggers a resolve by Webpack. If yo +u encounter an issue, you can add a fallback for this file by adding a resolve configuration in y +our `webpack.config.js`: + +```javascript + resolve: { + fallback: { + 'tfhe_bg.wasm': require.resolve('tfhe/tfhe_bg.wasm'), + }, + }, +``` + +#### Issue with importing ESM version With a bundler such as Webpack or Rollup, imports will be replaced with the version mentioned in the `"browser"` field of the `package.json`. If you encounter issue with typing, you can use this [tsconfig.json](https://github.com/zama-ai/fhevmjs-react-template/blob/main/tsconfig.json) using TypeScript 5. @@ -80,7 +94,7 @@ If you encounter any other issue, you can force import of the browser package. import { initFhevm, createInstance } from 'fhevmjs/web'; ``` -##### Use bundled version +#### Use bundled version If you have an issue with bundling the library (for example with some SSR framework), you can use the prebundled version available in `fhevmjs/bundle`. Just embed the library with a `