antfu-collective / vitesse-webext

⚡️ WebExtension Vite Starter Template
MIT License
2.92k stars 225 forks source link

Safari browser.runtime.onInstalled not working #123

Closed luedrame closed 1 year ago

luedrame commented 1 year ago

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