Skip to content

Commit

Permalink
Merge pull request #39 from zama-ai/fix/docs-and-package
Browse files Browse the repository at this point in the history
Fix/docs and package
  • Loading branch information
immortal-tofu authored Sep 18, 2023
2 parents a205e1b + 64fffed commit 3eae222
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions docs/sdk/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 `<script>` tag and you're good to go.

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
".": {
"import": "./lib/web.js",
"require": "./lib/node.cjs"
},
"./web": {
"import": "./lib/web.js",
"require": "./lib/web.js"
}
},
"scripts": {
Expand Down

0 comments on commit 3eae222

Please sign in to comment.