MrOtherGuy / fx-autoconfig

Load custom javascript in browser context
Mozilla Public License 2.0
164 stars 10 forks source link

Loader changes in version 0.10.0 #50

Open MrOtherGuy opened 2 months ago

MrOtherGuy commented 2 months ago

Currently @backgroundmodule scripts are loaded using ChromeUtils.import() which is old mechanism meant for loading .jsm modules. All jsm use has been removed for mozilla-central already, and while the mechanism does work still, it will be removed shortly after 128 cycle. I intend to remove support during 128 cycle.

It should be pretty simple to change your scripts to ES6 modules instead - just rename the file with .sys.mjs extension and the loader will treat it correctly, most of the time at least.

Afterwards, the @backgroundmodule header will be useless, since the loader will use file extension to determine if the script is background module or not. However, I might instead make the loader check if @backgroundmodule tag exists in the header, and then ignore such scripts with a warning.

MrOtherGuy commented 1 month ago

I'll hijack this issue for discussion about all the changes in version 0.10.0.

tl;dr _ucUtils is no more, @backgroundmodule and @startup are ignored

UC_API

This is provided as a module by and "interface script" - utils/uc_api.sys.mjs. This module can be imported into your ES6 module scripts whether they are window- or background-scripts and the properties it has should be "valid" at all times. In contrast, you could not just static-import utils.sys.mjs in all scripts because depending on situation it would not give you the actual instances that boot.sys.mjs uses which lead to problems in various cases. This new version at least to me feels much more ergonomic and simple to use.