Migrate Chrome and Edge builds to Manifest V3#269
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/edgebuild/zip/startscripts (and the defaultdev/buildscripts, 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 onmanifestVersion:page_action→action(MV3 has no page action)*://*.deviantart.com/*match pattern moves frompermissionstohost_permissionsweb_accessible_resourcesuses the MV3 object format, scoped to*://*.deviantart.com/*minimum_chrome_versionbecomes88.0(the MV3 floor) for both Chrome and Edgeapp/entrypoints/background.js:persistentis now MV2-only (MV3 runs as a service worker); the click listener binds tobrowser.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 realpageActionAPI (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 thechrome-mv3/edge-mv3outputs 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 ignoresbrowserslist, and the firefox bundle was shipping untranspiled?./??/??=— syntax Firefox 62 (the declaredstrict_min_version) does not support. The firefox build now targetsfirefox62and the Chrome/Edge builds targetchrome88; 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
(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 testpasses end-to-end (exit 0):eslint ./app/— 0 problemswxt buildfor chrome (MV3), edge (MV3), firefox (MV2)Validated chrome manifest (MV3),Validated edge manifest (MV3),Validated firefox manifest (MV2)wxt zipfor all three targetsweb-ext linton 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 thefirefox62target (all three appeared throughout the bundle before it).Manual test checklist (Chrome, unpacked
.output/chrome-mv3)chrome://extensions(service worker starts; no MV2 deprecation warning).output/edge-mv3build in Edge (button behavior + filtering).output/firefox-mv2): page action still appears in the address bar on deviantart.com only, and filtering works