Skip to content

Comments

feat: Add globalName entrypoint option.#2017

Open
jviney wants to merge 1 commit intowxt-dev:mainfrom
jviney:add-global-name-option
Open

feat: Add globalName entrypoint option.#2017
jviney wants to merge 1 commit intowxt-dev:mainfrom
jviney:add-global-name-option

Conversation

@jviney
Copy link

@jviney jviney commented Dec 24, 2025

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 globalName option.

Questions:

  • The globalName property is available on all entrypoints - should we restrict this to just content scripts and unlisted scripts in the type definitions?
  • Is there any benefit to having the globalName option available for other entrypoint types?
  • How shall we indicate that the default value will switch to the behaviour of false in 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 globalName option on a content script or unlisted script entrypoint and check the generated JS output matches what's expected for the given option.

@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit e00a3d4
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/699a8baa46d898000894e44c
😎 Deploy Preview https://deploy-preview-2017--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 project configuration.

Copy link
Member

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

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

  • The globalName property 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 globalName option available for other entrypoint types?

No, for the above reason.

  • How shall we indicate that the default value will switch to the behaviour of false in 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

@jviney jviney force-pushed the add-global-name-option branch 4 times, most recently from bdf5f89 to ed53336 Compare February 22, 2026 04:32
@jviney jviney force-pushed the add-global-name-option branch from ed53336 to e00a3d4 Compare February 22, 2026 04:52
@jviney
Copy link
Author

jviney commented Feb 22, 2026

Ready for another review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants