-
Notifications
You must be signed in to change notification settings - Fork 188
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
Don't use webextension-polyfill
by default
#784
Comments
Does the default build target for |
Good call out... I'm going to say no for now. MV2 for Firefox is a better user experience and there are no problems with dev mode (MV3 CSP blocks loading scripts from localhost). So I'm a little hesitant to switch the default. Also, I don't believe Firefox MV3 is a blocker for this specific issue. The polyfill isn't doing anything to Firefox now that promises are supported by all browsers by default. MV2 or MV3, for Firefox, doesn't matter. Do you want to switch to MV3 by default? If so, what are your reasons @aiktb? Maybe we continue this conversation on #230 |
mozilla/webextension-polyfill#210
|
Perfect, thanks for sharing! I'm planning on manually polyfill-ing things like this so it just works. If you notice anything else, please share! |
Alright, I've done some refactoring and added an option to preview what the API will look like. It is available in
To make sure the polyfill has been removed, do a build analysis: pnpm build --analyze --analyze-open Note If dependencies import There should be no other code changes required. Your extension should work the same way as before. If you run into issues, either at runtime or with types, please report them! |
I will also add, as of 0.19.0, the manifest type in your |
Closing this issue in favor of #868 |
Feature Request
Currently, WXT's
browser
is the default export fromwebextension-polyfill
. However, now that Chrome doesn't support MV2 extensions, and Firefox has MV3 support, it's not really doing anything anymore... It's main features were:chrome
andbrowser
However, those two features are no longer necessary:
chrome
andbrowser
chrome
global, but WXT will continue to re-export it's ownbrowser
variable.So how is WXT going to remove the polyfill?
First, it will provide some flag in config to continue using it if you want, but the polyfilll will not be the default. It will be moved to an optional peer-dependency so it's not even installed if it doesn't have to be.
Second, we'll be replacing
@types/webextension-polyfill
with@types/chrome
. This will address lots of the problems with missing API and manifest types, at the cost of not being able to use type errors to know what's supported by all browsers and what's not. Either way, both ways have problems, but I think@types/chrome
will provide a better DX.Finally, we'll need to update
wxt/testing
to make sure it properly fakes the API. Not sure if@webext-core/fake-browser
is still the best option for providing a fake version during development. Edit: Been looking and can't find anything else on NPMSo in summary, you shouldn't have to make any changes to your source code or tests. That's the goal, to make this transition as seemless as possible. You'll be able to opt into using the polyfill from
wxt.config.ts
. There will be breaking changes to types, don't think I can get around that.If you use a library that includes the polyfill, it will work just fine, the polyfill will still be included.
Is your feature request related to a bug?
#506 - The
vite-node
solution works well, but the polyfill is getting in the way.#521 - Improve manifest typing
#299 - Improve runtime API typing
What are the alternatives?
N/A
Additional context
The text was updated successfully, but these errors were encountered: