Add initial MV3 support
In order to prepare the migration towards Manifest Version 3, this
change adds a MV3 browser target for Chromium (chromium_mv3) and another
one for Edge (edge_mv3), which will build the extension using MV3.
This CL also changes several things to fix some bugs in the MV3 version
of the extension:
- Adds //src/common/actionApi.js to target |chrome.browserAction| (MV2)
and |chrome.action| (MV3) accordingly using the version-agnostic
object |actionApi|.
- Adds //src/common/sessionStorage.js to wrap the
|chrome.storage.session| object in the case of MV3, and polyfill it in
the case of MV2. (The polyfill isn't perfect, since it stores the data
under the window object of the current page, so different pages will
have access to completely different storage areas, which are cleared
once the page is closed, not once the extension stops running.
However, this is fine for our case.)
As of now, the extension built with MV3 might have bugs. Thus, the MV3
variant will not be used for builds until it has been stabilized.
Bug: translateselectedtext:4
Change-Id: Ib525339c055237b32b7352c490fee86b21555ed6
diff --git a/Makefile b/Makefile
index 166ca7b..ec00ad4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: node_deps clean_dist deps clean_deps serve_chromium serve_edge release release_chromium_stable release_chromium_beta release_edge build_test_extension clean_releases clean
+.PHONY: node_deps clean_dist deps clean_deps serve_chromium serve_chromium_mv3 serve_edge serve_edge_mv3 release release_chromium_stable release_chromium_beta release_edge build_test_extension clean_releases clean
.DEFAULT_GOAL := release
WEBPACK := ./node_modules/webpack-cli/bin/cli.js
@@ -20,9 +20,15 @@
serve_chromium: deps
$(WEBPACK) --mode development --env browser_target=chromium --watch
+serve_chromium_mv3: deps
+ $(WEBPACK) --mode development --env browser_target=chromium_mv3 --watch
+
serve_edge: deps
$(WEBPACK) --mode development --env browser_target=edge --watch
+serve_edge_mv3: deps
+ $(WEBPACK) --mode development --env browser_target=edge_mv3 --watch
+
release: release_chromium_stable release_chromium_beta release_edge
release_chromium_stable: deps