Skip to content

feat: add content script registration optional - #2288

Open
eupthere wants to merge 15 commits into
wxt-dev:mainfrom
eupthere:content-script-optional
Open

eupthere wants to merge 15 commits into
wxt-dev:mainfrom
eupthere:content-script-optional

Conversation

@eupthere

@eupthere eupthere commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Adds support for registration: "optional" for content scripts so host match patterns are treated as optional origins instead of required host permissions.

Related Docs:
MDN optional_host_permissions
Chrome Extensions Docs MV2 - Optional Permissions

What changed:

  • Extended content script registration types to include "optional".
  • Updated manifest generation to:
    • Exclude registration: "optional" scripts from content_scripts (same dynamic-registration model as runtime scripts).
    • Move their matches into optional_host_permissions instead of host_permissions.
  • Added MV2 conversion support:
    • optional_host_permissions are merged into optional_permissions when targeting MV2.
  • Updated dev reload handling so "optional" follows runtime-style content script reload flow.
  • Added/updated tests for:
    • optional registration manifest output in MV3
    • optional host permission conversion in MV2
    • validation behavior around matches
  • Updated docs to include the new "optional" registration mode and describe intended optional-host runtime usage.

Please review this:

function validateContentScriptEntrypoint(
  definition: ContentScriptEntrypoint,
): ValidationResult[] {
  const errors = validateBaseEntrypoint(definition);
  if (
    definition.options.registration !== 'runtime' &&
    definition.options.matches == null
  ) {
    errors.push({
      type: 'error',
      message:
        '`matches` is required for content scripts not registered at runtime',
      value: definition.options.matches,
      entrypoint: definition,
    });
  }
  return errors;
}

I intentionally kept registration: 'runtime' as the only mode that can omit matches, to preserve manual injection flows (for example browser.scripting.executeScript({ target: { tabId } ... })) where URL match patterns are not needed in entrypoint options.

registration: "optional" requires matches because this mode derives origin scope from matches to populate optional_host_permissions (and MV2 conversion to optional_permissions).

Could you confirm whether this assumption about the original runtime exception is correct, and whether keeping optional stricter is the intended design?

Manual Testing

wxt core test pass
bun run --filter wxt test run

Generated Manifest

// packages/wxt-demo/src/entrypoints/content.ts
export default defineContentScript({
  registration: 'optional',
  matches: ['https://example.com/*'],
  main() {
    console.log('optional test');
  },
});
cd packages/wxt-demo
npm run build:chrome-mv2
npm run build:chrome-mv3
MV2
{
  "manifest_version": 2,
  "name": "wxt-demo",
  "version": "1.0.0",
  "icons": {
    "16": "icons/16.png",
    "32": "icons/32.png",
    "48": "icons/48.png",
    "128": "icons/128.png"
  },
  "permissions": ["storage"],
  "default_locale": "en",
  "web_accessible_resources": [
    "iframe-src.html",
    "unlisted.js",
    "content-scripts/ui.css"
  ],
  "background": { "scripts": ["background.js"] },
  "browser_action": { "default_title": "Popup", "default_popup": "popup.html" },
  "options_ui": { "open_in_tab": false, "page": "options.html" },
  "sandbox": { "pages": ["example.html", "sandbox.html"] },
  "content_scripts": [
    {
      "matches": ["https://*.duckduckgo.com/*"],
      "css": ["content-scripts/automount.css"],
      "js": ["content-scripts/automount.js", "content-scripts/ui.js"]
    },
    { "matches": ["<all_urls>"], "js": ["content-scripts/example-tsx.js"] },
    { "matches": ["*://*.google.com/*"], "js": ["content-scripts/iframe.js"] },
    {
      "matches": ["*://*.crunchyroll.com/*"],
      "js": ["content-scripts/location-change.js"]
    },
    {
      "matches": ["*://*/*"],
      "js": ["content-scripts/main-world.js"],
      "world": "MAIN"
    }
  ],
  "optional_permissions": ["https://example.com/*"]
}
MV3
{
  "manifest_version": 3,
  "name": "wxt-demo",
  "version": "1.0.0",
  "icons": {
    "16": "icons/16.png",
    "32": "icons/32.png",
    "48": "icons/48.png",
    "128": "icons/128.png"
  },
  "permissions": ["storage", "sidePanel"],
  "default_locale": "en",
  "web_accessible_resources": [
    {
      "resources": ["iframe-src.html", "unlisted.js"],
      "matches": ["*://*.google.com/*", "*://*.example.com/*"]
    },
    {
      "resources": ["content-scripts/ui.css"],
      "use_dynamic_url": true,
      "matches": ["https://*.duckduckgo.com/*"]
    }
  ],
  "background": { "service_worker": "background.js" },
  "action": { "default_title": "Popup", "default_popup": "popup.html" },
  "options_ui": { "open_in_tab": false, "page": "options.html" },
  "sandbox": { "pages": ["example.html", "sandbox.html"] },
  "side_panel": { "default_path": "sidepanel.html" },
  "content_scripts": [
    {
      "matches": ["https://*.duckduckgo.com/*"],
      "css": ["content-scripts/automount.css"],
      "js": ["content-scripts/automount.js", "content-scripts/ui.js"]
    },
    { "matches": ["<all_urls>"], "js": ["content-scripts/example-tsx.js"] },
    { "matches": ["*://*.google.com/*"], "js": ["content-scripts/iframe.js"] },
    {
      "matches": ["*://*.crunchyroll.com/*"],
      "js": ["content-scripts/location-change.js"]
    },
    {
      "matches": ["*://*/*"],
      "js": ["content-scripts/main-world.js"],
      "world": "MAIN"
    }
  ],
  "optional_host_permissions": ["https://example.com/*"]
}

