feat: Add globalName entrypoint option.
#2017
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.