Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firefox] Outputted manifest is in v2 format despite manifest_version set to 3 #1388

Open
5 tasks done
dceluis opened this issue Feb 1, 2025 · 2 comments
Open
5 tasks done
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug

Comments

@dceluis
Copy link

dceluis commented Feb 1, 2025

Describe the bug

Creating a new project with manifest-v3 and building the extension for firefox outputs a manifest with an incorrect v2 format

import { defineConfig } from 'wxt';

// See https://wxt.dev/api/config.html
export default defineConfig({
  manifest: {
    manifest_version: 3,
    name: "Test repro",
    version: "1.0",
    description: "Description",
    web_accessible_resources: [
      {
        resources: ["images/*.png"],
        matches: [ "<all_urls>" ]
      }
    ]
  },
});
// .output/firefox-mv2/manifest.json
{
    "manifest_version":3,
    "name":"Test repro",
    "description":"Description",
    "version":"1.0",
    "web_accessible_resources":["images/*.png"],
    "background":{"scripts":["background.js"]}
}

This is problematic because manifest_version is set to 3 while the web_accessible_resources key is formatted as per v2.
This leads to not being able to import the extension in Firefox, as it is expecting a true v3 manifest structure.

Reproduction

#!/usr/bin/env bash
mkdir wxt_tmp_repro

cd wxt_tmp_repro

# Initialize the Bun project (creates package.json with default content)
bun init -y

# Install wxt as a dev dependency
bun i -D wxt

# Insert the "scripts" block after the "name" property in package.json.
# This uses sed to append the block immediately after the line matching "name":
sed -i '/"name":/a\
  "scripts": {\
    "dev": "wxt",\
    "dev:firefox": "wxt -b firefox",\
    "build": "wxt build",\
    "build:firefox": "wxt build -b firefox",\
    "zip": "wxt zip",\
    "zip:firefox": "wxt zip -b firefox",\
    "postinstall": "wxt prepare"\
  },
' package.json

# Create the entrypoints directory if it doesn't exist and add the background script.
mkdir -p entrypoints
cat > entrypoints/background.js << 'EOF'
export default defineBackground(() => {
  console.log('Hello world!');
});
EOF

# Create the wxt.config.ts file with the provided content.
cat > wxt.config.ts << 'EOF'
import { defineConfig } from 'wxt';

// See https://wxt.dev/api/config.html
export default defineConfig({
  manifest: {
    manifest_version: 3,
    name: "Test repro",
    version: "1.0",
    description: "Description",
    web_accessible_resources: [
      {
        resources: ["images/*.png"],
        matches: [ "<all_urls>" ]
      }
    ]
  },
});
EOF

# Build for Firefox
bun run build:firefox

# Output the generated manifest.json to the console
cat .output/firefox-mv2/manifest.json

Steps to reproduce

Run the above repro as bash repro.sh

System Info

System:
    OS: Linux 6.12 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5700U with Radeon Graphics
    Memory: 10.14 GB / 14.45 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 23.7.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.1.0 - /usr/bin/npm
    bun: 1.1.43 - ~/.local/share/mise/installs/bun/1.1.43/bin/bun
  npmPackages:
    wxt: ^0.19.26 => 0.19.26

Used Package Manager

bun

Validations

@dceluis dceluis added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Feb 1, 2025
@aklinker1
Copy link
Collaborator

aklinker1 commented Feb 1, 2025

I can add a warning and make sure to ignore manifest.manifest_version. But basically, you're not setting the manifest version in the correct location. You should set manifestVersion instead:

export default defineConfig({
+ manifestVersion: 3,
  manifest: {
-   manifest_version: 3

I'm surprised TS let you define that key, I thought the type excluded it.

https://wxt.dev/api/reference/wxt/interfaces/InlineConfig.html#manifestversion

@dceluis
Copy link
Author

dceluis commented Feb 1, 2025

That explains why the final manifest.json was being written to mv2 folder AND came out with a manifest_version: 3.

Thanks. A warning might be sufficient, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug
Projects
None yet
Development

No branches or pull requests

2 participants