Skip to content

fix: don't add an empty content_scripts array for runtime-only content scripts - #2580

Merged
aklinker1 merged 1 commit into
wxt-dev:mainfrom
rxliuli:fix/empty-content-scripts-runtime-only
Aug 6, 2026
Merged

fix: don't add an empty content_scripts array for runtime-only content scripts#2580
aklinker1 merged 1 commit into
wxt-dev:mainfrom
rxliuli:fix/empty-content-scripts-runtime-only

Conversation

@rxliuli

@rxliuli rxliuli commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

manifestContentScripts.length >= 0 is a tautology (array length is never negative), so manifest.content_scripts was set to [] whenever a project had at least one content script entrypoint but every one of them used registration: 'runtime'.

Chrome and Firefox silently ignore the empty array, but Safari treats it as invalid. The build/convert step itself doesn't complain, but once the converted extension is run and inspected in Safari, its Extensions settings show:

Errors for "<Extension Name>":
❌ Empty or invalid content_scripts manifest entry.
image

(Reproduced by building a project whose only content script uses registration: 'runtime', converting it with wxt zip -b safari, then opening the extension in Safari.)

Changes

  • manifestContentScripts.length >= 0> 0, so content_scripts is only added to the manifest when there's actually something to declare.
  • Updated the existing test that asserted content_scripts equals [] for a runtime-only project — it now asserts undefined, matching the convention used elsewhere in the same file (e.g. the "skipped entrypoints" test).
  • Added a test covering the mixed case (one runtime-registered + one manifest-registered content script) to confirm the fix doesn't regress the normal case.

Test plan

  • vitest run src/core/utils/__tests__/manifest.test.ts — 92 tests passing, run repeatedly across several random faker seeds
  • tsc --noEmit — no new errors

…t scripts

`manifestContentScripts.length >= 0` is always true, so `content_scripts`
was set to `[]` in the manifest whenever every content script entrypoint
used `registration: 'runtime'`. Chrome and Firefox silently ignore the
empty array, but Safari's web extension converter flags it as an
unsupported/invalid key.
@rxliuli
rxliuli requested a review from aklinker1 as a code owner August 6, 2026 03:30
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 16733a7
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6a73ffcf9974750008953608
😎 Deploy Preview https://deploy-preview-2580--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 Aug 6, 2026
@aklinker1
aklinker1 enabled auto-merge (squash) August 6, 2026 10:16
@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/is-background

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

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: 16733a7

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.21%. Comparing base (971ffb0) to head (16733a7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2580      +/-   ##
==========================================
- Coverage   79.34%   79.21%   -0.13%     
==========================================
  Files         134      134              
  Lines        3994     3994              
  Branches      921      921              
==========================================
- Hits         3169     3164       -5     
- Misses        730      734       +4     
- Partials       95       96       +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.

@aklinker1
aklinker1 merged commit 7df7b8a into wxt-dev:main Aug 6, 2026
22 checks passed
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for helping make WXT better!

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.

2 participants