antfu-collective/vitesse-webext

Safari browser.runtime.onInstalled not working

luedrame opened this issue · 0 comments

Describe the bug

Hi guys, we are developing an extension and we need to open a new tab when a user installs the extension.

That's exactly what this boilerplate does in background/main.ts:
browser.runtime.onInstalled.addListener((): void => {
console.log('Extension installed')
})

But apparently Safari doesn't fire the event(the listener is created correctly but never is called), we have done some tests using webpack for build the extension and it does fire the event, the code is almost the same for webpack and vite.

We don't know where the problem could be, if it's in the vite plugin or in safari itself

Reproduction

We follow the README instructions, when we build the project after that, we use: xcrun safari-web-extension-converter --app-name vittesse --macos-only . To transform the extension for safari, we run the extension in Safari and the event doesn't fire.

System Info

System:
    OS: macOS 12.6.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 185.71 MB / 16.00 GB
    Shell: 3.4.1 - /usr/local/bin/fish
  Binaries:
    Node: 18.7.0 - /usr/local/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.15.0 - /usr/local/bin/npm
  Browsers:
    Safari: 16.4

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.