[Typescript] `browser.runtime.getURL` doesn't respect the unlisted css
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
While npx wxt prepare generates the types folder, it doesn't generate types for browser.runtime.getURL for the unlisted css (documentation).
Also, i noticed that there is an error in the description of the documentation about unlisted css.
entrypoints/{name}.(css|scss|sass|less|styl|stylus) will generates /assets/{name}.css, not /{name}.css.
Reproduction
This is a reproduction to inject css file into main world.
/entrypoints/main-world.css is the target css file will be injected into the main world.
injectCss(browser.runtime.getURL('/assets/main-world.css'))
// injectCss just creates the link element and insert into document head
The generated types for the browser.runtime.getURL looks like:
declare module "wxt/browser" {
export type PublicPath =
| ""
| "/"
| "/background.js"
| "/content-scripts/mycontent.js"
| "/icons/128.png"
| "/icons/16.png"
| "/icons/32.png"
| "/icons/48.png"
| "/inject.js"
type HtmlPublicPath = Extract<PublicPath, `${string}.html`>
export interface WxtRuntime {
getURL(path: PublicPath): string;
getURL(path: `${HtmlPublicPath}${string}`): string;
}
}
The unlisted script (inject.js) is properly generated, but unlisted css is not.
Steps to reproduce
No response
System Info
System:
OS: Windows 10 10.0.19045
CPU: (6) x64 Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz
Memory: 14.48 GB / 31.83 GB
Binaries:
Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.10.0 - ~\AppData\Local\pnpm\pnpm.CMD
Browsers:
Edge: Chromium (133.0.3065.69)
Internet Explorer: 11.0.19041.4355
npmPackages:
wxt: ^0.20.0 => 0.20.6
Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
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 running npx wxt prepare and inspect the generated types folder, comparing the existing inject.js entry with the unlisted CSS case described in the issue. Update the generated PublicPath behavior so the CSS asset path is represented, and correct the unlisted CSS description at the linked documentation page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100