Skip to content

feat: resolve the actual browser for browser-specific code generation - #2687

Open
devtechedge wants to merge 3 commits into
wxt-dev:mainfrom
devtechedge:fix/actual-browser-resolution
Open

devtechedge wants to merge 3 commits into
wxt-dev:mainfrom
devtechedge:fix/actual-browser-resolution

Conversation

@devtechedge

@devtechedge devtechedge commented Oct 24, 2026 •

Copy link
Copy Markdown

Reopening #2622, which was closed by accident when my fork was deleted. Rebased onto current main.

Overview

Fixes #2588.

Right now every build-time browser check compares wxt.config.browser against a literal like "firefox" or "safari". An ios build therefore misses every Safari check and generates the wrong manifest, even though it runs in Safari.

This PR implements the three changes proposed in the issue:

  1. InlineConfig#browser keeps working exactly as before: it still drives the output directory template, import.meta.env.BROWSER, the CHROME/FIREFOX/SAFARI/EDGE/OPERA env constants, the zip artifact name, and browser launching. Nothing changes for existing labels.

  2. InlineConfig#targetBrowserMap maps --browser strings to the actual browser. It defaults to:

    --browser value Actual browser
    chrome, edge, brave, opera, chromium chromium
    firefox firefox
    safari, ios safari

    Unknown labels are not mapped to anything by default. They resolve to themselves until the project adds an entry for them, so their behavior is unchanged.

  3. ResolvedConfig#actualBrowser: "chromium" | "firefox" | "safari" is resolved through that map and is now used for the manifest generation checks: use_dynamic_url (introduced in fix: don't set use_dynamic_url on browsers that don't support it #2581), MV2/MV3 key stripping, background/background scripts, version_name, browser_style/chrome_style, options_ui in Safari, side panels, and the Firefox warnings. The default manifest version (MV2 for Firefox and Safari) is also resolved off the actual browser now, so an ios build gets the same manifest as a safari build.

The per-entrypoint include/exclude lists and per-browser entrypoint options still key off the raw --browser label, since those are user-authored values keyed by label.

Manual Testing

  • Added mapping tests to resolve-config.test.ts: every default mapping resolves correctly, a custom targetBrowserMap entry wins over the defaults, unknown labels resolve to themselves, actualBrowser appears on the resolved config, and the output directory still uses the raw label while the default manifest version keys off the actual browser.
  • Added a manifest test proving an ios build with actualBrowser: "safari" skips the Chrome-only use_dynamic_url field.
  • Verified fail-before/pass-after: with only the source changes stashed, the new tests fail (11 config resolution assertions plus the manifest assertion); with them restored, all pass.
  • bun run check passes at the repo root, bun run test passes in packages/wxt (571 tests, one pre-existing flaky e2e that passes on re-run and is unrelated to this change).

Related Issue

This PR closes #2588. Related discussion: #2581 (comment) and #2301.

@netlify

netlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 89f1f4b
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ae57e778c3cbec06c15d246
😎 Deploy Preview https://deploy-preview-2687--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd39af51-5294-4f20-95da-31a1dce20ced

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Oct 24, 2026
@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

@devtechedge Let's resolve conflicts, yeah again 😆

I'll visit this PR, this week

@devtechedge

Copy link
Copy Markdown
Author

Thanks, Patryk, for checking in on this.

I merged the latest main into the branch and resolved the conflict in resolve-config.test.ts.

The PR is mergeable again now, and I have run the full test suite plus the lint and type checks locally, all of which pass.

The Validate and pkg.pr.new workflow runs are still waiting on first-time contributor approval, so they have not run yet.

Happy to adjust anything once you have had a chance to look at the branch.

@pkg-pr-new

pkg-pr-new Bot commented Oct 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2687

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: 89f1f4b

@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.66%. Comparing base (5c31bc8) to head (89f1f4b).

Files with missing lines Patch % Lines
packages/wxt/src/internal/manifest.ts 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2687      +/-   ##
==========================================
+ Coverage   80.44%   80.66%   +0.21%     
==========================================
  Files         139      140       +1     
  Lines        4162     4173      +11     
  Branches      961      967       +6     
==========================================
+ Hits         3348     3366      +18     
+ Misses        716      710       -6     
+ Partials       98       97       -1     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

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

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve the actual browser for any "--browser" strings

3 participants