Related Issue

This PR closes #2239

@eupthere
eupthere requested a review from aklinker1 as a code owner April 21, 2026 13:33
@netlify

netlify Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 39c5b88
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ac1010b35c41b0008b79b66
😎 Deploy Preview https://deploy-preview-2288--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Apr 21, 2026
@eupthere

Copy link
Copy Markdown
Contributor Author

@aklinker1 Right now optional_host_permissions dedupe is exact-string only.

Would be nice if this was deduped if user already had urls in optional_host_permissions. example if I had *.app.com in optional_host_permissions theres no need to put auth.app.com because its covered by the existing one

The issue mentions deduping as a nice to have.

Since WXT already uses @webext-core/match-patterns, I checked whether it can help directly. It has URL checks (includes(url)) but I didn’t find a pattern-to-pattern coverage API (covers(otherPattern) / subset).

I can either:

  • implement a small coverage check in WXT now, or
  • add coverage support to @webext-core/match-patterns first and then wire it in here.

Happy to do whichever you prefer.

@pkg-pr-new

pkg-pr-new Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2288

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2288

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2288

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2288

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2288

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2288

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2288

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2288

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2288

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2288

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2288

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2288

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2288

wxt

npm i https://pkg.pr.new/wxt@2288

commit: 39c5b88

@codecov

codecov Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.80%. Comparing base (804235e) to head (39c5b88).
⚠️ Report is 137 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2288      +/-   ##
==========================================
+ Coverage   79.52%   79.80%   +0.27%     
==========================================
  Files         135      135              
  Lines        4054     4104      +50     
  Branches      944      968      +24     
==========================================
+ Hits         3224     3275      +51     
+ Misses        734      732       -2     
- Partials       96       97       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/wxt/src/core/utils/manifest.ts Resolved
Comment thread packages/wxt/src/core/utils/manifest.ts Resolved
Comment thread packages/wxt/src/core/utils/manifest.ts Resolved
- Clarified error message for content scripts not registered at runtime.
- Clarify the error message for invalid `optional` content scripts without `matches`.
Comment thread docs/guide/essentials/scripting.md Resolved
Comment thread packages/wxt/src/core/utils/manifest.ts Resolved
Comment thread packages/wxt/src/core/utils/manifest.ts Resolved
@marcellino-ornelas

marcellino-ornelas commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

The only other improvement here I would recommend is to dedupe optional_host_permissions 😃 heres what I mean.

example
In our wxt.config.ts file we define optional_host_permissions to something like this:

optional_host_permissions: [
    "https://*.internal-server.com"
]

This way one host gives you access to anything internal. But in our content scripts were more specific like https://app1.internal-server.com/some/path because we only want it to run on certain websites.

