Skip to content

Conversation

aklinker1
Copy link
Member

@aklinker1 aklinker1 commented Dec 13, 2023

This closes #282.

Now, when a content script is built, it will use different virtual entrypoints depending on the world option. If it's undefined or "ISOLATED", it will continue working as-is. If it's "MAIN", then a separate entrypoint is imported that doesn't load the webextension-polyfill, since main world content scripts run in a sandboxed environment without access to the extension APIs.

BREAKING CHANGE: In order to isolate the webextension-polyfill from being imported automatically from wxt/client when importing defineContentScript, defineContentScript and defineBackgroundScript have been moved from wxt/client to wxt/sandbox.

Copy link

netlify bot commented Dec 13, 2023

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit f4e54f4
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/657a241e1077510008afaff2
😎 Deploy Preview https://deploy-preview-284--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@aklinker1 aklinker1 self-assigned this Dec 13, 2023
@aklinker1 aklinker1 changed the title feat: Add support for "main world" content scripts feat!: Add support for "main world" content scripts Dec 13, 2023
@aklinker1 aklinker1 marked this pull request as ready for review December 13, 2023 21:34
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (0873c24) 70.20% compared to head (f4e54f4) 69.98%.

Files Patch % Lines
...rc/virtual/content-script-main-world-entrypoint.ts 0.00% 13 Missing and 1 partial ⚠️
demo/src/entrypoints/main-world.content.ts 0.00% 7 Missing and 1 partial ⚠️
scripts/build.ts 0.00% 6 Missing ⚠️
src/types/internal.ts 0.00% 6 Missing ⚠️
src/sandbox/index.ts 0.00% 4 Missing ⚠️
src/client/index.ts 0.00% 2 Missing ⚠️
src/core/builders/vite/index.ts 94.44% 1 Missing ⚠️
...irtual/content-script-isolated-world-entrypoint.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## main #284 +/- ## ========================================== - Coverage 70.20% 69.98% -0.23%  ========================================== Files 133 135 +2 Lines 7395 7459 +64 Branches 575 580 +5 ========================================== + Hits 5192 5220 +28  - Misses 2153 2187 +34  - Partials 50 52 +2 

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

@aklinker1 aklinker1 merged commit fde488a into main Dec 13, 2023
@aklinker1 aklinker1 deleted the main-world-content-scripts branch December 13, 2023 21:41
@mefengl
Copy link
Contributor

mefengl commented Dec 24, 2023

@aklinker1

It seems this line might not reflect the recent breaking changes. Should it be updated to wxt/sandbox?

return `import { defineBackground } from 'wxt/client';\nexport default defineBackground(() => void 0)`;

@aklinker1
Copy link
Member Author

@mefengl good catch! I'll fix it today

@aklinker1
Copy link
Member Author

@mefengl Fixed in #298, released in v0.12.5

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

Labels

None yet

2 participants