I wanted to shorten some stuff, for example document.querySelectorAll() into dom.qsa().
The code is, basically;
const dom = {}
dom.qsa = function (query) {
return document.querySelectorAll(query);
}
export default dom;
And in my popup.js file i can just write;
import dom from "./dom.js";
var elements = dom.qsa(".element");
That works perfectly. I obviously have other things for dom and other stuff like i18n, storage, etc.
But in contentScript, it doesn't allow me to use that. It says: Uncaught SyntaxError: Cannot use import statement outside a module.
Why it doesn't let me? It's a local file, uses extension's file. Is there a way to do that?