diff --git a/src/interface/index.ts b/src/interface/index.ts index 5003af7b..9e893eb7 100644 --- a/src/interface/index.ts +++ b/src/interface/index.ts @@ -1,7 +1,6 @@ import "./index.css"; import Settings from "./pages/settings.svelte"; import IconFamily from "@/resources/fonts/IconFamily.woff"; -import browser from "webextension-polyfill"; import { resolveExtensionAssetUrl } from "@/lib/extensionAssetUrl"; import renderSvelte from "./main"; import { initializeSettingsState } from "@/seqta/utils/listeners/SettingsState"; @@ -24,14 +23,18 @@ function InjectCustomIcons() { const mountPoint = document.getElementById("app"); if (!mountPoint) { - console.error("Mount point #app not found"); - throw new Error("Mount point #app not found"); -} + // In production, Rollup may put this entry in a shared chunk that content + // scripts load via `import("@/interface/main")`. Only the settings page + // has `#app` — never throw on SEQTA tabs. + verboseInfo( + "[BetterSEQTA+] Settings bootstrap skipped (no #app — not the settings page)", + ); +} else { + InjectCustomIcons(); -InjectCustomIcons(); - -(async () => { - await initializeSettingsState(); - initVerboseLogging(); - renderSvelte(Settings, mountPoint, { standalone: true }); -})(); + void (async () => { + await initializeSettingsState(); + initVerboseLogging(); + renderSvelte(Settings, mountPoint, { standalone: true }); + })(); +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 86a96d8c..3dd71519 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -147,6 +147,18 @@ export default defineConfig(({ command, mode: viteMode }) => { }, output: { assetFileNames: "assets/[name]-[hash][extname]", + manualChunks(id) { + const normalized = id.replace(/\\/g, "/"); + // Keep the Svelte mount helper out of the settings entry chunk so + // content-script `import("@/interface/main")` does not execute + // settings-page bootstrap (which requires #app). + if ( + normalized.endsWith("/interface/main.ts") || + normalized.endsWith("/interface/main.js") + ) { + return "interface-main"; + } + }, }, onwarn(warning, warn) { if (warning.code === "FILE_NAME_CONFLICT") return;