samrum / vite-plugin-web-extension

A vite plugin for generating cross browser platform, ES module based web extensions.
MIT License
323 stars 33 forks source link

Safari browser.runtime.onInstalled not working #96

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 https://github.com/antfu/vitesse-webext 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 are using this base repo https://github.com/antfu/vitesse-webext 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

samrum commented 1 year ago

That template isn't using this plugin. Should open an issue there.

Seems to be an issue with Safari in general, though: https://developer.apple.com/forums/thread/660182 https://developer.apple.com/forums/thread/679429