Skip to content

feat: Add globalName entrypoint option.#2017

Merged
aklinker1 merged 1 commit intowxt-dev:mainfrom
jviney:add-global-name-option
Feb 22, 2026
Merged

feat: Add globalName entrypoint option.#2017
aklinker1 merged 1 commit intowxt-dev:mainfrom
jviney:add-global-name-option

Conversation

@jviney
Copy link
Contributor

@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
Contributor Author

jviney commented Feb 22, 2026

Ready for another review.

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.

Nice, thanks! Will release today.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 22, 2026

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: e00a3d4

@aklinker1 aklinker1 enabled auto-merge (squash) February 22, 2026 21:04
@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.22%. Comparing base (182d575) to head (e00a3d4).
⚠️ Report is 7 commits behind head on main.

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.
📢 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 7da6f44 into wxt-dev:main Feb 22, 2026
18 of 19 checks passed
@github-actions
Copy link
Contributor

Thanks for helping make WXT better!

aklinker1 pushed a commit that referenced this pull request Feb 22, 2026
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