Skip to content

Commit

Permalink
Allow both service_worker and scripts in MV3 Web Extensions (#9673)
Browse files Browse the repository at this point in the history
* Allow both service_worker and scripts in MV3

* support `background.page` and `background.persistent` in MV3

* Lint

---------

Co-authored-by: 101arrowz <arjunbarrett@gmail.com>
  • Loading branch information
mischnic and 101arrowz committed May 10, 2024
1 parent fcc6b59 commit ef63bff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Expand Up @@ -4,7 +4,9 @@
"version": "0.1",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
"service_worker": "background.js",
"type": "module",
"scripts": [ "background.js" ]
},
"permissions": [
"scripting",
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/webextension.js
Expand Up @@ -111,6 +111,7 @@ describe('webextension', function () {
assets: ['manifest.json'],
},
{assets: ['background.js']},
{assets: ['background.js']},
{assets: ['popup.html']},
{assets: ['popup.css']},
{assets: ['popup.js', 'esmodule-helpers.js', 'bundle-url.js']},
Expand Down
Expand Up @@ -273,7 +273,8 @@ async function collectDependencies(
...getJSONSourceLocation(ptrs['/background/page'], 'value'),
},
});
} else if (program.background?.service_worker) {
}
if (program.background?.service_worker) {
program.background.service_worker = asset.addURLDependency(
program.background.service_worker,
{
Expand Down
4 changes: 4 additions & 0 deletions packages/transformers/webextension/src/schema.js
Expand Up @@ -473,6 +473,10 @@ export const MV3Schema = ({
type: 'string',
enum: ['classic', 'module'],
},
// to support both Chrome and Firefox
scripts: arrStr,
page: string,
persistent: boolean,
},
additionalProperties: false,
required: ['service_worker'],
Expand Down

0 comments on commit ef63bff

Please sign in to comment.