question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project don't work with chrome's new Manifest v3, can be easily fixed

See original GitHub issue

In 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Lusitocommented, Jul 14, 2021

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:

const action = browser.action || browser.browserAction;
1reaction
Lusitocommented, Mar 13, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found