Skip to content

[Typescript] browser.runtime.getURL doesn't respect the unlisted css #1679

Open
@iyume

Description

@iyume

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions