Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox build for Backpack #1496

Open
beeman opened this issue Nov 15, 2022 · 4 comments
Open

Firefox build for Backpack #1496

beeman opened this issue Nov 15, 2022 · 4 comments
Assignees

Comments

@beeman
Copy link

beeman commented Nov 15, 2022

I would love to see a Firefox build for Backpack. Happy to contribute to make this happen

@armaniferrante
Copy link
Member

Would love some help with this @beeman!

@beeman
Copy link
Author

beeman commented Nov 21, 2022

I've tried to get it running in Firefox and it looks there are a few issues.

1: Firefox doesn't support Manifest v3 yet, but there is a developer preview and it will be a matter of time for that to land.

2: The next blocker is the lack of background service workers in Firefox. To install the extension anyway, you can change this in the manifest.json:

   "background": {
-    "service_worker": "background.js",
-    "type": "module"
+    "scripts": ["background.js"]
   },
  1. Once its installed, opening the extension leads to this message, coming from <LedgerIframe /> who is trying to access navigator.serviceWorker:

image

The fix for this seems simple enough, conditionally loading that LedgerIframe when the service worker is enabled.

const LedgerIframe = () => {
  if (typeof serviceWorker in navigator) {
    return <LoadLedgerIframe />;
  }
  return null;
};

With that in place, the extension loads and seems to work as expected! 🥳

image

image

In terms of next steps, I'm happy to submit a PR that conditionally loads the LedgerIframe if the service worker is found.

With regards to the other change, it should be simple enough to patch the manifest.json just before creating the Firefox build, so I think that could be done in a build script.

@armaniferrante
Copy link
Member

Build script sounds great!

Unfortunately, that conditional iframe load will break ledgers, and so we need to also add back in the ledger injection somehow.

One solution is to mirror that conditional step, but in the background script, and inject there (which is what we used to do when we were using manifest v2). The PR that migrated from v2 -> v3 can be found here. Feel free to use this for inspiration (or if you have a better solution, even better!).

@wentokay
Copy link
Collaborator

wentokay commented Apr 10, 2023

Resurfacing this issue and taking a quick look at it while some other stuff is building

This are the errors that would need addressing after running npx web-ext lint --source-dir ./build right now

Screenshot 2023-04-10 at 20 06 25

TODO


After that all references to chrome. would need to use the browser. API

I'll update this thread as any progress is made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants