Skip to content

Commit ef63bff

Browse files
mischnic101arrowz
andauthored
Allow both service_worker and scripts in MV3 Web Extensions (#9673)
* Allow both service_worker and scripts in MV3 * support `background.page` and `background.persistent` in MV3 * Lint --------- Co-authored-by: 101arrowz <[email protected]>
1 parent fcc6b59 commit ef63bff

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

packages/core/integration-tests/test/integration/webextension-mv3/manifest.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"version": "0.1",
55
"manifest_version": 3,
66
"background": {
7-
"service_worker": "background.js"
7+
"service_worker": "background.js",
8+
"type": "module",
9+
"scripts": [ "background.js" ]
810
},
911
"permissions": [
1012
"scripting",

packages/core/integration-tests/test/webextension.js

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ describe('webextension', function () {
111111
assets: ['manifest.json'],
112112
},
113113
{assets: ['background.js']},
114+
{assets: ['background.js']},
114115
{assets: ['popup.html']},
115116
{assets: ['popup.css']},
116117
{assets: ['popup.js', 'esmodule-helpers.js', 'bundle-url.js']},

packages/transformers/webextension/src/WebExtensionTransformer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ async function collectDependencies(
273273
...getJSONSourceLocation(ptrs['/background/page'], 'value'),
274274
},
275275
});
276-
} else if (program.background?.service_worker) {
276+
}
277+
if (program.background?.service_worker) {
277278
program.background.service_worker = asset.addURLDependency(
278279
program.background.service_worker,
279280
{

packages/transformers/webextension/src/schema.js

+4
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ export const MV3Schema = ({
473473
type: 'string',
474474
enum: ['classic', 'module'],
475475
},
476+
// to support both Chrome and Firefox
477+
scripts: arrStr,
478+
page: string,
479+
persistent: boolean,
476480
},
477481
additionalProperties: false,
478482
required: ['service_worker'],

0 commit comments

Comments
 (0)