I am trying to import websocket-async
to use for my extension, but I get the error Cannot use import statement outside a module. From what I've read you can't simply import other scripts into the main file, some used dynamic import()
here but for V3 I can't managed to make it work. I've created a separate js file and added it to the:
"web_accessible_resources": [
{
"matches": ["<all_urls>"],
"resources": ["src/imports.js"]
}
],
But it still throws the error. And even if I could make it work, how could I send my Websocket object to the main thread if it didn't let me import it in the first place?
Edit: Here is how main.js is loaded:
"content_scripts": [
{
"matches": ["https://*.docs.google.com/*"],
"js": [
"src/main.js",
"src/audio-worker.js",
"src/dist/websocket-async.esm.js",
"src/dist/websocket-async.umd.js"
],
"css": ["src/style.css"],
"type": "module"
}
],
also in package.json
it has the type module