I found a convenient way of turning my Chrome extension into modules (a lot easier to maintain etc.). I made it like this https://mcmap.net/q/158579/-how-to-import-es6-modules-in-content-script-for-chrome-extension (turning background.js into a module and then using dynamic import to get modules).
The simplified version of importing:
(async () => {
const src = chrome.extension.getURL("your/content_main.js");
const contentMain = await import(src);
contentMain.main();
})();
My question is: how could I implement it in Mozilla Firefox? As I am developing for both browsers (first for Chrome and then later copy stuff over to Firefox files and change what's needed). Earlier I just went the easy way and included all the functions in the files they are needed for Firefox version but as I have like 20 files at least then it gets dull do edit all of them etc.
When I try to use dynamic import in Firefox addon then it just doesn't load the script at all (no error log or anything in console) so I don't exactly know the problem (does Firefox just not support it at all?).