WXT should bundle multiple `background.js` scripts like it does with `content.js`
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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