Skip to content

No support for background page or preferred environment in manifest #1070

@apexskier

Description

@apexskier

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

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.5

Severity

blocking all usage of RPCE

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions