Skip to content

[BUG] How should I automatically translate the chrome api when building a firefox version? #1230

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

Open
2 of 3 tasks
jeffminim opened this issue Mar 9, 2025 · 2 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@jeffminim
Copy link

What happened?

I want to try adapting firefox, but a lot of the API calls to browser I use chrome.*. However, when building --target=firefox, it looks like the plasmo framework doesn't translate automatically for me properly (chrome. -> browser.) Including, but not limited to, “chrome.runtime, chrome.storage, chrome.tabs, chrome.i18n”, which results in not work correctly in firefox.
Is there something I'm doing wrong? Or is this feature currently missing?

Version

Latest

What OS are you seeing the problem on?

Windows

What browsers are you seeing the problem on?

Firefox

Relevant log output

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@jeffminim jeffminim added the bug Something isn't working label Mar 9, 2025
@muzammil0011
Copy link

Use webExtension-polifill instead

@spiceworm
Copy link

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API

Firefox also implements these APIs under the chrome namespace using callbacks. This allows code written for Chrome to run largely unchanged in Firefox for the APIs documented here.

Try to make minimal usage of direct calls to chrome.* APIs for things like chrome.storage and chrome.runtime.sendMessage and instead use plasmo APIs wherever possible.

https://docs.plasmo.com/framework/storage

https://docs.plasmo.com/framework/messaging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants