feat: Add globalName entrypoint option.#2017
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
aklinker1
left a comment
There was a problem hiding this comment.
- The
globalNameproperty is available on all entrypoints - should we restrict this to just content scripts and unlisted scripts in the type definitions?
Only content scripts and unlisted scripts are bundled as IIFEs, so this option is only relevant for them.
- Is there any benefit to having the
globalNameoption available for other entrypoint types?
No, for the above reason.
- How shall we indicate that the default value will switch to the behaviour of
falsein a future WXT version? Would this version change the generated output for other script types too (eg: background, popup), or will we leave them generating a named IIFE.
You don't need to indicate anything in this PR. For the PR that makes the breaking change, add a section to the PR explaining the change and migration path for people.
https://github.com/wxt-dev/wxt/blob/main/CONTRIBUTING.md#breaking-changes-policy
bdf5f89 to
ed53336
Compare
ed53336 to
e00a3d4
Compare
|
Ready for another review. |
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2017 +/- ##
==========================================
+ Coverage 76.11% 76.22% +0.10%
==========================================
Files 113 114 +1
Lines 3048 3062 +14
Branches 682 687 +5
==========================================
+ Hits 2320 2334 +14
Misses 643 643
Partials 85 85 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for helping make WXT better! |
Overview
Implements #2004
The IIFE name is not currently configurable for content scripts and unlisted scripts. The variable name can be important when inserting scripts with world=MAIN or directly via a
<script>tag to ensure there is no conflict with an existing variable name on the page.This PR is a followup to the discussion in #1897 where we decided to add a
globalNameoption.Questions:
globalNameproperty is available on all entrypoints - should we restrict this to just content scripts and unlisted scripts in the type definitions?globalNameoption available for other entrypoint types?falsein a future WXT version? Would this version change the generated output for other script types too (eg: background, popup), or will we leave them generating a named IIFE.Manual Testing
Specify the
globalNameoption on a content script or unlisted script entrypoint and check the generated JS output matches what's expected for the given option.