45bbd8d68d
* Update `action` sample * Update `alarms` sample * Update `bookmarks` sample * Update `browsingData` sample * Update `contentSettings` sample * Update `cookies/cookie-clearer` sample * Update `debugger` sample * Update wasm functional sample * Update `functional/cookbook.geolocation-contentscript` sample * Update `cookbook.geolocation-offscreen` sample * Update `cookbook.geolocation-popup` sample * Update `cookbook.offscreen-clipboard-write` sample * Update `cookbook.offscreen-dom` sample * Fix browsingData description * Fix bookmarks description * Update offscreen document descriptions * Update descriptions * Update browsingData description * Update descriptions for all api samples * Update descriptions for cookbook samples * Update api-samples/browsingData/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/action/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/contextMenus/basic/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/cookies/cookie-clearer/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/debugger/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update functional-samples/sample.favicon-cs/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update functional-samples/cookbook.sidepanel-site-specific/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/omnibox/new-tab-search/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/devtools/inspectedWindow/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/override/blank_ntp/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Apply suggestions from code review Co-authored-by: Joe Medley <jmedley@google.com> * Update wasm samples description * Update description * Update functional-samples/sample.co2meter/manifest.json Co-authored-by: Joe Medley <jmedley@google.com> * Apply suggestions from code review --------- Co-authored-by: Joe Medley <jmedley@google.com> Co-authored-by: Oliver Dunk <oliver@oliverdunk.com> |
||
---|---|---|
.. | ||
wasm | ||
README.md | ||
background.js | ||
manifest.json |
README.md
Using WASM as a module in Manifest V3
This recipe shows how to use WASM in Manifest V3.
To load WASM in Manifest V3, we need to use the wasm-unsafe-eval
CSP directive (Content Security Policy).
Overview
Running this extension
- Clone this repository.
- Load this directory in Chrome as an unpacked extension.
- Find the extension named "WASM Load Example - Helloworld" and inspect the service worker.
You will see the following output:
[from wasm] Inited.
[from wasm] Hello World!
[from wasm] Hello John
Build WASM locally
We have already built the WASM file for you. If you want to build it yourself, follow the steps below.
-
Install Rust.
-
Install wasm-pack.
cargo install wasm-pack
-
Build WASM.
cd wasm wasm-pack build --target web
Implementation Notes
- To import the script generated by
wasm-pack
, we need to declare the service worker as an ES Module.
// manifest.json
...
"background": {
"service_worker": "background.js",
+ "type": "module"
},
...