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

feat!: Remove webextension-polyfill #1084

Merged
merged 12 commits into from
Oct 19, 2024

Conversation

aklinker1
Copy link
Collaborator

@aklinker1 aklinker1 commented Oct 19, 2024

This is not being merged into main, but the v0.20.0 staging branch.


BREAKING CHANGE: WXT no longer uses the webextension-polyfill because it doesn't provide any value anymore. As long as you're not developing a legacy MV2 extension for Chrome, nothing changes about how you're importing and using WXT's browser at runtime - your extension should behave the exact same way!

However, there are a few changes you might need to make to your non-runtime code:

  • If you use TypeScript, extension API types are now apart of the browser variable, not separate imports:
    - import { type Runtime} from 'wxt/browser';
    + import { browser } from 'wxt/browser';
    
    - function getSenderId(sender: Runtime.Sender) { 
    + function getSenderId(sender: browser.runtime.Sender) { 
  • If you set extensionApi option in your wxt.config.ts, remove it:
    export default defineConfig({
    - extnsionApi: "chrome",
    });
  • If you disabled auto-imports and were importing from wxt/browser/chrome, you can go back to importing from wxt/browser:
    - import { browser } from 'wxt/browser/chrome';
    + import { browser } from 'wxt/browser';

To continue using the polyfill, install the NPM package and import it instead of using wxt/browser:

pnpm i webextension-polyfill
pnpm i -D @types/webextension-polyfill
import browser from 'webextension-polyfill';

console.log(browser.runtime.id);

@aklinker1 aklinker1 changed the title feat!: Use extensionApi: chrome by default feat!: Use extensionApi: chrome by default Oct 19, 2024
@aklinker1 aklinker1 changed the title feat!: Use extensionApi: chrome by default feat!: Remove webextension-polyfill Oct 19, 2024
Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 94.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 81.66%. Comparing base (842c158) to head (615f68a).
Report is 2 commits behind head on 0.20.0-breaking-changes.

Files with missing lines Patch % Lines
...src/core/builders/vite/plugins/extensionApiMock.ts 0.00% 1 Missing ⚠️
packages/wxt/src/core/utils/content-scripts.ts 66.66% 1 Missing ⚠️
...es/wxt/src/virtual/utils/reload-content-scripts.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           0.20.0-breaking-changes    #1084      +/-   ##
===========================================================
- Coverage                    82.07%   81.66%   -0.42%     
===========================================================
  Files                          127      125       -2     
  Lines                         6661     6625      -36     
  Branches                      1112     1107       -5     
===========================================================
- Hits                          5467     5410      -57     
- Misses                        1180     1198      +18     
- Partials                        14       17       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aklinker1 aklinker1 marked this pull request as ready for review October 19, 2024 09:48
@aklinker1 aklinker1 merged commit 70d842f into 0.20.0-breaking-changes Oct 19, 2024
12 checks passed
@aklinker1 aklinker1 deleted the chrome-by-default branch October 19, 2024 09:51
aklinker1 added a commit that referenced this pull request Oct 19, 2024
aklinker1 added a commit that referenced this pull request Oct 19, 2024
aklinker1 added a commit that referenced this pull request Oct 19, 2024
This was referenced Oct 19, 2024
@aklinker1 aklinker1 added this to the v1.0 milestone Oct 19, 2024
aklinker1 added a commit that referenced this pull request Dec 25, 2024
aklinker1 added a commit that referenced this pull request Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant