I think it could be neat to adopt more modern development approaches, for instance, the use of modules. Modules are standard and browsers support them.
The problem with extensions is that you cannot load a module for content_scripts, background_scripts, and so on. Thus, the usage is restricted to HTML pages that can import a script as module rather than plain javascript: <script src="..." type="module">.
A workaround is using bundlers. We already have a base infrastructure for that with gulp. In another project, I am using rollup to bundle everything into one or more files that can work on browsers. I am still experimenting, but perhaps having a options.bundle.js, moodle.bundle.js, sigarra.bundle.js, etc can make sense to reduce the amount of code to load on different contexts. Another benefit is the possibility to import Node.js packages. Makes it a bit easier to manage dependencies and their version. Finally, manifest.js would be simpler, I think, and require less maintenance. Because instead of listing all javascript files to be loaded, you specify a single bundle file. The loads are managed at the source code using import statements, the bundler within gulp does the rest!
I think it could be neat to adopt more modern development approaches, for instance, the use of modules. Modules are standard and browsers support them.
The problem with extensions is that you cannot load a module for
content_scripts
,background_scripts
, and so on. Thus, the usage is restricted to HTML pages that can import a script as module rather than plain javascript:<script src="..." type="module">
.A workaround is using bundlers. We already have a base infrastructure for that with
gulp
. In another project, I am usingrollup
to bundle everything into one or more files that can work on browsers. I am still experimenting, but perhaps having aoptions.bundle.js
,moodle.bundle.js
,sigarra.bundle.js
, etc can make sense to reduce the amount of code to load on different contexts. Another benefit is the possibility to import Node.js packages. Makes it a bit easier to manage dependencies and their version. Finally,manifest.js
would be simpler, I think, and require less maintenance. Because instead of listing all javascript files to be loaded, you specify a single bundle file. The loads are managed at the source code usingimport
statements, the bundler withingulp
does the rest!