Skip to content

Migrate Chrome and Edge builds to Manifest V3#269

Merged
rthaut merged 2 commits into
masterfrom
build/chrome-edge-mv3
Jul 17, 2026
Merged

Migrate Chrome and Edge builds to Manifest V3#269
rthaut merged 2 commits into
masterfrom
build/chrome-edge-mv3

Conversation

@rthaut

@rthaut rthaut commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Migrates the Chrome and Edge builds to Manifest V3 ahead of the Chrome Web Store's MV2 removal deadline. Firefox continues to build MV2 with its existing 62.0 minimum. Closes #243.

What changed

  • package.json: the chrome/edge build/zip/start scripts (and the default dev/build scripts, which target Chrome) no longer pass --mv2, so WXT builds MV3 for those targets. The firefox scripts keep --mv2.
  • wxt.config.ts: the manifest now branches on manifestVersion:
    • page_actionaction (MV3 has no page action)
    • the *://*.deviantart.com/* match pattern moves from permissions to host_permissions
    • web_accessible_resources uses the MV3 object format, scoped to *://*.deviantart.com/*
    • minimum_chrome_version becomes 88.0 (the MV3 floor) for both Chrome and Edge
  • app/entrypoints/background.js: persistent is now MV2-only (MV3 runs as a service worker); the click listener binds to browser.pageAction ?? browser.action.
  • app/scripts/background/tabs.js: page-action behavior is emulated on MV3 — the action button is disabled globally on install/startup and enabled per-tab when the tab is on deviantart.com. The button is therefore always visible in the toolbar (an MV3 constraint) but greyed out/non-clickable off-domain. Firefox still uses the real pageAction API (capability-checked, not browser-sniffed).
  • app/scripts/background/runtime.js: browser.extension.getURL() (removed in MV3) → browser.runtime.getURL().
  • scripts/smoke-manifests.js: now asserts the chrome-mv3/edge-mv3 outputs have the correct MV3 shape (service worker, action, host_permissions, object-format WAR, min version 88) while firefox remains MV2 with all of its existing checks.
  • wxt.config.ts (second commit): explicit per-browser esbuild targets. Vite ignores browserslist, and the firefox bundle was shipping untranspiled ?./??/??= — syntax Firefox 62 (the declared strict_min_version) does not support. The firefox build now targets firefox62 and the Chrome/Edge builds target chrome88; the rebuilt firefox bundle contains none of those tokens.

No version bump here — versioning is handled by the pending release PR (#241).

Chrome manifest: MV2 → MV3 diff

--- chrome-mv2/manifest.json
+++ chrome-mv3/manifest.json
@@ -1,5 +1,5 @@
 {
-  "manifest_version": 2,
+  "manifest_version": 3,
   "name": "__MSG_ExtensionName__",
   "description": "__MSG_ExtensionDescription__",
   "version": "6.2.2",
@@ -17,7 +17,7 @@
   },
   "default_locale": "en",
   "homepage_url": "https://rthaut.github.io/deviantART-Filter",
-  "page_action": {
+  "action": {
     "default_icon": {
       "16": "images/icon-16.png",
       "19": "images/icon-19.png",
@@ -36,18 +36,24 @@
     "contextMenus",
     "notifications",
     "storage",
-    "tabs",
+    "tabs"
+  ],
+  "host_permissions": [
     "*://*.deviantart.com/*"
   ],
   "web_accessible_resources": [
-    "create-filters.html"
+    {
+      "resources": [
+        "create-filters.html"
+      ],
+      "matches": [
+        "*://*.deviantart.com/*"
+      ]
+    }
   ],
-  "minimum_chrome_version": "49.0",
+  "minimum_chrome_version": "88.0",
   "background": {
-    "persistent": true,
-    "scripts": [
-      "background.js"
-    ]
+    "service_worker": "background.js"
   },
   "content_scripts": [
     {

(The icons, content_scripts, name/description/locale, and permissions other than the host pattern are unchanged. The edge-mv3 manifest has the same shape.)

Validation

npm test passes end-to-end (exit 0):

  • eslint ./app/ — 0 problems
  • wxt build for chrome (MV3), edge (MV3), firefox (MV2)
  • manifest smoke tests — Validated chrome manifest (MV3), Validated edge manifest (MV3), Validated firefox manifest (MV2)
  • wxt zip for all three targets
  • web-ext lint on the firefox build — 0 errors, 0 notices, 6 pre-existing warnings (eval/innerHTML flags from bundled third-party libraries)

Transpilation check: scanning the built firefox bundle for ?. / ?? / ??= finds none after the firefox62 target (all three appeared throughout the bundle before it).

Manual test checklist (Chrome, unpacked .output/chrome-mv3)

  • Extension loads with no errors on chrome://extensions (service worker starts; no MV2 deprecation warning)
  • Toolbar button is present but disabled (greyed out, not clickable) on non-DeviantArt tabs
  • Toolbar button becomes enabled on a deviantart.com tab, and clicking it opens (or focuses) the Manage page
  • Filters apply on browse/search pages (existing user/keyword filters hide deviations)
  • Creating a filter from the Manage page works and takes effect on an open DeviantArt tab without a reload
  • The create-filters page opens from a deviation (web-accessible resource loads)
  • Right-click context menus on tag/deviation links appear and create filters
  • After restarting the browser, the button is disabled off-domain and re-enables on deviantart.com tabs
  • Quick smoke of the unpacked .output/edge-mv3 build in Edge (button behavior + filtering)
  • Firefox regression check (.output/firefox-mv2): page action still appears in the address bar on deviantart.com only, and filtering works

rthaut added 2 commits July 17, 2026 10:05
Chrome and Edge now build MV3 by default (Firefox stays MV2):

- Drop --mv2 from the chrome/edge build, zip, and start scripts
- Branch the manifest on manifestVersion: action replaces page_action,
  host permissions move to host_permissions, web_accessible_resources
  uses the MV3 object format, and minimum_chrome_version becomes 88
- Make the background persistent flag MV2-only (MV3 uses a service worker)
- Emulate the old page action behavior on MV3 with the action API:
  disable the toolbar button globally on install/startup and enable it
  per-tab on deviantart.com; Firefox keeps the real pageAction API
- Replace the removed extension.getURL with runtime.getURL
- Update the manifest smoke tests to assert the chrome-mv3/edge-mv3
  outputs (MV3 shape) alongside the unchanged firefox-mv2 output
Vite/esbuild ignore the browserslist field and default to a ~es2020
target, so the firefox build shipped untranspiled optional chaining
(?.), nullish coalescing (??), and logical nullish assignment (??=),
none of which Firefox 62 (the declared strict_min_version) supports.
Set the esbuild target explicitly: firefox62 for the Firefox build and
chrome88 for the Chrome/Edge MV3 builds.
@rthaut
rthaut merged commit b21b7ca into master Jul 17, 2026
3 checks passed
@rthaut
rthaut deleted the build/chrome-edge-mv3 branch July 17, 2026 16:15
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
3 tasks
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.

Migrate manifest v2 to v3 for deviantart filter

1 participant