Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webextensions] Parcel doesn't accept manifest v3 with both service_worker and scripts #9458

Open
fregante opened this issue Jan 2, 2024 · 4 comments 路 May be fixed by #9673
Open

[webextensions] Parcel doesn't accept manifest v3 with both service_worker and scripts #9458

fregante opened this issue Jan 2, 2024 · 4 comments 路 May be fixed by #9673

Comments

@fregante
Copy link
Contributor

fregante commented Jan 2, 2024

馃悰 bug report

Parcel supports either background.service_worker or background.scripts, but not both.

Firefox supports background.scripts, but warns that it doesn't support the other one.

Chrome won't load a manifest that has background.scripts

馃帥 Configuration (.babelrc, package.json, cli command)

{
	"extends": "@parcel/config-webextension"
}
{
	"name": "Awesome Extension",
	"version": "0.0.0",
	"description": "An awesome new browser extension",
	"manifest_version": 3,
	"background": {
		"service_worker": "background.js",
		"type": "module",
		"scripts": [ "background.js" ]
	}
}

馃 Expected Behavior

Parcel should build both, so that the extension can (eventually) be loaded in both browsers

馃槸 Current Behavior

馃毃 Build failed.

@parcel/transformer-webextension: Invalid Web 
Extension manifest

  ./source/manifest.json:36:3
    35 |   "background": {
  > 36 |     "service_worker": "background.js",
  >    |     ^^^^^^^^^^^^^^^^ Possible values: "page", "persistent"
  > 37 |     "type": "module",
  >    |     ^^^^^^ Possible values: "page", "persistent"
    38 |     "scripts": [ "background.js" ]
    39 |   }

馃拋 Possible Solution

Allow and build both pages, ideally build a single background.js file without generating two separate bundles.

馃敠 Context

Chrome has been open to allowing the scripts property in the manifest without throwing, however this hasn't been fixed in several months. It would be great for Parcel to start supporting it as soon as possible so that we don't have to wait any longer once Chrome supports it.

馃捇 Code Sample

  1. Check this out https://github.com/fregante/browser-extension-template
  2. Add "scripts": ["background.js"], to its manifest

馃實 Your Environment

Software Version(s)
Parcel 2.10.3
Node 20
npm/Yarn 10
Operating System macOS
@fregante
Copy link
Contributor Author

fregante commented Jan 2, 2024

@fregante
Copy link
Contributor Author

fregante commented Feb 1, 2024

Chrome 121 is out and this is preventing me from building cross-browser MV3 extensions unfortunately.

@zopieux
Copy link

zopieux commented Mar 24, 2024

Per https://stackoverflow.com/a/78088358/180709 both are valid and this finally allows truly cross-browser extension packaging with Parcel.

Please allow both keys.

@tdriley
Copy link

tdriley commented Apr 26, 2024

both are valid and this finally allows truly cross-browser extension packaging with Parcel.

This is great news!

Official docs from Chrome about their MV3 manifest accepting the MV2 background values without erroring: https://developer.chrome.com/docs/extensions/whats-new#background-key-warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants