Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
README.md update
  • Loading branch information
BaderBC committed Jul 8, 2024
commit 6cc76c8c0c00fddaf8f09ec607a127d639bb96d8
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ rust({
//
// This is useful for libraries which want to export TypeScript types.
typescriptDeclarationDir: null,

// Whether to transpile the wasm output to JS using wasm2js tool.
// Note that this option may slow down your application.
//
// This requires `inlineWasm: true`, `directExports: true` and `synchronous: true`.
transpileToJS: false,
},
})
```
Expand All @@ -225,6 +231,12 @@ rust({

This is necessary because extension files are put into a separate URL namespace, so you must use `chrome.runtime.getURL` to get the correct URL.

If you want to use inline wasm with extensions, the browser will treat it as remote wasm execution and may block it.
To avoid this, you can use the `transpileToJS` option, which will transpile wasm to JS.
Keep in mind that this option may slow down your extension.

```js

### Environment variables

You can use the following environment variables to customize some aspects of this plugin:
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ module.exports = function rust(options = {}) {
if (options.inlineWasm == null) {
options.inlineWasm = false;
}

if (options.verbose == null) {
options.verbose = false;
}
Expand All @@ -675,6 +675,10 @@ module.exports = function rust(options = {}) {
if (options.experimental.synchronous == null) {
options.experimental.synchronous = false;
}

if(options.experimental.transpileToJS == null) {
options.experimental.transpileToJS = false;
}

return {
name: "rust",
Expand Down