-
Notifications
You must be signed in to change notification settings - Fork 245
Description
Build tool
Vite
Describe the bug
No support for page or preferred_environment in manifest types.
I'm developing an extension that targets Safari as well as other browsers. In order to get a decent development environment in Safari, I use a background script instead of a service worker. To target Chrome with the same manifest, I generate something like this:
"background": {
"service_worker": "service-worker-loader.js",
"scripts": ["assets/index.ts-XXXXXXX.js"],
"preferred_environment": "document",
"type": "module"
}
Chrome uses the service_worker, Safari a background script. However, this plugin doesn't support that (it won't generate both the service_worker and scripts entries). Typechecking fails, and it won't output, the preferred_environment key (same for the page key, which I was trying to use at one point).
Documentation is at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background
Reproduction
chrome-extension-tools/packages/vite-plugin/src/node/manifest.ts
Lines 48 to 51 in 303b696
| background?: | |
| | ChromeManifestBackground | |
| | FirefoxManifestBackground | |
| | undefined |
System Info
System:
OS: macOS 26.0
CPU: (12) arm64 Apple M2 Pro
Memory: 561.67 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 22.19.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.9.3 - /opt/homebrew/bin/npm
Browsers:
Brave Browser: 136.1.78.94
Chrome: 140.0.7339.186
Safari: 26.0
npmPackages:
@crxjs/vite-plugin: ^2.0.3 => 2.0.3
vite: ^6.3.5 => 6.3.5Severity
blocking all usage of RPCE