Project don't work with chrome's new Manifest v3, can be easily fixed
See original GitHub issueIn manifest v3 background workers are run as service workers. This means they don’t have access to window. https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/#service-workers
The if-statement checking if window is present ruins it for the background script
// if not in a browser, assume we're in a test, return a dummy
if (typeof window === "undefined") exports.browser = {};
else exports.browser = require("webextension-polyfill");
If I just remove the if-else this library seems to be working fine for Manifest V3.
🙏 Please remove it, for testing jsdom can be used to fake window/document stuff…
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
More details on the transition to Manifest V3
In June 2023, the Chrome Web Store will no longer allow Manifest V2 items to be published with visibility set to Public.
Read more >1173354 - wasm does not work in extensions manifest v3
My Chrome extension is written in Rust and compiled to WebAssembly. It works well with manifest v2 wasm-eval enabled. That is not working...
Read more >Google's Manifest V3 Still Hurts Privacy, Security, and Innovation
According to Google, Manifest V3 will improve privacy, security and performance. We fundamentally disagree. According to Google, Manifest V3 ...
Read more >Chrome extension manifest v3 Content Security Policy
I updated the code with the offending line. It is the appendchild part that is blocked because V3 does not allow for injection...
Read more >What is Manifest V3 and why is Google pestering me about it?
This ephemerality allows Chrome to lower overall system resource utilization since the browser can start up and tear down service workers as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This polyfill adds the types for browser.action, but keep in mind, that firefox does not actually have browser.action implemented yet. So you should check if browser.action exists if you want to support browsers other than chrome. For example:
@AhsanAyaz Since then we have moved to
@types/webextension-polyfill, so this package no longer provides any code.If you have switched to
@types/webextension-polyfill, the only place this might be caused is in the actual code repo: https://github.com/mozilla/webextension-polyfill.