wxt-dev / wxt-dev/wxt

WXT should bundle multiple `background.js` scripts like it does with `content.js`

Open
#1,038 2 comments 2 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

Currently it is easy to modularize the content scripts in the entrypoints folder by simply appending .content.ts to the file name.

Add the same ability to background.js.

Is your feature request related to a bug?

N/A

What are the alternatives?

From @aaronklinker-st :

For now, a quick fix to using multiple background scripts is to use Vite's glob import:

// background/index.ts
const scripts = import.meta.glob<{ default: () => void }>('./*.background.ts', { eager: true });

export default defineBackground(() => {
  Object.values(scripts).map(script => script.default.main());
});

Then put your other files in like background/some-name.background.ts

Additional context

https://discord.com/channels/1212416027611365476/1290896813850886197

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 tracing how WXT discovers and bundles modular content scripts in the entrypoints folder, then compare that path with background script handling. Done means multiple files using the background naming convention are bundled and usable like the existing content scripts, with coverage for the new behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.