It would be sweet if:

  • If there is optional_host_permissions defined in wxt config already, append optionalMatches hosts instead of replace
  • (this would be sweet) Only add optionalMatches hosts to optional_host_permissions if one doesnt match it already. Soo in my above example https://app1.internal-server.com wouldnt be added again because https://*.internal-server.com already covers that requirement.

No big deal if not we can easily change our custom module to remove the dups if not 😃 Although I think overall this behavior would be sweet for not only optional content scripts but also regular matches too

@marcellino-ornelas

Copy link
Copy Markdown
Contributor

@eupthere planning on taking this on still 👀

@eupthere

eupthere commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@marcellino-ornelas Thanks for the reminder! I will update the PR on this weekend

Per review, `registration` only controls how `matches` is added to the
manifest. The new `optionalMatches` option is always added to
`optional_host_permissions` and never to `content_scripts`, so a single
content script can have both required and optional hosts.
`optionalMatches` are appended to any user defined
`optional_host_permissions`, skipping patterns already covered by
another entry. For example, `https://app.example.com/path/*` is not
added when `https://*.example.com/*` exists.
…hes` hosts

Without this, a shadow root UI registered on an optional host can't load
its CSS file.
Adds a Registration section to the content scripts guide covering
`manifest`, `runtime` and `optionalMatches`, and removes the previous
`registration: 'optional'` notes.
# Conflicts:
#	packages/wxt/src/core/utils/manifest.ts
@eupthere
eupthere requested a review from nishu-murmu as a code owner October 3, 2026 10:09
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3af7453-023b-4aca-bf1e-fab36a55971b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Comment on lines +1554 to +1555
matches: ['*://required.com/*'],
optionalMatches: ['*://optional.com/*'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if somebody put duplicated values in matches, like:

Obvious:

Suggested change
matches: ['*://required.com/*'],
optionalMatches: ['*://optional.com/*'],
matches: ['*://required.com/*'],
optionalMatches: ['*://required.com/*'],

or

Like the way, you have in code below:

Suggested change
matches: ['*://required.com/*'],
optionalMatches: ['*://optional.com/*'],
matches: ['https://*.other.com/*'],
optionalMatches: ['https://other.com/*'],

In both cases, optionalMatches should be omitted. because it's covered already.

Maybe it's edge case, and dev should care about that.
But that's the same conversation like before, about duplicated values in optionalMatches or matches, and i think if we've decided to dedupe it before, we should dedupe it there as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! Added the edge case handling at 020a3a9

const two = optionalCs(
{
registration: 'runtime',
optionalMatches: ['https://other.com/*', 'https://*.other.com/*'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add deduping like there, also for matches.

I'm wondering if this PR is a good place, because it's related with optional, but i think yeah, let's do it there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented at → 39c5b88 . I left out deduping the user defined manifest host_permissions for now, as it might be confusing for users to notice how their config doesn't seem to match the output. But I am open to dedupe them too if that seems more consistent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented at → 39c5b88 . I left out deduping the user defined manifest host_permissions for now, as it might be confusing for users to notice how their config doesn't seem to match the output. But I am open to dedupe them too if that seems more consistent.

Maybe i'm not understand, can you provide me some examples?

Comment thread packages/wxt/src/core/utils/manifest.ts Outdated
Comment on lines +678 to +690
let added: string[] = [];

for (const pattern of matchPatterns) {
const isCovered = [...existing, ...added].some((other) =>
matchPatternCovers(other, pattern),
);
if (isCovered) continue;

// Drop previously added patterns that this broader pattern covers. User
// defined entries in `existing` are never removed.
added = added.filter((other) => !matchPatternCovers(pattern, other));
added.push(pattern);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't easier to do it like that?:

Suggested change
let added: string[] = [];
for (const pattern of matchPatterns) {
const isCovered = [...existing, ...added].some((other) =>
matchPatternCovers(other, pattern),
);
if (isCovered) continue;
// Drop previously added patterns that this broader pattern covers. User
// defined entries in `existing` are never removed.
added = added.filter((other) => !matchPatternCovers(pattern, other));
added.push(pattern);
}
const added = matchPatterns.reduce<string[]>((added, pattern) => {
const allPatterns = [...existing, ...added];
const isCovered = allPatterns.some((other) =>
matchPatternCovers(other, pattern),
);
if (isCovered) {
return added;
}
return [
...added.filter((other) => !matchPatternCovers(pattern, other)),
pattern,
];
}, []);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the code style as suggested at 7c7be23

`optionalMatches` covered by any content script's `matches` or by
`host_permissions` are not added to `optional_host_permissions`, since
access to those hosts is already declared. Also avoids writing an empty
`optional_host_permissions` array when every pattern is skipped.
Content script `matches` added to `host_permissions` now use the same
dedupe as `optionalMatches`: patterns covered by an existing entry or by
another added pattern are skipped. User defined `host_permissions` are
never removed.
Comment on lines +2640 to +2657
['<all_urls>', 'https://example.com/*', true],
['https://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'http://example.com/*', true],
['https://example.com/*', '*://example.com/*', false],
['https://example.com/*', 'http://example.com/*', false],
['*://example.com/*', 'file:///example/*', false],
['https://*/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://a.b.example.com/*', true],
['https://*.example.com/*', 'https://*.a.example.com/*', true],
['https://*.example.com/*', 'https://notexample.com/*', false],
['https://a.example.com/*', 'https://*.example.com/*', false],
['https://example.com/*', 'https://example.com/path/*', true],
['https://example.com/path/*', 'https://example.com/*', false],
['https://example.com/a*', 'https://example.com/a/b*c', true],
['https://example.com/a.b', 'https://example.com/aXb', false],
['https://example.com/*', '<all_urls>', false],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
['<all_urls>', 'https://example.com/*', true],
['https://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'http://example.com/*', true],
['https://example.com/*', '*://example.com/*', false],
['https://example.com/*', 'http://example.com/*', false],
['*://example.com/*', 'file:///example/*', false],
['https://*/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://a.b.example.com/*', true],
['https://*.example.com/*', 'https://*.a.example.com/*', true],
['https://*.example.com/*', 'https://notexample.com/*', false],
['https://a.example.com/*', 'https://*.example.com/*', false],
['https://example.com/*', 'https://example.com/path/*', true],
['https://example.com/path/*', 'https://example.com/*', false],
['https://example.com/a*', 'https://example.com/a/b*c', true],
['https://example.com/a.b', 'https://example.com/aXb', false],
['https://example.com/*', '<all_urls>', false],
['*://*/*', 'https://example.com/*', true],
['<all_urls>', 'https://example.com/*', true],
['https://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'https://example.com/*', true],
['*://example.com/*', 'http://example.com/*', true],
['https://example.com/*', '*://example.com/*', false],
['https://example.com/*', 'http://example.com/*', false],
['*://example.com/*', 'file:///example/*', false],
['https://*/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://example.com/*', true],
['https://*.example.com/*', 'https://a.b.example.com/*', true],
['https://*.example.com/*', 'https://*.a.example.com/*', true],
['https://*.example.com/*', 'https://notexample.com/*', false],
['https://a.example.com/*', 'https://*.example.com/*', false],
['https://example.com/*', 'https://example.com/path/*', true],
['https://example.com/path/*', 'https://example.com/*', false],
['https://example.com/a*', 'https://example.com/a/b*c', true],
['https://example.com/a.b', 'https://example.com/aXb', false],
['https://example.com/*', '*://*/*', false],
['https://example.com/*', '<all_urls>', false],

const two = optionalCs(
{
registration: 'runtime',
optionalMatches: ['https://other.com/*', 'https://*.other.com/*'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented at → 39c5b88 . I left out deduping the user defined manifest host_permissions for now, as it might be confusing for users to notice how their config doesn't seem to match the output. But I am open to dedupe them too if that seems more consistent.

Maybe i'm not understand, can you provide me some examples?

Comment on lines +710 to +711
// Drop previously kept patterns that this broader pattern covers. Patterns
// in `coveredBy` are never removed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Drop previously kept patterns that this broader pattern covers. Patterns
// in `coveredBy` are never removed.
// Drop previously kept patterns that this broader pattern covers.
// Patterns in `coveredBy` are never removed.

@PatrykKuniczak

PatrykKuniczak commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

@eupthere Very good work, a couple more small things 😄

@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

@eupthere Are you want to go on with that?
If my brain braining that was on the home stretch 😄

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support new content script registration optional

4 participants