wxt-dev/wxt

Generated script constants

オープン

#2,020 opened on 2025/12/24

 (9 件のコメント) (1 件のリアクション) (1 人の担当者)TypeScript (511 件のフォーク)user submission
contribution welcomegood first issue

Repository metrics

Stars
 (9,861 個のスター)
PR merge metrics
 (平均マージ 11d 22h) (30d で 51 merged PRs)

説明

Feature Request

A common pattern is to define a content script and dynamically injecting script at runtime via

// script.ts
export default defineUnlistedScript(() => { console.log("Hello" });

// background.ts
browser.scripting.executeScript({ file: ["/script.js"] })

If the filename were to change, the user would also need to update the path used in executeScript. Curious on whether it's feasible to generate a constant enum specifying the filename. The API can look something like

export default defineUnlistedScript({
  name: "MyDynamicScript"
  main: () => { ... }
}

// background.ts
browser.scripting.executeScript({ file: [Scripts["MyDynamicScript"]] });

the value would map to the actual path.

Is your feature request related to a bug?

N/A

コントリビューターガイド