crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.71k stars 181 forks source link

Reading manifest: Error processing background #813

Open SkyfallWasTaken opened 10 months ago

SkyfallWasTaken commented 10 months ago

Build tool

Vite

Where do you see the problem?

Describe the bug

When loading the example Vite project into Firefox, I get this error:

Extension is invalid
Reading manifest: Error processing background: Value must either: contain the required "page" property, contain the required "scripts" property, or not contain an unexpected "type" property

Reproduction

Repro: https://github.com/SkyfallWasTaken/airhorn-ext

  1. Go to about:debugging#/runtime/this-firefox in Firefox
  2. Press "Load Temporary Add-on..." and choose the manifest.json file
  3. Get the error

Logs

[ACTION FAILED] TEMPORARY_EXTENSION_INSTALL_FAILURE: Extension is invalid
loadManifestFromWebManifest@resource://gre/modules/addons/XPIInstall.jsm:466:17

System Info

System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (8) x64 Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
    Memory: 26.91 GB / 31.33 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 1.0.7 - /tmp/bun-node/node
  npmPackages:
    @crxjs/vite-plugin: beta => 2.0.0-beta.19 
    vite: ^4.4.5 => 4.5.0

(note that I'm using Bun 1.0.7 to run everything, not Node 1 😅)

Severity

blocking all usage of RPCE

SkyfallWasTaken commented 10 months ago

Okay, so I just found the problem:

Crxjs uses background service workers, which are unsupported in Firefox.

sublimator commented 9 months ago

background service workers, which are unsupported in Firefox.

Really ?? I could have sworn it supported service workers at some point

honwhy commented 7 months ago

if you use manifest.config.ts to define and export manifest.config.jsonsee here, you can follow @crxjs/vite-plugin/dist/index.d.ts and find background key requirement.

interface ManifestV3 {
...
background?: ChromeManifestBackground | FirefoxManifestBackground | undefined;
}
interface FirefoxManifestBackground {
    scripts: string[];
    persistent?: false;
}