Skip to content

feat: Migrate from Manifest V2 to V3#78

Open
yize wants to merge 1 commit intomasterfrom
manifest-v3-upgrade
Open

feat: Migrate from Manifest V2 to V3#78
yize wants to merge 1 commit intomasterfrom
manifest-v3-upgrade

Conversation

@yize
Copy link
Owner

@yize yize commented Feb 14, 2026

Migrate XSwitch from Manifest V2 to V3 for Chrome 88+ compatibility.

Summary

This PR upgrades XSwitch to use Manifest V3, which is required for Chrome 88+.

Changes

manifest.json

  • Update manifest_version: 2 → 3
  • Replace browser_action with action
  • Replace background.scripts with background.service_worker
  • Replace webRequest permissions with declarativeNetRequest
  • Add host_permissions for all URLs

src/background.ts

  • Rewrite using declarativeNetRequest API instead of webRequest
  • Service worker pattern instead of persistent background script
  • Add updateDeclarativeNetRequestRules() function
  • Add updateCorsHeaders() function
  • Maintain CORS and cache clearing functionality

build/webpack.v3.config.js (new)

  • Webpack configuration for V3 build
  • Generates service worker instead of persistent script
  • Production mode with minification

package.json

  • Add build:v3 script
  • Add pub:v3 script

Breaking Changes

  • webRequest API replaced with declarativeNetRequest
  • Background script now runs as service worker (non-persistent)
  • Dynamic request modification now declarative (rules-based)

Testing

Build with: npm run build:v3

API Changes

V2 V3
browser_action action
webRequest declarativeNetRequest
blocking callback declarative rules
persistent script service worker

Migration Guide

See MANIFEST_V3_MIGRATION_GUIDE.md for detailed migration documentation.

Major changes:
- Update manifest.json: v2 → v3, browser_action → action
- Rewrite background.ts using declarativeNetRequest API
- Add webpack config for service worker build
- Add V3 migration guide documentation
- Add build:v3 and pub:v3 scripts

Breaking changes:
- webRequest replaced with declarativeNetRequest
- Background script now runs as service worker
- Dynamic request modification now declarative

This migration is required for Chrome 88+ compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant