wxt-dev/wxt

Generated script constants

Open

#2,020 建立於 2025年12月24日

在 GitHub 查看
 (9 留言) (1 反應) (1 負責人)TypeScript (511 fork)user submission
contribution welcomegood first issue

倉庫指標

Star
 (9,861 star)
PR 合併指標
 (平均合併 11天 22小時) (30 天內合併 51 個 PR)

描述

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

貢獻者指南