Closed avi12 closed 1 month ago
I looked into google-maps-search-box.html
's output and found something interesting
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module" src="http://localhost:3000/@vite/client"></script>
<script src="http://localhost:3000/@id/virtual:wxt-html-plugins" type="module"></script>
<title>Google Maps Search Box</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="manifest.exclude" content="['firefox']">
<script type="module" crossorigin="" src="/chunks/google-maps-search-box-BxzUToPe.js"></script>
</head>
<body>
<div id="app"></div>
<script src="http://localhost:3000/src/entrypoints/google-maps-search-box.sandbox/main.ts" type="module"></script>
</body>
</html>
By commenting out the import of main.ts
, the error goes away (although the Google Maps search box won't load)
When I built a version for production, this is what I got:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google Maps Search Box</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="manifest.exclude" content="['firefox']">
<script type="module" crossorigin src="/chunks/google-maps-search-box-5_0kcOXx.js"></script>
<link rel="stylesheet" crossorigin href="/assets/google-maps-search-box-CsnkNW2S.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
Considering the <meta name="manifest.exclude" content="['firefox']">
, it seems like the framework does not properly process the sandbox
Sandbox is a MV3 only feature. Are you targeting MV3 for Firefox?
For Firefox MV3 I'm not using a sandbox
But after some debugging, I discovered that the Svelte component I used for the sandbox imported a function that used browser.i18n.getUILanguage()
, which caused the error in the first post to throw
What I changed:
export async someFunc({ language }: { language: string }) {
return ...
}
in the sandbox:
import { someFunc } from "@/lib/some-util";
const searchParams = new URLSearchParams(location.search);
const languageUi = $state(searchParams.get("langaugeUi") || "en-US");
async function processInputAddress() {
const result = await someFunc({ language: languageUi });
}
embedding
{#if import.meta.env.BROWSER !== "firefox"}
{@const params = new URLSearchParams({
langaugeUi: chrome.i18n.getLanguageUI()
})}
<iframe src="{browser.runtime.getURL(`/google-maps-search-box.html`)}?{params}"></iframe>
{/if}
that resolved it
Describe the bug
I keep getting this error when I try to load the sandbox with an iframe
Reproduction
FYI, I didn't run into this issue in Plasmo
Steps to reproduce
No response
System Info
Used Package Manager
pnpm
Validations