-
Install wasm-pack:
cargo install wasm-pack -
Go to
/wasm_modand runbuild.bat.
It will compile the.wasmmodule and.js-wrapper for it and put them in theextension/js/wasm -
Go to Chrome extensions page and load unpacked extension from
/extension
extension/js/content.jsdemonstrates how to load wasm into the content script
Important: in the content script, the module can only be loaded for those sites whose Content Security Policy does not prohibit itextension/js/background.jsdemonstrates how to load wasm into the background worker script- For
wasm-packalways use--target web manifest.json:- To load the wasm module into the content script, you should list
.wasmand corresponding.jsin theweb_accessible_resources.resourcessection of manifest - To load the wasm module into the background worker script, you should specify
wasm-unsafe-evalin thecontent_security_policy.extension_pagessection of manifest
- To load the wasm module into the content script, you should list
- Chrome 114 (extension manifest v3)
- Rust 1.70 (edition 2021)
- wasm-bindgen 0.2.86
- wasm-pack 0.11.1