wxt-dev / wxt-dev/wxt

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

Open
#2,588 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Internally, there's lots of places where WXT makes assumptions about the strings people are using for the --browser flag. Common examples would be "chrome", "firefox", "safari", "opera", "brave", etc, but it can be anything.

The assumptions WXT makes are related to how it resolves specific things, like manifest options, that may only be supported by chrome or firefox or safari. But what if someone has both an "ios" target and a "safari" target? Any logic that checks wxt.config.browser === "safari" will miss ios, when ideally "ios" should result in the same manifest as "safari".

So WXT needs a way to resolve which browser to generate things for - but that is different from which label you're building under.

Proposing a few changes to the current ResolvedConfig and InlineConfig types:

  1. Keep using InlineConfig#browser (--browser CLI flag) for the output directory, import.meta.env.BROWSER and related runtime constants
  2. Introduce InlineConfig#targetBrowserMap: Record<TargetBrowser, " that has a good default, but that can be customized by projects to map different --browser strings to the actual browser the extension will run in
  3. Introduce ResolvedConfig.actualBrowser: "chromium" | "firefox" | "safari" which is used when generating manifest or other browser-specific code. I'm not sure if opera (or future browsers/forks) but it could be added to the union in the future, and we'd have have to update the checks.
Is your feature request related to a bug?

I thought this was already implemented, but I must have done it somewhere else, never ported into WXT.

Discussion here: https://github.com/wxt-dev/wxt/pull/2581#discussion_r3727922886

What are the alternatives?

AFAIK there is no way to "know" if a --browser is chrome or not without a way to map custom values to their actual browser.

Additional context

Related to #2301

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the InlineConfig and ResolvedConfig type definitions and the discussion on PR #2581, then trace browser-specific manifest generation. Confirm how #2301 relates. Done means custom --browser labels can map to an actual browser while the original label remains available for output directories and runtime constants.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.