-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add compatibility mode for Firefox #644
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! FF support is something people have asked for.
CI doesn't pass yet, I'll be happy to merge this once it does 👍
for the time being I am using a vite plugin to manually modify the manifest.json. Apart from removing |
I took a quick look at this, as I've been trying to work on porting an extension from Chrome to Firefox. I don't think the linting issues are a big problem, but the bigger issue is that a dev build doesn't work on Firefox. A background page cannot import from localhost because of CSP, and CSP doesn't allow localhost in MV3. @laptou already left a comment about this in the code. I worked around the dev issue with vite build --watch --sourcemap instead of vite and added a separate script dev:firefox in my example extension. Not particularly beautiful. I should be able to provide my view on the small changes to the linting issues if needed. |
@thilinaaligent Could you possibly share the details of the vite plugin and configuration you're using? |
As mentioned by @jhholm, this PR isn't fully complete because I haven't figured out how to make hot reloading work in Firefox. Background pages have different APIs and capabilities from service workers, so it will require some more work to get this fully baked. I'm not sure when I will get around to writing a background page though, so if anyone else wants to take it on, that would be much appreciated. |
@laptou wanting to take this on. Can I get some guidance on your idea? |
@kjaonline What kind of guidance are you looking for? The main thing that is needed to make this PR complete in my opinion is an implementation of hot reloading that is compatible with Firefox's background pages. This requires looking at how the HMR service worker is implemented for Chrome and addressing the differences between the technologies (which are largely differences in the restrictions on how scripts can be loaded) |
Great job. Is anyone still working on this pull request to move it forward? |
@IamFive I've been occupied with other stuff for a while; if you would like to fix the CI stuff it's all yours |
@laptou I just created a PR to this fork that fixes the CI. I didn't attempt to fix the HMR issue because that isn't really important to me. Let's just get this PR merged first. |
Closing in favor of #776 which build on this PR. Thanks for putting it together! |
Firefox support has landed on NPM https://www.npmjs.com/package/@crxjs/vite-plugin/v/2.0.0-beta.19 |
I wanted to be able to use this extension to create MV3 extensions for both Chrome and Firefox. They each implement MV3 a little differently; in particular:
use_dynamic_url
inweb_accessible_resources
because it the resource URLs in Firefox are always dynamicSo I added a new config option called
browser
that can be either"firefox"
or"chrome"
, and if it is"firefox"
, then the emittedmanifest.json
will respect these differences so the extension can be loaded in Firefox.There are some parts that don't work very well yet -- in particular, hot module reloading does not work in Firefox because the service worker generated by this extension does not work as a background page.