export const sendToContentScript = <T extends object>(
message: ToastMessage,
) => {
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
if (tabs.length > 0 && tabs[0].id !== undefined) {
const activeTabId = tabs[0].id;
chrome.tabs.sendMessage(activeTabId, message, (response: string) => {
console.log(response);
});
}
});
};
if this function is defined in background/index.ts it works just fine if i export it to another file background/utils.ts and then import it `import {sendToContentScript} from './utils'. the service worker fails to register and extension keeps flickering.
edit this is not limited to this function